Hi Marshall, We should merge this fix into the 4.0 release. It fixes a regression which was reported by the FreeBSD maintainers here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216177
Am I OK to merge this? /Eric On Tue, Jan 17, 2017 at 3:10 PM, Eric Fiselier via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ericwf > Date: Tue Jan 17 16:10:32 2017 > New Revision: 292276 > > URL: http://llvm.org/viewvc/llvm-project?rev=292276&view=rev > Log: > 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. > > Added: > libcxx/trunk/test/std/strings/basic.string/string.cons/ > brace_assignment.pass.cpp > Modified: > libcxx/trunk/include/string > libcxx/trunk/test/std/strings/basic.string/string.cons/ > string_view.pass.cpp > > Modified: libcxx/trunk/include/string > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ > string?rev=292276&r1=292275&r2=292276&view=diff > ============================================================ > ================== > --- libcxx/trunk/include/string (original) > +++ libcxx/trunk/include/string Tue Jan 17 16:10:32 2017 > @@ -818,6 +818,7 @@ public: > operator __self_view() const _NOEXCEPT { return __self_view(data(), > size()); } > > basic_string& operator=(const basic_string& __str); > + template <class = void> > _LIBCPP_INLINE_VISIBILITY > basic_string& operator=(__self_view __sv) {return assign(__sv);} > #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES > > Added: libcxx/trunk/test/std/strings/basic.string/string.cons/ > brace_assignment.pass.cpp > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/ > strings/basic.string/string.cons/brace_assignment.pass. > cpp?rev=292276&view=auto > ============================================================ > ================== > --- > libcxx/trunk/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp > (added) > +++ > libcxx/trunk/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp > Tue Jan 17 16:10:32 2017 > @@ -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"); > + } > +} > > Modified: libcxx/trunk/test/std/strings/basic.string/string.cons/ > string_view.pass.cpp > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/ > strings/basic.string/string.cons/string_view.pass.cpp?rev= > 292276&r1=292275&r2=292276&view=diff > ============================================================ > ================== > --- > libcxx/trunk/test/std/strings/basic.string/string.cons/string_view.pass.cpp > (original) > +++ > libcxx/trunk/test/std/strings/basic.string/string.cons/string_view.pass.cpp > Tue Jan 17 16:10:32 2017 > @@ -28,12 +28,23 @@ test(std::basic_string_view<charT> sv) > typedef std::basic_string<charT, std::char_traits<charT>, > test_allocator<charT> > S; > typedef typename S::traits_type T; > typedef typename S::allocator_type A; > + { > S s2(sv); > LIBCPP_ASSERT(s2.__invariants()); > assert(s2.size() == sv.size()); > assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); > assert(s2.get_allocator() == A()); > assert(s2.capacity() >= s2.size()); > + } > + { > + S s2; > + s2 = sv; > + LIBCPP_ASSERT(s2.__invariants()); > + assert(s2.size() == sv.size()); > + assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); > + assert(s2.get_allocator() == A()); > + assert(s2.capacity() >= s2.size()); > + } > } > > template <class charT, class A> > @@ -42,12 +53,23 @@ test(std::basic_string_view<charT> sv, c > { > typedef std::basic_string<charT, std::char_traits<charT>, A> S; > typedef typename S::traits_type T; > + { > S s2(sv, a); > LIBCPP_ASSERT(s2.__invariants()); > assert(s2.size() == sv.size()); > assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); > assert(s2.get_allocator() == a); > assert(s2.capacity() >= s2.size()); > + } > + { > + S s2(a); > + s2 = sv; > + LIBCPP_ASSERT(s2.__invariants()); > + assert(s2.size() == sv.size()); > + assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); > + assert(s2.get_allocator() == a); > + assert(s2.capacity() >= s2.size()); > + } > } > > int main() > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits