From: Eric Fiselier Date: Mon, 1 Jul 2019 19:59:34 +0000 (+0000) Subject: Ensure bitset's string constructor doesn't poison the overload set. X-Git-Tag: llvmorg-10-init~1545 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d1523f7a8c2247adfee559b127206a40ce4b2591;p=platform%2Fupstream%2Fllvm.git Ensure bitset's string constructor doesn't poison the overload set. llvm-svn: 364842 --- diff --git a/libcxx/include/bitset b/libcxx/include/bitset index 9fb91e9..4755fbe 100644 --- a/libcxx/include/bitset +++ b/libcxx/include/bitset @@ -679,7 +679,7 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} - template + template::value> > explicit bitset(const _CharT* __str, typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); @@ -760,7 +760,7 @@ private: }; template -template +template bitset<_Size>::bitset(const _CharT* __str, typename basic_string<_CharT>::size_type __n, _CharT __zero, _CharT __one) diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index cdb252c..3b09c59 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -4006,6 +4006,10 @@ inline constexpr bool is_constant_evaluated() noexcept { } #endif + +template +using _IsCharLikeType = _And, is_trivial<_CharT> >; + _LIBCPP_END_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 diff --git a/libcxx/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp index 453db91..b08449c 100644 --- a/libcxx/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp +++ b/libcxx/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp @@ -74,6 +74,18 @@ void test_string_ctor() } } +struct Nonsense { + virtual ~Nonsense() {} +}; + +void test_for_non_eager_instantiation() { + // Ensure we don't accidentally instantiate `std::basic_string` + // since it may not be well formed and can cause an error in the + // non-immediate context. + static_assert(!std::is_constructible, Nonsense*>::value, ""); + static_assert(!std::is_constructible, Nonsense*, size_t, Nonsense&, Nonsense&>::value, ""); +} + int main(int, char**) { test_string_ctor<0>(); @@ -85,6 +97,7 @@ int main(int, char**) test_string_ctor<64>(); test_string_ctor<65>(); test_string_ctor<1000>(); + test_for_non_eager_instantiation(); return 0; }