diff --git a/test/helpers/unordered.hpp b/test/helpers/unordered.hpp index d3cbf17f..fae08422 100644 --- a/test/helpers/unordered.hpp +++ b/test/helpers/unordered.hpp @@ -21,4 +21,10 @@ #include "postfix.hpp" // clang-format on +#if defined(BOOST_LIBSTDCXX_VERSION) +#if BOOST_LIBSTDCXX_VERSION < 60000 +#define BOOST_UNORDERED_NO_INIT_TYPE_TESTS +#endif +#endif + #endif diff --git a/test/unordered/emplace_smf_tests.cpp b/test/unordered/emplace_smf_tests.cpp index b67bfe59..ed37e060 100644 --- a/test/unordered/emplace_smf_tests.cpp +++ b/test/unordered/emplace_smf_tests.cpp @@ -30,12 +30,29 @@ namespace emplace_smf_tests { counted_value(const converting_value& v) : counted_value(v.index_) {} }; + class immovable_key : public smf_counted_object + { + public: + using smf_counted_object::smf_counted_object; + immovable_key(immovable_key&&) = delete; + immovable_key& operator=(immovable_key&&) = delete; + }; + class immovable_value : public smf_counted_object + { + public: + using smf_counted_object::smf_counted_object; + immovable_value(immovable_value&&) = delete; + immovable_value& operator=(immovable_value&&) = delete; + }; + void reset_counts() { counted_key::reset_count(); counted_value::reset_count(); converting_key::reset_count(); converting_value::reset_count(); + immovable_key::reset_count(); + immovable_value::reset_count(); } #ifdef BOOST_UNORDERED_FOA_TESTS @@ -302,6 +319,59 @@ namespace emplace_smf_tests { // clang-format on + template static void emplace_smf_key_value_map_immovable_key(X*) + { +#ifndef BOOST_UNORDERED_NO_INIT_TYPE_TESTS + using container = X; + BOOST_STATIC_ASSERT( + std::is_same::value); + using mapped_type = typename X::mapped_type; + + container x; + + { + reset_counts(); + auto ret = x.emplace(0, 0); + BOOST_TEST_EQ(ret.second, true); + BOOST_TEST_EQ(immovable_key::count, (smf_count{1, 0, 0, 0, 0, 0})); + BOOST_TEST_EQ(mapped_type::count, (smf_count{1, 0, 0, 0, 0, 0})); + } + + { + reset_counts(); + auto ret = x.emplace(0, 1); + BOOST_TEST_EQ(ret.second, false); + BOOST_TEST_EQ(immovable_key::count, (smf_count{1, 0, 0, 0, 0, 1})); + BOOST_TEST_EQ(mapped_type::count, (smf_count{1, 0, 0, 0, 0, 1})); + } +#endif + } + +#ifdef BOOST_UNORDERED_FOA_TESTS + static boost::unordered_node_map* + test_smf_node_map_immovable_key_counted_value; + static boost::unordered_node_map* + test_smf_node_map_immovable_key_immovable_value; +#define EMPLACE_SMF_TESTS_MAP_IMMOVABLE_ARGS \ + ((test_smf_node_map_immovable_key_counted_value)(test_smf_node_map_immovable_key_immovable_value)) +#else + static boost::unordered_map* + test_smf_map_immovable_key_counted_value; + static boost::unordered_map* + test_smf_map_immovable_key_immovable_value; +#define EMPLACE_SMF_TESTS_MAP_IMMOVABLE_ARGS \ + ((test_smf_map_immovable_key_counted_value)(test_smf_map_immovable_key_immovable_value)) +#endif + + // clang-format off + + UNORDERED_TEST( + emplace_smf_key_value_map_immovable_key, + EMPLACE_SMF_TESTS_MAP_IMMOVABLE_ARGS + ) + + // clang-format on + } // namespace emplace_smf_tests RUN_TESTS() diff --git a/test/unordered/init_type_insert_tests.cpp b/test/unordered/init_type_insert_tests.cpp index 3358ddfe..dd72efc6 100644 --- a/test/unordered/init_type_insert_tests.cpp +++ b/test/unordered/init_type_insert_tests.cpp @@ -12,12 +12,6 @@ #include -#if defined(BOOST_LIBSTDCXX_VERSION) -#if BOOST_LIBSTDCXX_VERSION < 60000 -#define BOOST_UNORDERED_NO_INIT_TYPE_TESTS -#endif -#endif - struct move_only { int x_ = -1;