From 867e60113b0f703dd38bd61ad6b6b314bed5f472 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Mon, 7 Nov 2022 12:55:28 -0800 Subject: [PATCH 1/8] Add SFINAE helpers to type_traits.hpp --- .../boost/unordered/detail/implementation.hpp | 12 ----- .../boost/unordered/detail/type_traits.hpp | 50 +++++++++++++++++++ 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 48a0170d..d953b313 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -182,18 +182,6 @@ #endif #endif -// BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES - -#if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES) -#if BOOST_COMP_CLANG && __cplusplus >= 201703 -#define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 1 -#endif -#endif - -#if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES) -#define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 0 -#endif - namespace boost { namespace unordered { namespace detail { diff --git a/include/boost/unordered/detail/type_traits.hpp b/include/boost/unordered/detail/type_traits.hpp index 3d7dcf67..3fe2f404 100644 --- a/include/boost/unordered/detail/type_traits.hpp +++ b/include/boost/unordered/detail/type_traits.hpp @@ -14,6 +14,25 @@ #include #include #include +#include + +#if !defined(BOOST_NO_CXX17_DEDUCTION_GUIDES) +#include +#include +#include +#endif + +// BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES + +#if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES) +#if !defined(BOOST_NO_CXX17_DEDUCTION_GUIDES) +#define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 1 +#endif +#endif + +#if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES) +#define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 0 +#endif namespace boost { namespace unordered { @@ -52,6 +71,37 @@ namespace boost { !boost::is_convertible::value && !boost::is_convertible::value; }; + +#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES + // https://eel.is/c++draft/container.requirements#container.alloc.reqmts-34 + // https://eel.is/c++draft/container.requirements#unord.req.general-243 + + template + constexpr bool const is_input_iterator_v = + !boost::is_integral::value; + + template struct is_allocator + { + constexpr static bool const value = false; + }; + + template + struct is_allocator().allocate(std::size_t{}))> > + { + constexpr static bool const value = true; + }; + + template + constexpr bool const is_allocator_v = is_allocator::value; + + template + constexpr bool const is_hash_v = + !boost::is_integral::value && !is_allocator_v; + + template constexpr bool const is_pred_v = !is_allocator_v

; +#endif } // namespace detail } // namespace unordered } // namespace boost From 2949b37490dfadbfd5c2139b510c1ff0f621fd05 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Mon, 7 Nov 2022 10:26:30 -0800 Subject: [PATCH 2/8] Flesh out deduction_tests to include unordered_[multi]set, update to use BOOST_TEST_TRAIT_SAME --- test/unordered/deduction_tests.cpp | 441 ++++++++++++++++------------- 1 file changed, 248 insertions(+), 193 deletions(-) diff --git a/test/unordered/deduction_tests.cpp b/test/unordered/deduction_tests.cpp index cffb0c1d..e808f656 100644 --- a/test/unordered/deduction_tests.cpp +++ b/test/unordered/deduction_tests.cpp @@ -3,11 +3,14 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include #include +#include #include #include #if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES + struct hash_equals { template bool operator()(T const& x) const @@ -33,22 +36,15 @@ template struct test_allocator bool operator==(test_allocator const&) const { return true; } bool operator!=(test_allocator const&) const { return false; } }; -#endif -int main() +template