|
| 1 | +// Copyright 2026 Braden Ganetsky |
| 2 | +// Distributed under the Boost Software License, Version 1.0. |
| 3 | +// https://www.boost.org/LICENSE_1_0.txt |
| 4 | + |
| 5 | +#if !defined(BOOST_UNORDERED_FOA_TESTS) |
| 6 | +#error "This test is only for the FOA-style conatiners" |
| 7 | +#endif |
| 8 | + |
| 9 | +#include <boost/unordered/unordered_flat_map.hpp> |
| 10 | +#include <boost/unordered/unordered_flat_set.hpp> |
| 11 | +#include <boost/unordered/unordered_node_map.hpp> |
| 12 | +#include <boost/unordered/unordered_node_set.hpp> |
| 13 | + |
| 14 | +using flat_map = boost::unordered::unordered_flat_map<int, int>; |
| 15 | +using flat_set = boost::unordered::unordered_flat_set<int>; |
| 16 | +using node_map = boost::unordered::unordered_node_map<int, int>; |
| 17 | +using node_set = boost::unordered::unordered_node_set<int>; |
| 18 | + |
| 19 | +struct constrained_template_converter |
| 20 | +{ |
| 21 | + struct dummy |
| 22 | + { |
| 23 | + }; |
| 24 | + template <class T, typename std::enable_if< |
| 25 | + std::is_constructible<T, dummy>::value, int>::type = 0> |
| 26 | + operator T() const |
| 27 | + { |
| 28 | + return T{}; |
| 29 | + } |
| 30 | +}; |
| 31 | + |
| 32 | +// Check whether the corresponding CFOA container gets instantiated |
| 33 | +static_assert( |
| 34 | + !std::is_constructible<flat_map, constrained_template_converter>::value); |
| 35 | +static_assert( |
| 36 | + !std::is_constructible<flat_set, constrained_template_converter>::value); |
| 37 | +static_assert( |
| 38 | + !std::is_constructible<node_map, constrained_template_converter>::value); |
| 39 | +static_assert( |
| 40 | + !std::is_constructible<node_set, constrained_template_converter>::value); |
| 41 | + |
| 42 | +#include <boost/unordered/concurrent_flat_map.hpp> |
| 43 | +#include <boost/unordered/concurrent_flat_set.hpp> |
| 44 | +#include <boost/unordered/concurrent_node_map.hpp> |
| 45 | +#include <boost/unordered/concurrent_node_set.hpp> |
| 46 | + |
| 47 | +using c_flat_map = boost::unordered::concurrent_flat_map<int, int>; |
| 48 | +using c_flat_set = boost::unordered::concurrent_flat_set<int>; |
| 49 | +using c_node_map = boost::unordered::concurrent_node_map<int, int>; |
| 50 | +using c_node_set = boost::unordered::concurrent_node_set<int>; |
| 51 | + |
| 52 | +template <class C> struct container_converter |
| 53 | +{ |
| 54 | + operator C() const { return {}; } |
| 55 | +}; |
| 56 | + |
| 57 | +// Check whether the container can be constructed with an |
| 58 | +// implicit conversion to the corresponding CFOA container |
| 59 | +static_assert( |
| 60 | + std::is_constructible<flat_map, container_converter<c_flat_map> >::value); |
| 61 | +static_assert( |
| 62 | + std::is_constructible<flat_set, container_converter<c_flat_set> >::value); |
| 63 | +static_assert( |
| 64 | + std::is_constructible<node_map, container_converter<c_node_map> >::value); |
| 65 | +static_assert( |
| 66 | + std::is_constructible<node_set, container_converter<c_node_set> >::value); |
| 67 | + |
| 68 | +int main() { return 0; } |
0 commit comments