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 | b25029437e2141fc74062d8331f3c355bfdfe0f6 (patch) | |
tree | b9476bdb46cfc8c940b62c92f6e61c13a7214a5e /test | |
parent | c72032be6013dd0507fff2c29835f214aae631e3 (diff) |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp | 31 | ||||
-rw-r--r-- | test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp | 29 |
2 files changed, 60 insertions, 0 deletions
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp new file mode 100644 index 000000000..1a4c0bd82 --- /dev/null +++ b/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/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp new file mode 100644 index 000000000..81a1c368a --- /dev/null +++ b/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()); +} |