commit f78f25f43864f38ae5a6a9fcce8f26c94fe45bcd Author: Jonathan Wakely Date: Fri Jun 4 15:59:37 2021 libstdc++: Add feature test macro for heterogeneous lookup in unordered containers Also update the C++20 status docs. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * doc/xml/manual/status_cxx2020.xml: * doc/html/*: Regenerate. * include/bits/hashtable.h (__cpp_lib_generic_unordered_lookup): Define. * include/std/version (__cpp_lib_generic_unordered_lookup): Define. * testsuite/23_containers/unordered_map/operations/1.cc: Check feature test macro. * testsuite/23_containers/unordered_set/operations/1.cc: Likewise. diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2020.xml b/libstdc++-v3/doc/xml/manual/status_cxx2020.xml index b62a432eed1..ca12d8023f1 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2020.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2020.xml @@ -429,13 +429,12 @@ or any notes about the implementation. - Atomic waiting and notifying, std::semaphore, std::latch and std::barrier P1135R6 - + 11.1 __cpp_lib_atomic_lock_free_type_aliases >= 201907L @@ -803,16 +802,25 @@ or any notes about the implementation. - Heterogeneous lookup for unordered containers P0919R3 - + 11.1 __cpp_lib_generic_unordered_lookup >= 201811 + + Refinement Proposal for P0919 + + + P1690R1 + + 11.1 + + + Adopt Consistent Container Erasure from Library Fundamentals 2 for C++20 diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index 4bdbe7dd9cc..dfc2a2a7800 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -735,7 +735,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::pair equal_range(const key_type& __k) const; -#if __cplusplus > 201702L +#if __cplusplus >= 202002L +#define __cpp_lib_generic_unordered_lookup 201811L + template, typename = __has_is_transparent_t<_Equal, _Kt>> @@ -765,7 +767,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename = __has_is_transparent_t<_Equal, _Kt>> pair _M_equal_range_tr(const _Kt& __k) const; -#endif +#endif // C++20 private: // Bucket index computation helpers. diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index ea0e18a3f9d..8d0b2b95f34 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -169,7 +169,7 @@ #define __cpp_lib_variant 201606L #endif -#if __cplusplus > 201703L +#if __cplusplus >= 202002L // c++20 #define __cpp_lib_atomic_flag_test 201907L #define __cpp_lib_atomic_float 201711L @@ -225,6 +225,7 @@ #define __cpp_lib_constexpr_tuple 201811L #define __cpp_lib_constexpr_utility 201811L #define __cpp_lib_erase_if 202002L +#define __cpp_lib_generic_unordered_lookup 201811L #define __cpp_lib_interpolate 201902L #ifdef _GLIBCXX_HAS_GTHREADS # define __cpp_lib_jthread 201911L diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/operations/1.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/operations/1.cc index 4f2df728ebb..f310a8a55ed 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/operations/1.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/operations/1.cc @@ -18,6 +18,13 @@ // { dg-do run { target c++20 } } #include + +#ifndef __cpp_lib_generic_unordered_lookup +# error "Feature-test macro for generic lookup missing in " +#elif __cpp_lib_generic_unordered_lookup < 201811L +# error "Feature-test macro for generic lookup has wrong value in " +#endif + #include struct Equal diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/operations/1.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/operations/1.cc index 34414d2434a..66826dc33ec 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/operations/1.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/operations/1.cc @@ -18,6 +18,13 @@ // { dg-do run { target c++20 } } #include + +#ifndef __cpp_lib_generic_unordered_lookup +# error "Feature-test macro for generic lookup missing in " +#elif __cpp_lib_generic_unordered_lookup < 201811L +# error "Feature-test macro for generic lookup has wrong value in " +#endif + #include struct Equal