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