diff -dur trunc/boost/any.hpp fix/boost/any.hpp --- trunc/boost/any.hpp Tue Jun 19 21:02:05 2012 +++ fix/boost/any.hpp Tue Jun 19 21:05:22 2012 @@ -19,6 +19,8 @@ #include #include +#include + // See boost/python/type_id.hpp // TODO: add BOOST_TYPEID_COMPARE_BY_NAME to config.hpp # if (defined(__GNUC__) && __GNUC__ >= 3) \ @@ -34,6 +36,7 @@ { class any { + BOOST_COPYABLE_AND_MOVABLE_ALT(any) public: // structors any() @@ -47,11 +50,23 @@ { } + template + any(BOOST_RV_REF(ValueType) value,typename BOOST_MOVE_MPL_NS::disable_if >::type* = 0) + : content(new holder::type >(boost::move(value))) + { + } + any(const any & other) : content(other.content ? other.content->clone() : 0) { } + any(BOOST_RV_REF(any) other) + : content(other.content) + { + other.content = 0; + } + ~any() { delete content; @@ -72,12 +87,25 @@ return *this; } + template + typename BOOST_MOVE_MPL_NS::disable_if,any >::type& operator=(BOOST_RV_REF(ValueType) rhs) + { + any(boost::move(rhs)).swap(*this); + return *this; + } + any & operator=(any rhs) { rhs.swap(*this); return *this; } + any & operator=(BOOST_RV_REF(any) rhs) + { + rhs.swap(*this); + return *this; + } + public: // queries bool empty() const @@ -119,6 +147,11 @@ holder(const ValueType & value) : held(value) + { + } + + holder(BOOST_RV_REF(ValueType) value) + : held(boost::move(value)) { }