1 /* Boost.Flyweight test of assoc_container_factory.
3 * Copyright 2006-2018 Joaquin M Lopez Munoz.
4 * Distributed under the Boost Software License, Version 1.0.
5 * (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
8 * See http://www.boost.org/libs/flyweight for library home page.
11 #include "test_assoc_cont_factory.hpp"
13 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
14 #include <boost/flyweight/assoc_container_factory.hpp>
15 #include <boost/flyweight/detail/is_placeholder_expr.hpp>
16 #include <boost/flyweight/flyweight.hpp>
17 #include <boost/flyweight/refcounted.hpp>
18 #include <boost/flyweight/simple_locking.hpp>
19 #include <boost/flyweight/static_holder.hpp>
20 #include <boost/mpl/if.hpp>
23 #include "test_basic_template.hpp"
25 using namespace boost::flyweights
;
27 struct reverse_set_specifier
29 template<typename Entry
,typename Key
>
32 typedef std::set
<Entry
,std::greater
<Key
> > type
;
36 struct assoc_container_factory_flyweight_specifier1
43 assoc_container_factory
<reverse_set_specifier
>
48 /* flyweight<..., assoc_container_factory_class<std::set<...> >, ...> pulls
49 * the type std::set<...> in as part of its associated ADL set and causes it
50 * to be instantiated when doing any unqualified function call like, for
51 * instance, comparing flyweights for equality, which can trigger a static
52 * assertion in concept-checked STL implementations when std::set<...> is an
53 * MPL placeholder expression. We avoid this mess with protected_set<...>.
56 struct protected_set_empty_base
{};
58 template<typename K
,typename C
,typename A
>
61 boost::flyweights::detail::is_placeholder_expression
<
64 protected_set_empty_base
,
69 struct assoc_container_factory_flyweight_specifier2
76 assoc_container_factory_class
<
79 std::greater
<boost::mpl::_2
>,
80 std::allocator
<boost::mpl::_1
>
87 void test_assoc_container_factory()
89 test_basic_template
<assoc_container_factory_flyweight_specifier1
>();
90 test_basic_template
<assoc_container_factory_flyweight_specifier2
>();