forked from boostorg/function
Remove BOOST_NO_CXX11_RVALUE_REFERENCES workarounds
This commit is contained in:
@ -21,11 +21,7 @@
|
|||||||
#define BOOST_FUNCTION_TEMPLATE_PARMS typename... T
|
#define BOOST_FUNCTION_TEMPLATE_PARMS typename... T
|
||||||
#define BOOST_FUNCTION_TEMPLATE_ARGS T...
|
#define BOOST_FUNCTION_TEMPLATE_ARGS T...
|
||||||
#define BOOST_FUNCTION_PARMS T... a
|
#define BOOST_FUNCTION_PARMS T... a
|
||||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
#define BOOST_FUNCTION_ARGS static_cast<T&&>(a)...
|
||||||
# define BOOST_FUNCTION_ARGS a...
|
|
||||||
#else
|
|
||||||
# define BOOST_FUNCTION_ARGS static_cast<T&&>(a)...
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Always have commas (zero args case is handled with variadics too)
|
// Always have commas (zero args case is handled with variadics too)
|
||||||
#define BOOST_FUNCTION_COMMA ,
|
#define BOOST_FUNCTION_COMMA ,
|
||||||
@ -710,12 +706,10 @@ namespace boost {
|
|||||||
this->assign_to_own(f);
|
this->assign_to_own(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
BOOST_FUNCTION_FUNCTION(BOOST_FUNCTION_FUNCTION&& f) : function_base()
|
BOOST_FUNCTION_FUNCTION(BOOST_FUNCTION_FUNCTION&& f) : function_base()
|
||||||
{
|
{
|
||||||
this->move_assign(f);
|
this->move_assign(f);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
~BOOST_FUNCTION_FUNCTION() { clear(); }
|
~BOOST_FUNCTION_FUNCTION() { clear(); }
|
||||||
|
|
||||||
@ -785,7 +779,6 @@ namespace boost {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
// Move assignment from another BOOST_FUNCTION_FUNCTION
|
// Move assignment from another BOOST_FUNCTION_FUNCTION
|
||||||
BOOST_FUNCTION_FUNCTION& operator=(BOOST_FUNCTION_FUNCTION&& f)
|
BOOST_FUNCTION_FUNCTION& operator=(BOOST_FUNCTION_FUNCTION&& f)
|
||||||
{
|
{
|
||||||
@ -802,7 +795,6 @@ namespace boost {
|
|||||||
BOOST_CATCH_END
|
BOOST_CATCH_END
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void swap(BOOST_FUNCTION_FUNCTION& other)
|
void swap(BOOST_FUNCTION_FUNCTION& other)
|
||||||
{
|
{
|
||||||
@ -1061,11 +1053,9 @@ public:
|
|||||||
|
|
||||||
function(const base_type& f) : base_type(static_cast<const base_type&>(f)){}
|
function(const base_type& f) : base_type(static_cast<const base_type&>(f)){}
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
// Move constructors
|
// Move constructors
|
||||||
function(self_type&& f): base_type(static_cast<base_type&&>(f)){}
|
function(self_type&& f): base_type(static_cast<base_type&&>(f)){}
|
||||||
function(base_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& operator=(const self_type& f)
|
||||||
{
|
{
|
||||||
@ -1073,13 +1063,11 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
self_type& operator=(self_type&& f)
|
self_type& operator=(self_type&& f)
|
||||||
{
|
{
|
||||||
self_type(static_cast<self_type&&>(f)).swap(*this);
|
self_type(static_cast<self_type&&>(f)).swap(*this);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename Functor>
|
template<typename Functor>
|
||||||
typename boost::enable_if_<
|
typename boost::enable_if_<
|
||||||
@ -1103,13 +1091,11 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
self_type& operator=(base_type&& f)
|
self_type& operator=(base_type&& f)
|
||||||
{
|
{
|
||||||
self_type(static_cast<base_type&&>(f)).swap(*this);
|
self_type(static_cast<base_type&&>(f)).swap(*this);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef BOOST_FUNCTION_PARTIAL_SPEC
|
#undef BOOST_FUNCTION_PARTIAL_SPEC
|
||||||
|
@ -754,7 +754,6 @@ static void test_move_semantics()
|
|||||||
BOOST_CHECK(!f1.empty());
|
BOOST_CHECK(!f1.empty());
|
||||||
BOOST_CHECK(global_int == 1);
|
BOOST_CHECK(global_int == 1);
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
// Testing rvalue constructors
|
// Testing rvalue constructors
|
||||||
f1_type f2(static_cast<f1_type&&>(f1));
|
f1_type f2(static_cast<f1_type&&>(f1));
|
||||||
BOOST_CHECK(f1.empty());
|
BOOST_CHECK(f1.empty());
|
||||||
@ -796,8 +795,6 @@ static void test_move_semantics()
|
|||||||
BOOST_CHECK(global_int == 5);
|
BOOST_CHECK(global_int == 5);
|
||||||
f4 = static_cast<f1_type&&>(f5);
|
f4 = static_cast<f1_type&&>(f5);
|
||||||
BOOST_CHECK(global_int == 4);
|
BOOST_CHECK(global_int == 4);
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -59,10 +59,8 @@ struct sum_struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
int three(std::string&&) { return 1; }
|
int three(std::string&&) { return 1; }
|
||||||
std::string&& four(std::string&& s) { return boost::move(s); }
|
std::string&& four(std::string&& s) { return boost::move(s); }
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -95,13 +93,11 @@ int main()
|
|||||||
BOOST_CHECK(om2_sum_2.get_value() == 3);
|
BOOST_CHECK(om2_sum_2.get_value() == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
function <int(std::string&&)> f3 = three;
|
function <int(std::string&&)> f3 = three;
|
||||||
function <std::string&& (std::string&& s)> f4 = four;
|
function <std::string&& (std::string&& s)> f4 = four;
|
||||||
|
|
||||||
f3(std::string("Hello"));
|
f3(std::string("Hello"));
|
||||||
BOOST_CHECK(f4(std::string("world")) == "world");
|
BOOST_CHECK(f4(std::string("world")) == "world");
|
||||||
#endif
|
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user