diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2017-11-27 15:51:36 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2017-11-27 15:51:36 +0000 |
commit | 48f365399936d6ecb38f57f4cf72a870896d954d (patch) | |
tree | 73674c6e4d79fc223149027c2f9faea14a53106c /libcxx/test/std/utilities/memory | |
parent | df97de7f966f9d01968900b09dfc20399ba9c106 (diff) | |
download | bcm5719-llvm-48f365399936d6ecb38f57f4cf72a870896d954d.tar.gz bcm5719-llvm-48f365399936d6ecb38f57f4cf72a870896d954d.zip |
Implement LWG#2948: unique_ptr does not define operator<< for stream output
llvm-svn: 319038
Diffstat (limited to 'libcxx/test/std/utilities/memory')
-rw-r--r-- | libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp | 31 | ||||
-rw-r--r-- | libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp | 29 |
2 files changed, 60 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp new file mode 100644 index 00000000000..1a4c0bd8215 --- /dev/null +++ b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp @@ -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; +} diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp new file mode 100644 index 00000000000..81a1c368a5d --- /dev/null +++ b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp @@ -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()); +} |