diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:33:54 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:36:09 +0900 |
commit | d9ec475d945d3035377a0d89ed42e382d8988891 (patch) | |
tree | 34aff2cee4b209906243ab5499d61f3edee2982f /boost/intrusive/detail/ebo_functor_holder.hpp | |
parent | 71d216b90256936a9638f325af9bc69d720e75de (diff) | |
download | boost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.gz boost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.bz2 boost-d9ec475d945d3035377a0d89ed42e382d8988891.zip |
Imported Upstream version 1.60.0
Change-Id: Ie709530d6d5841088ceaba025cbe175a4ef43050
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/intrusive/detail/ebo_functor_holder.hpp')
-rw-r--r-- | boost/intrusive/detail/ebo_functor_holder.hpp | 132 |
1 files changed, 97 insertions, 35 deletions
diff --git a/boost/intrusive/detail/ebo_functor_holder.hpp b/boost/intrusive/detail/ebo_functor_holder.hpp index 27dd093b60..9fec5a32b7 100644 --- a/boost/intrusive/detail/ebo_functor_holder.hpp +++ b/boost/intrusive/detail/ebo_functor_holder.hpp @@ -22,6 +22,8 @@ # pragma once #endif +#include <boost/move/utility_core.hpp> + namespace boost { namespace intrusive { namespace detail { @@ -155,20 +157,63 @@ template<typename T> struct is_unary_or_binary_function : is_unary_or_binary_function_impl<T> {}; -template<typename T, bool IsEmpty = true> -class ebo_functor_holder_impl +template<typename T, bool = is_unary_or_binary_function<T>::value> +class ebo_functor_holder { + BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder) + public: - ebo_functor_holder_impl() + typedef T functor_type; + + ebo_functor_holder() + : t_() + {} + + explicit ebo_functor_holder(const T &t) + : t_(t) {} - ebo_functor_holder_impl(const T& t) - : t_(t) + + explicit ebo_functor_holder(BOOST_RV_REF(T) t) + : t_(::boost::move(t)) {} + template<class Arg1, class Arg2> - ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2) - : t_(arg1, arg2) + ebo_functor_holder(BOOST_FWD_REF(Arg1) arg1, BOOST_FWD_REF(Arg2) arg2) + : t_(::boost::forward<Arg1>(arg1), ::boost::forward<Arg2>(arg2)) + {} + + ebo_functor_holder(const ebo_functor_holder &x) + : t_(x) + {} + + ebo_functor_holder(BOOST_RV_REF(ebo_functor_holder) x) + : t_(x.t_) {} + ebo_functor_holder& operator=(BOOST_COPY_ASSIGN_REF(ebo_functor_holder) x) + { + this->get() = x.get(); + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(ebo_functor_holder) x) + { + this->get() = ::boost::move(x.get()); + return *this; + } + + ebo_functor_holder& operator=(const T &x) + { + this->get() = x; + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(T) x) + { + this->get() = ::boost::move(x); + return *this; + } + T& get(){return t_;} const T& get()const{return t_;} @@ -177,50 +222,67 @@ class ebo_functor_holder_impl }; template<typename T> -class ebo_functor_holder_impl<T, false> +class ebo_functor_holder<T, false> : public T { + BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder) + public: - ebo_functor_holder_impl() - {} - explicit ebo_functor_holder_impl(const T& t) - : T(t) + typedef T functor_type; + + ebo_functor_holder() + : T() {} - template<class Arg1, class Arg2> - ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2) - : T(arg1, arg2) + + explicit ebo_functor_holder(const T &t) + : T(t) {} - T& get(){return *this;} - const T& get()const{return *this;} -}; + explicit ebo_functor_holder(BOOST_RV_REF(T) t) + : T(::boost::move(t)) + {} -template<typename T> -class ebo_functor_holder - : public ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value> -{ - private: - typedef ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value> super; + template<class Arg1, class Arg2> + ebo_functor_holder(BOOST_FWD_REF(Arg1) arg1, BOOST_FWD_REF(Arg2) arg2) + : T(::boost::forward<Arg1>(arg1), ::boost::forward<Arg2>(arg2)) + {} - public: - typedef T functor_type; - ebo_functor_holder(){} - explicit ebo_functor_holder(const T& t) - : super(t) + ebo_functor_holder(const ebo_functor_holder &x) + : T(static_cast<const T&>(x)) {} - template<class Arg1, class Arg2> - ebo_functor_holder(const Arg1& arg1, const Arg2& arg2) - : super(arg1, arg2) + ebo_functor_holder(BOOST_RV_REF(ebo_functor_holder) x) + : T(BOOST_MOVE_BASE(T, x)) {} - ebo_functor_holder& operator=(const ebo_functor_holder& x) + ebo_functor_holder& operator=(BOOST_COPY_ASSIGN_REF(ebo_functor_holder) x) { - this->get()=x.get(); + const ebo_functor_holder&r = x; + this->get() = x.get(); + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(ebo_functor_holder) x) + { + this->get() = ::boost::move(x.get()); + return *this; + } + + ebo_functor_holder& operator=(const T &x) + { + this->get() = x; + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(T) x) + { + this->get() = ::boost::move(x); return *this; } -}; + T& get(){return *this;} + const T& get()const{return *this;} +}; } //namespace detail { } //namespace intrusive { |