diff options
author | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
commit | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch) | |
tree | 7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/flyweight/flyweight.hpp | |
parent | bb4dd8289b351fae6b55e303f189127a394a1edd (diff) | |
download | boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2 boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip |
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/flyweight/flyweight.hpp')
-rw-r--r-- | boost/flyweight/flyweight.hpp | 58 |
1 files changed, 49 insertions, 9 deletions
diff --git a/boost/flyweight/flyweight.hpp b/boost/flyweight/flyweight.hpp index b909b676fc..fcc867c852 100644 --- a/boost/flyweight/flyweight.hpp +++ b/boost/flyweight/flyweight.hpp @@ -1,6 +1,6 @@ /* Flyweight class. * - * Copyright 2006-2009 Joaquin M Lopez Munoz. + * Copyright 2006-2014 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -11,7 +11,7 @@ #ifndef BOOST_FLYWEIGHT_FLYWEIGHT_HPP #define BOOST_FLYWEIGHT_FLYWEIGHT_HPP -#if defined(_MSC_VER)&&(_MSC_VER>=1200) +#if defined(_MSC_VER) #pragma once #endif @@ -20,6 +20,7 @@ #include <boost/detail/workaround.hpp> #include <boost/flyweight/detail/default_value_policy.hpp> #include <boost/flyweight/detail/flyweight_core.hpp> +#include <boost/flyweight/detail/perfect_fwd.hpp> #include <boost/flyweight/factory_tag.hpp> #include <boost/flyweight/flyweight_fwd.hpp> #include <boost/flyweight/locking_tag.hpp> @@ -35,10 +36,15 @@ #include <boost/mpl/not.hpp> #include <boost/mpl/or.hpp> #include <boost/parameter/binding.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/utility/swap.hpp> +#if !defined(BOOST_NO_SFINAE)&&!defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_convertible.hpp> +#include <initializer_list> +#endif + #if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400)) #pragma warning(push) #pragma warning(disable:4521) /* multiple copy ctors */ @@ -181,21 +187,55 @@ public: }; /* construct/copy/destroy */ + + flyweight():h(core::insert()){} - flyweight():h(core::insert(key_type())){} +#define BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY(args) \ + :h(core::insert(BOOST_FLYWEIGHT_FORWARD(args))){} + + BOOST_FLYWEIGHT_PERFECT_FWD_WITH_ARGS( + explicit flyweight, + BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY) + +#undef BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY + +#if !defined(BOOST_NO_SFINAE)&&!defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + template<typename V> + flyweight( + std::initializer_list<V> list, + typename boost::enable_if< + boost::is_convertible<std::initializer_list<V>,key_type> >::type* =0): + h(core::insert(list)){} +#endif + flyweight(const flyweight& x):h(x.h){} flyweight(flyweight& x):h(x.h){} - /* template ctors */ +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + flyweight(const flyweight&& x):h(x.h){} + flyweight(flyweight&& x):h(x.h){} +#endif -#define BOOST_FLYWEIGHT_PERFECT_FWD_NAME explicit flyweight -#define BOOST_FLYWEIGHT_PERFECT_FWD_BODY(n) \ - :h(core::insert(BOOST_PP_ENUM_PARAMS(n,t))){} -#include <boost/flyweight/detail/perfect_fwd.hpp> +#if !defined(BOOST_NO_SFINAE)&&!defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + template<typename V> + typename boost::enable_if< + boost::is_convertible<std::initializer_list<V>,key_type>,flyweight&>::type + operator=(std::initializer_list<V> list) + { + return operator=(flyweight(list)); + } +#endif flyweight& operator=(const flyweight& x){h=x.h;return *this;} flyweight& operator=(const value_type& x){return operator=(flyweight(x));} +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + flyweight& operator=(value_type&& x) + { + return operator=(flyweight(std::move(x))); + } +#endif + /* convertibility to underlying type */ const key_type& get_key()const{return core::key(h);} |