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