diff options
author | Eric Fiselier <eric@efcs.ca> | 2017-01-17 22:10:32 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2017-01-17 22:10:32 +0000 |
commit | 38590b3845f3bddd9cf2eae85e60757ffffa5286 (patch) | |
tree | 78e32600e2bf3aba5a0d2babd9b42cc078486cfa /libcxx/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp | |
parent | bd551e9674adbf7e505f1055114d8adf0caed071 (diff) | |
download | bcm5719-llvm-38590b3845f3bddd9cf2eae85e60757ffffa5286.tar.gz bcm5719-llvm-38590b3845f3bddd9cf2eae85e60757ffffa5286.zip |
Fix std::string assignment ambiguity from braced initializer lists.
When support for `basic_string_view` was added to string it also
added new assignment operators from `basic_string_view`. These caused
ambiguity when assigning from a braced initializer. This patch fixes
that regression by making the basic_string_view assignment operator
rank lower in overload resolution by making it a template.
llvm-svn: 292276
Diffstat (limited to 'libcxx/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp')
-rw-r--r-- | libcxx/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libcxx/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp new file mode 100644 index 00000000000..8b498f1787b --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <string> + +// basic_string<charT,traits,Allocator>& +// operator=(basic_string<charT,traits,Allocator>&& str); + +#include <string> +#include <cassert> + +#include "test_macros.h" + +int main() +{ + // Test that assignment from {} and {ptr, len} are allowed and are not + // ambiguous. + { + std::string s = "hello world"; + s = {}; + assert(s.empty()); + } + { + std::string s = "hello world"; + s = {"abc", 2}; + assert(s == "ab"); + } +} |