1/* Copyright 2006-2019 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
24namespace boost{
25
26namespace flyweights{
27
28namespace detail{
29
30template<typename Value>
31struct 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(BOOST_GCC,<=40603)
43/* GCC bug: the default ctor generated by the variadic template ctor below
44 * fails to value-initialize x.
45 */
46
47 rep_type():x(){}
48#endif
49
50#define BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY(args) \
51 :x(BOOST_FLYWEIGHT_FORWARD(args)){}
52
53 BOOST_FLYWEIGHT_PERFECT_FWD(
54 explicit rep_type,
55 BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY)
56
57#undef BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY
58
59 rep_type(const rep_type& r):x(r.x){}
60
61#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
62 rep_type(rep_type&& r):x(std::move(r.x)){}
63#endif
64
65 operator const value_type&()const{return x;}
66
67 value_type x;
68 };
69
70 static void construct_value(const rep_type&){}
71 static void copy_value(const rep_type&){}
72
73#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
74 static void move_value(const rep_type&){}
75#endif
76};
77
78} /* namespace flyweights::detail */
79
80} /* namespace flyweights */
81
82} /* namespace boost */
83
84#endif
85

source code of boost/libs/flyweight/include/boost/flyweight/detail/default_value_policy.hpp