summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/filesystem/class.path
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-01-18 05:48:55 +0000
committerEric Fiselier <eric@efcs.ca>2017-01-18 05:48:55 +0000
commit337a7c542d57d936159681178d476dc0e82027f8 (patch)
tree4853ca8ac9bed33ed0c1bc336b7ac1404ec5d2ef /libcxx/test/std/experimental/filesystem/class.path
parent0320314249863792eef93cc0a222ca8a219d6c8b (diff)
downloadbcm5719-llvm-337a7c542d57d936159681178d476dc0e82027f8.tar.gz
bcm5719-llvm-337a7c542d57d936159681178d476dc0e82027f8.zip
Fix filesystem::path assignment from {}
Adding `path::operator=(string_type&&)` made the expression `p = {}` ambiguous. This path fixes that ambiguity by making the `string&&` overload a template so it ranks lower during overload resolution. llvm-svn: 292345
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/class.path')
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.assign/braced_init.pass.cpp32
-rw-r--r--libcxx/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp18
2 files changed, 50 insertions, 0 deletions
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.assign/braced_init.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.assign/braced_init.pass.cpp
new file mode 100644
index 00000000000..c5da52f6524
--- /dev/null
+++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.assign/braced_init.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <experimental/filesystem>
+
+// class path
+
+// path& operator=(path const&);
+
+#include <experimental/filesystem>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "count_new.hpp"
+
+namespace fs = std::experimental::filesystem;
+
+int main() {
+ using namespace fs;
+ path p("abc");
+ p = {};
+ assert(p.native() == "");
+}
diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp
index 9e48cbf1e7f..987c873218c 100644
--- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp
+++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp
@@ -15,6 +15,7 @@
// template <class Source>
// path& operator=(Source const&);
+// path& operator=(string_type&&);
// template <class Source>
// path& assign(Source const&);
// template <class InputIterator>
@@ -213,12 +214,29 @@ void test_sfinae() {
}
}
+void RunStringMoveTest(const char* Expect) {
+ using namespace fs;
+ std::string ss(Expect);
+ path p;
+ {
+ DisableAllocationGuard g; ((void)g);
+ path& pr = (p = std::move(ss));
+ assert(&pr == &p);
+ }
+ assert(p == Expect);
+ {
+ // Signature test
+ ASSERT_NOEXCEPT(p = std::move(ss));
+ }
+}
+
int main() {
for (auto const& MS : PathList) {
RunTestCase<char>(MS);
RunTestCase<wchar_t>(MS);
RunTestCase<char16_t>(MS);
RunTestCase<char32_t>(MS);
+ RunStringMoveTest(MS);
}
test_sfinae();
}
OpenPOWER on IntegriCloud