diff --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv index 107b2bca110f69..07f53ee995ea16 100644 --- a/libcxx/docs/Status/Cxx20Papers.csv +++ b/libcxx/docs/Status/Cxx20Papers.csv @@ -173,7 +173,7 @@ "`P1868R2 `__","LWG","width: clarifying units of width and precision in std::format","Prague","|Complete|","14.0" "`P1937R2 `__","CWG","Fixing inconsistencies between constexpr and consteval functions","Prague","* *","" "`P1956R1 `__","LWG","On the names of low-level bit manipulation functions","Prague","|Complete|","12.0" -"`P1957R2 `__","CWG","Converting from ``T*``\ to bool should be considered narrowing (re: US 212)","Prague","* *","" +"`P1957R2 `__","CWG","Converting from ``T*``\ to bool should be considered narrowing (re: US 212)","Prague","|Complete|","18.0" "`P1963R0 `__","LWG","Fixing US 313","Prague","* *","","" "`P1964R2 `__","LWG","Wording for boolean-testable","Prague","|Complete|","13.0" "`P1970R2 `__","LWG","Consistency for size() functions: Add ranges::ssize","Prague","|Complete|","15.0","|ranges|" diff --git a/libcxx/include/variant b/libcxx/include/variant index 7df2e87cf3bf98..d89c0596b1db0d 100644 --- a/libcxx/include/variant +++ b/libcxx/include/variant @@ -1252,22 +1252,6 @@ struct __overload { auto operator()(_Tp, _Up&&) const -> __check_for_narrowing<_Tp, _Up>; }; -template -struct __overload_bool { - template > - auto operator()(bool, _Up&&) const - -> enable_if_t, __type_identity<_Tp>>; -}; - -template -struct __overload : __overload_bool {}; -template -struct __overload : __overload_bool {}; -template -struct __overload : __overload_bool {}; -template -struct __overload : __overload_bool {}; - template struct __all_overloads : _Bases... { void operator()() const; diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp index 0cab5689114360..c63626090c2fe9 100644 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "test_macros.h" @@ -145,8 +146,8 @@ void test_T_assignment_sfinae() { }; static_assert(!std::is_assignable::value, "no boolean conversion in operator="); - static_assert(!std::is_assignable::value, - "no converted to bool in operator="); + static_assert(std::is_assignable::value, + "converted to bool in operator="); } { struct X {}; @@ -295,12 +296,21 @@ void test_T_assignment_performs_assignment() { #endif // TEST_HAS_NO_EXCEPTIONS } +void test_T_assignment_vector_bool() { + std::vector vec = {true}; + std::variant v; + v = vec[0]; + assert(v.index() == 0); + assert(std::get<0>(v) == true); +} + int main(int, char**) { test_T_assignment_basic(); test_T_assignment_performs_construction(); test_T_assignment_performs_assignment(); test_T_assignment_noexcept(); test_T_assignment_sfinae(); + test_T_assignment_vector_bool(); return 0; } diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/conv.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/conv.pass.cpp index 5c1bf2bbc00bca..d93d429e262c05 100644 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/conv.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/conv.pass.cpp @@ -33,9 +33,8 @@ int main(int, char**) static_assert(!std::is_assignable, decltype("meow")>::value, ""); static_assert(!std::is_assignable, decltype("meow")>::value, ""); - static_assert(!std::is_assignable, decltype("meow")>::value, ""); - static_assert(!std::is_assignable, std::true_type>::value, ""); + static_assert(std::is_assignable, std::true_type>::value, ""); static_assert(!std::is_assignable, std::unique_ptr >::value, ""); static_assert(!std::is_assignable, decltype(nullptr)>::value, ""); diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp index 5d3e8d884ee1ae..04329f4f412b06 100644 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "test_macros.h" #include "variant_test_helpers.h" @@ -79,8 +80,8 @@ void test_T_ctor_sfinae() { }; static_assert(!std::is_constructible::value, "no boolean conversion in constructor"); - static_assert(!std::is_constructible::value, - "no converted to bool in constructor"); + static_assert(std::is_constructible::value, + "converted to bool in constructor"); } { struct X {}; @@ -138,12 +139,12 @@ void test_T_ctor_basic() { assert(std::get<0>(v) == "foo"); } { - std::variant> v = nullptr; + std::variant> v = nullptr; assert(v.index() == 1); assert(std::get<1>(v) == nullptr); } { - std::variant v = true; + std::variant v = true; assert(v.index() == 0); assert(std::get<0>(v)); } @@ -198,11 +199,19 @@ void test_construction_with_repeated_types() { static_assert(std::is_constructible::value, ""); } +void test_vector_bool() { + std::vector vec = {true}; + std::variant v = vec[0]; + assert(v.index() == 0); + assert(std::get<0>(v) == true); +} + int main(int, char**) { test_T_ctor_basic(); test_T_ctor_noexcept(); test_T_ctor_sfinae(); test_no_narrowing_check_for_class_types(); test_construction_with_repeated_types(); + test_vector_bool(); return 0; } diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/conv.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/conv.pass.cpp index 152f694ce30f43..7a4c68b5dacca7 100644 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/conv.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/conv.pass.cpp @@ -32,9 +32,8 @@ int main(int, char**) static_assert(!std::is_constructible, decltype("meow")>::value, ""); static_assert(!std::is_constructible, decltype("meow")>::value, ""); - static_assert(!std::is_constructible, decltype("meow")>::value, ""); - static_assert(!std::is_constructible, std::true_type>::value, ""); + static_assert(std::is_constructible, std::true_type>::value, ""); static_assert(!std::is_constructible, std::unique_ptr >::value, ""); static_assert(!std::is_constructible, decltype(nullptr)>::value, "");