From be71d336bd7718ed622fffb7aa9e66757f62c249 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sun, 4 Feb 2018 03:10:53 +0000 Subject: Implement LWG2989: path's streaming operators allow everything under the sun. Because path can be constructed from a ton of different types, including string and wide strings, this caused it's streaming operators to suck up all sorts of silly types via silly conversions. For example: using namespace std::experimental::filesystem::v1; std::wstring w(L"wide"); std::cout << w; // converts to path. This patch tentatively adopts the resolution to LWG2989 and fixes the issue by making the streaming operators friends of path. llvm-svn: 324189 --- .../class.path/path.nonmember/path.io.pass.cpp | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'libcxx/test/std/experimental/filesystem/class.path/path.nonmember') diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.nonmember/path.io.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.nonmember/path.io.pass.cpp index 4b7ad735c7f..8dd82a845f2 100644 --- a/libcxx/test/std/experimental/filesystem/class.path/path.nonmember/path.io.pass.cpp +++ b/libcxx/test/std/experimental/filesystem/class.path/path.nonmember/path.io.pass.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "test_macros.h" #include "test_iterators.h" @@ -35,6 +36,8 @@ MultiStringType InStr = MKSTR("abcdefg/\"hijklmnop\"/qrstuvwxyz/123456789"); MultiStringType OutStr = MKSTR("\"abcdefg/\\\"hijklmnop\\\"/qrstuvwxyz/123456789\""); + + template void doIOTest() { using namespace fs; @@ -56,10 +59,40 @@ void doIOTest() { } } +namespace impl { +using namespace fs; + +template () << std::declval())> +std::true_type is_ostreamable_imp(int); + +template +std::false_type is_ostreamable_imp(long); + +template () >> std::declval())> +std::true_type is_istreamable_imp(int); + +template +std::false_type is_istreamable_imp(long); + + +} // namespace impl + +template +struct is_ostreamable : decltype(impl::is_ostreamable_imp(0)) {}; +template +struct is_istreamable : decltype(impl::is_istreamable_imp(0)) {}; + +void test_LWG2989() { + static_assert(!is_ostreamable::value, ""); + static_assert(!is_ostreamable::value, ""); + static_assert(!is_istreamable::value, ""); + static_assert(!is_istreamable::value, ""); +} int main() { doIOTest(); doIOTest(); //doIOTest(); //doIOTest(); + test_LWG2989(); } -- cgit v1.2.3