]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* Copyright 2006-2009 Joaquin M Lopez Munoz. |
2 | * Distributed under the Boost Software License, Version 1.0. | |
3 | * (See accompanying file LICENSE_1_0.txt or copy at | |
4 | * http://www.boost.org/LICENSE_1_0.txt) | |
5 | * | |
6 | * See http://www.boost.org/libs/flyweight for library home page. | |
7 | */ | |
8 | ||
9 | #ifndef BOOST_FLYWEIGHT_SET_FACTORY_HPP | |
10 | #define BOOST_FLYWEIGHT_SET_FACTORY_HPP | |
11 | ||
12 | #if defined(_MSC_VER) | |
13 | #pragma once | |
14 | #endif | |
15 | ||
16 | #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ | |
17 | #include <boost/detail/allocator_utilities.hpp> | |
18 | #include <boost/flyweight/assoc_container_factory.hpp> | |
19 | #include <boost/flyweight/factory_tag.hpp> | |
20 | #include <boost/flyweight/set_factory_fwd.hpp> | |
21 | #include <boost/mpl/aux_/lambda_support.hpp> | |
22 | #include <boost/mpl/if.hpp> | |
23 | #include <set> | |
24 | ||
25 | /* Particularization of assoc_container_factory_class using a set. | |
26 | */ | |
27 | ||
28 | namespace boost{ | |
29 | ||
30 | namespace flyweights{ | |
31 | ||
32 | template< | |
33 | typename Entry,typename Key, | |
34 | typename Compare,typename Allocator | |
35 | > | |
36 | class set_factory_class: | |
37 | public assoc_container_factory_class< | |
38 | std::set< | |
39 | Entry, | |
40 | typename boost::mpl::if_< | |
41 | mpl::is_na<Compare>, | |
42 | std::less<Key>, | |
43 | Compare | |
44 | >::type, | |
45 | typename boost::mpl::if_< | |
46 | mpl::is_na<Allocator>, | |
47 | std::allocator<Entry>, | |
48 | Allocator | |
49 | >::type | |
50 | > | |
51 | > | |
52 | { | |
53 | public: | |
54 | typedef set_factory_class type; | |
55 | BOOST_MPL_AUX_LAMBDA_SUPPORT( | |
56 | 4,set_factory_class,(Entry,Key,Compare,Allocator)) | |
57 | }; | |
58 | ||
59 | /* set_factory_class specifier */ | |
60 | ||
61 | template< | |
62 | typename Compare,typename Allocator | |
63 | BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF | |
64 | > | |
65 | struct set_factory:factory_marker | |
66 | { | |
67 | template<typename Entry,typename Key> | |
68 | struct apply: | |
69 | mpl::apply2< | |
70 | set_factory_class< | |
71 | boost::mpl::_1,boost::mpl::_2,Compare,Allocator | |
72 | >, | |
73 | Entry,Key | |
74 | > | |
75 | {}; | |
76 | }; | |
77 | ||
78 | } /* namespace flyweights */ | |
79 | ||
80 | } /* namespace boost */ | |
81 | ||
82 | #endif |