Chris@101: /* Copyright 2006-2014 Joaquin M Lopez Munoz. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: * Chris@16: * See http://www.boost.org/libs/flyweight for library home page. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_FLYWEIGHT_DETAIL_DEFAULT_VALUE_POLICY_HPP Chris@16: #define BOOST_FLYWEIGHT_DETAIL_DEFAULT_VALUE_POLICY_HPP Chris@16: Chris@101: #if defined(_MSC_VER) Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@101: #include /* keep it first to prevent nasty warns in MSVC */ Chris@101: #include Chris@101: #include Chris@16: #include Chris@16: Chris@16: /* Default value policy: the key is the same as the value. Chris@16: */ Chris@16: Chris@16: namespace boost{ Chris@16: Chris@16: namespace flyweights{ Chris@16: Chris@16: namespace detail{ Chris@16: Chris@16: template Chris@16: struct default_value_policy:value_marker Chris@16: { Chris@16: typedef Value key_type; Chris@16: typedef Value value_type; Chris@16: Chris@16: struct rep_type Chris@16: { Chris@16: /* template ctors */ Chris@16: Chris@101: #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)&&\ Chris@101: !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)&&\ Chris@101: BOOST_WORKAROUND(__GNUC__,<=4)&&(__GNUC__<4||__GNUC_MINOR__<=4) Chris@101: Chris@101: /* GCC 4.4.2 (and probably prior) bug: the default ctor generated by the Chris@101: * variadic temmplate ctor below fails to value-initialize x. Chris@101: */ Chris@101: Chris@101: rep_type():x(){} Chris@101: #endif Chris@101: Chris@101: #define BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY(args) \ Chris@101: :x(BOOST_FLYWEIGHT_FORWARD(args)){} Chris@101: Chris@101: BOOST_FLYWEIGHT_PERFECT_FWD( Chris@101: explicit rep_type, Chris@101: BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY) Chris@101: Chris@101: #undef BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY Chris@101: Chris@101: rep_type(const rep_type& r):x(r.x){} Chris@101: Chris@101: #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) Chris@101: rep_type(rep_type&& r):x(std::move(r.x)){} Chris@101: #endif Chris@16: Chris@16: operator const value_type&()const{return x;} Chris@16: Chris@16: value_type x; Chris@16: }; Chris@16: Chris@16: static void construct_value(const rep_type&){} Chris@16: static void copy_value(const rep_type&){} Chris@101: Chris@101: #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) Chris@101: static void move_value(const rep_type&){} Chris@101: #endif Chris@16: }; Chris@16: Chris@16: } /* namespace flyweights::detail */ Chris@16: Chris@16: } /* namespace flyweights */ Chris@16: Chris@16: } /* namespace boost */ Chris@16: Chris@16: #endif