forked from boostorg/function
Merge from trunk: added move assignment and move constructors to Boost.Function (fixes #7330)
[SVN r80738]
This commit is contained in:
@ -748,7 +748,14 @@ namespace boost {
|
||||
{
|
||||
this->assign_to_own(f);
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
BOOST_FUNCTION_FUNCTION(BOOST_FUNCTION_FUNCTION&& f) : function_base()
|
||||
{
|
||||
this->move_assign(f);
|
||||
}
|
||||
#endif
|
||||
|
||||
~BOOST_FUNCTION_FUNCTION() { clear(); }
|
||||
|
||||
result_type operator()(BOOST_FUNCTION_PARMS) const
|
||||
@ -830,6 +837,26 @@ namespace boost {
|
||||
BOOST_CATCH_END
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
// Move assignment from another BOOST_FUNCTION_FUNCTION
|
||||
BOOST_FUNCTION_FUNCTION& operator=(BOOST_FUNCTION_FUNCTION&& f)
|
||||
{
|
||||
|
||||
if (&f == this)
|
||||
return *this;
|
||||
|
||||
this->clear();
|
||||
BOOST_TRY {
|
||||
this->move_assign(f);
|
||||
} BOOST_CATCH (...) {
|
||||
vtable = 0;
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
void swap(BOOST_FUNCTION_FUNCTION& other)
|
||||
{
|
||||
@ -1063,12 +1090,26 @@ public:
|
||||
|
||||
function(const base_type& f) : base_type(static_cast<const base_type&>(f)){}
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
// Move constructors
|
||||
function(self_type&& f): base_type(static_cast<base_type&&>(f)){}
|
||||
function(base_type&& f): base_type(static_cast<base_type&&>(f)){}
|
||||
#endif
|
||||
|
||||
self_type& operator=(const self_type& f)
|
||||
{
|
||||
self_type(f).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
self_type& operator=(self_type&& f)
|
||||
{
|
||||
self_type(static_cast<self_type&&>(f)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename Functor>
|
||||
#ifndef BOOST_NO_SFINAE
|
||||
typename enable_if_c<
|
||||
@ -1097,6 +1138,14 @@ public:
|
||||
self_type(f).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
self_type& operator=(base_type&& f)
|
||||
{
|
||||
self_type(static_cast<base_type&&>(f)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#undef BOOST_FUNCTION_PARTIAL_SPEC
|
||||
|
Reference in New Issue
Block a user