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)
6 * See http://www.boost.org/libs/flyweight for library home page.
9 #ifndef BOOST_FLYWEIGHT_DETAIL_DEFAULT_VALUE_POLICY_HPP
10 #define BOOST_FLYWEIGHT_DETAIL_DEFAULT_VALUE_POLICY_HPP
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>
21 /* Default value policy: the key is the same as the value.
30 template<typename Value>
31 struct default_value_policy:value_marker
33 typedef Value key_type;
34 typedef Value value_type;
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)
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.
51 #define BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY(args) \
52 :x(BOOST_FLYWEIGHT_FORWARD(args)){}
54 BOOST_FLYWEIGHT_PERFECT_FWD(
56 BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY)
58 #undef BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY
60 rep_type(const rep_type& r):x(r.x){}
62 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
63 rep_type(rep_type&& r):x(std::move(r.x)){}
66 operator const value_type&()const{return x;}
71 static void construct_value(const rep_type&){}
72 static void copy_value(const rep_type&){}
74 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
75 static void move_value(const rep_type&){}
79 } /* namespace flyweights::detail */
81 } /* namespace flyweights */
83 } /* namespace boost */