Chris@101
|
1 /* Copyright 2006-2014 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_DETAIL_DEFAULT_VALUE_POLICY_HPP
|
Chris@16
|
10 #define BOOST_FLYWEIGHT_DETAIL_DEFAULT_VALUE_POLICY_HPP
|
Chris@16
|
11
|
Chris@101
|
12 #if defined(_MSC_VER)
|
Chris@16
|
13 #pragma once
|
Chris@16
|
14 #endif
|
Chris@16
|
15
|
Chris@101
|
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
Chris@101
|
17 #include <boost/detail/workaround.hpp>
|
Chris@101
|
18 #include <boost/flyweight/detail/perfect_fwd.hpp>
|
Chris@16
|
19 #include <boost/flyweight/detail/value_tag.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 /* Default value policy: the key is the same as the value.
|
Chris@16
|
22 */
|
Chris@16
|
23
|
Chris@16
|
24 namespace boost{
|
Chris@16
|
25
|
Chris@16
|
26 namespace flyweights{
|
Chris@16
|
27
|
Chris@16
|
28 namespace detail{
|
Chris@16
|
29
|
Chris@16
|
30 template<typename Value>
|
Chris@16
|
31 struct default_value_policy:value_marker
|
Chris@16
|
32 {
|
Chris@16
|
33 typedef Value key_type;
|
Chris@16
|
34 typedef Value value_type;
|
Chris@16
|
35
|
Chris@16
|
36 struct rep_type
|
Chris@16
|
37 {
|
Chris@16
|
38 /* template ctors */
|
Chris@16
|
39
|
Chris@101
|
40 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)&&\
|
Chris@101
|
41 !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)&&\
|
Chris@101
|
42 BOOST_WORKAROUND(__GNUC__,<=4)&&(__GNUC__<4||__GNUC_MINOR__<=4)
|
Chris@101
|
43
|
Chris@101
|
44 /* GCC 4.4.2 (and probably prior) bug: the default ctor generated by the
|
Chris@101
|
45 * variadic temmplate ctor below fails to value-initialize x.
|
Chris@101
|
46 */
|
Chris@101
|
47
|
Chris@101
|
48 rep_type():x(){}
|
Chris@101
|
49 #endif
|
Chris@101
|
50
|
Chris@101
|
51 #define BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY(args) \
|
Chris@101
|
52 :x(BOOST_FLYWEIGHT_FORWARD(args)){}
|
Chris@101
|
53
|
Chris@101
|
54 BOOST_FLYWEIGHT_PERFECT_FWD(
|
Chris@101
|
55 explicit rep_type,
|
Chris@101
|
56 BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY)
|
Chris@101
|
57
|
Chris@101
|
58 #undef BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY
|
Chris@101
|
59
|
Chris@101
|
60 rep_type(const rep_type& r):x(r.x){}
|
Chris@101
|
61
|
Chris@101
|
62 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@101
|
63 rep_type(rep_type&& r):x(std::move(r.x)){}
|
Chris@101
|
64 #endif
|
Chris@16
|
65
|
Chris@16
|
66 operator const value_type&()const{return x;}
|
Chris@16
|
67
|
Chris@16
|
68 value_type x;
|
Chris@16
|
69 };
|
Chris@16
|
70
|
Chris@16
|
71 static void construct_value(const rep_type&){}
|
Chris@16
|
72 static void copy_value(const rep_type&){}
|
Chris@101
|
73
|
Chris@101
|
74 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@101
|
75 static void move_value(const rep_type&){}
|
Chris@101
|
76 #endif
|
Chris@16
|
77 };
|
Chris@16
|
78
|
Chris@16
|
79 } /* namespace flyweights::detail */
|
Chris@16
|
80
|
Chris@16
|
81 } /* namespace flyweights */
|
Chris@16
|
82
|
Chris@16
|
83 } /* namespace boost */
|
Chris@16
|
84
|
Chris@16
|
85 #endif
|