Implement LWG#2948: unique_ptr does not define operator<< for stream output
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@319038 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// unique_ptr
|
||||
|
||||
// template<class CharT, class Traits, class Y, class D>
|
||||
// basic_ostream<CharT, Traits>&
|
||||
// operator<<(basic_ostream<CharT, Traits>& os, const unique_ptr<Y, D>& p);
|
||||
|
||||
// -?- Remarks: This function shall not participate in overload resolution unless os << p.get() is a valid expression.
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
class A {};
|
||||
|
||||
int main()
|
||||
{
|
||||
std::unique_ptr<A> p(new A);
|
||||
std::ostringstream os;
|
||||
os << p;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// unique_ptr
|
||||
|
||||
// template<class CharT, class Traits, class Y, class D>
|
||||
// basic_ostream<CharT, Traits>&
|
||||
// operator<<(basic_ostream<CharT, Traits>& os, const unique_ptr<Y, D>& p);
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::unique_ptr<int> p(new int(3));
|
||||
std::ostringstream os;
|
||||
assert(os.str().empty());
|
||||
os << p;
|
||||
assert(!os.str().empty());
|
||||
}
|
||||
Reference in New Issue
Block a user