|
| 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 | +#include <boost/static_assert.hpp> |
| 6 | +#include <boost/unordered/concurrent_flat_map.hpp> |
| 7 | +#include <boost/unordered/concurrent_flat_set.hpp> |
| 8 | +#include <boost/unordered/concurrent_node_map.hpp> |
| 9 | +#include <boost/unordered/concurrent_node_set.hpp> |
| 10 | + |
| 11 | +using c_flat_map = boost::unordered::concurrent_flat_map<int, int>; |
| 12 | +using c_flat_set = boost::unordered::concurrent_flat_set<int>; |
| 13 | +using c_node_map = boost::unordered::concurrent_node_map<int, int>; |
| 14 | +using c_node_set = boost::unordered::concurrent_node_set<int>; |
| 15 | + |
| 16 | +struct constrained_template_converter |
| 17 | +{ |
| 18 | + struct dummy |
| 19 | + { |
| 20 | + }; |
| 21 | + template <class T, typename std::enable_if< |
| 22 | + std::is_constructible<T, dummy>::value, int>::type = 0> |
| 23 | + operator T() const |
| 24 | + { |
| 25 | + return T{}; |
| 26 | + } |
| 27 | +}; |
| 28 | + |
| 29 | +// Check whether the corresponding FOA container gets instantiated |
| 30 | +BOOST_STATIC_ASSERT( |
| 31 | + (!std::is_constructible<c_flat_map, constrained_template_converter>::value)); |
| 32 | +BOOST_STATIC_ASSERT( |
| 33 | + (!std::is_constructible<c_flat_set, constrained_template_converter>::value)); |
| 34 | +BOOST_STATIC_ASSERT( |
| 35 | + (!std::is_constructible<c_node_map, constrained_template_converter>::value)); |
| 36 | +BOOST_STATIC_ASSERT( |
| 37 | + (!std::is_constructible<c_node_set, constrained_template_converter>::value)); |
| 38 | + |
| 39 | +#include <boost/unordered/unordered_flat_map.hpp> |
| 40 | +#include <boost/unordered/unordered_flat_set.hpp> |
| 41 | +#include <boost/unordered/unordered_node_map.hpp> |
| 42 | +#include <boost/unordered/unordered_node_set.hpp> |
| 43 | + |
| 44 | +using flat_map = boost::unordered::unordered_flat_map<int, int>; |
| 45 | +using flat_set = boost::unordered::unordered_flat_set<int>; |
| 46 | +using node_map = boost::unordered::unordered_node_map<int, int>; |
| 47 | +using node_set = boost::unordered::unordered_node_set<int>; |
| 48 | + |
| 49 | +template <class C> struct container_converter |
| 50 | +{ |
| 51 | + operator C() const { return {}; } |
| 52 | +}; |
| 53 | + |
| 54 | +// Check whether the container can be constructed with an |
| 55 | +// implicit conversion to the corresponding FOA container |
| 56 | +BOOST_STATIC_ASSERT( |
| 57 | + (std::is_constructible<c_flat_map, container_converter<flat_map> >::value)); |
| 58 | +BOOST_STATIC_ASSERT( |
| 59 | + (std::is_constructible<c_flat_set, container_converter<flat_set> >::value)); |
| 60 | +BOOST_STATIC_ASSERT( |
| 61 | + (std::is_constructible<c_node_map, container_converter<node_map> >::value)); |
| 62 | +BOOST_STATIC_ASSERT( |
| 63 | + (std::is_constructible<c_node_set, container_converter<node_set> >::value)); |
| 64 | + |
| 65 | +int main() { return 0; } |
0 commit comments