1 | /* Boost.Flyweight test of static data initialization facilities. |
---|---|
2 | * |
3 | * Copyright 2006-2019 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) |
7 | * |
8 | * See http://www.boost.org/libs/flyweight for library home page. |
9 | */ |
10 | |
11 | #include "test_init.hpp" |
12 | |
13 | #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ |
14 | #include <boost/detail/lightweight_test.hpp> |
15 | #include <boost/flyweight.hpp> |
16 | |
17 | using namespace boost::flyweights; |
18 | |
19 | template<bool* pmark,typename Entry,typename Value> |
20 | struct marked_hashed_factory_class:hashed_factory_class<Entry,Value> |
21 | { |
22 | marked_hashed_factory_class(){*pmark=true;} |
23 | }; |
24 | |
25 | template<bool* pmark> |
26 | struct marked_hashed_factory:factory_marker |
27 | { |
28 | template<typename Entry,typename Value> |
29 | struct apply |
30 | { |
31 | typedef marked_hashed_factory_class<pmark,Entry,Value> type; |
32 | }; |
33 | }; |
34 | |
35 | namespace boost_flyweight_test{ |
36 | |
37 | bool mark1=false; |
38 | bool init1=flyweight<int,marked_hashed_factory<&mark1> >::init(); |
39 | |
40 | bool mark2=false; |
41 | flyweight<int,marked_hashed_factory<&mark2> >::initializer init2; |
42 | |
43 | } |
44 | |
45 | void test_init() |
46 | { |
47 | BOOST_TEST(boost_flyweight_test::mark1); |
48 | BOOST_TEST(boost_flyweight_test::mark2); |
49 | } |
50 |