Skip to content

Commit

Permalink
Remove BOOST_NO_CXX11_RVALUE_REFERENCES workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Jan 27, 2024
1 parent c9357b6 commit a9a0f90
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 22 deletions.
16 changes: 1 addition & 15 deletions include/boost/function/function_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
#define BOOST_FUNCTION_TEMPLATE_PARMS typename... T
#define BOOST_FUNCTION_TEMPLATE_ARGS T...
#define BOOST_FUNCTION_PARMS T... a
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
# define BOOST_FUNCTION_ARGS a...
#else
# define BOOST_FUNCTION_ARGS static_cast<T&&>(a)...
#endif
#define BOOST_FUNCTION_ARGS static_cast<T&&>(a)...

// Always have commas (zero args case is handled with variadics too)
#define BOOST_FUNCTION_COMMA ,
Expand Down Expand Up @@ -710,12 +706,10 @@ namespace boost {
this->assign_to_own(f);
}

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_FUNCTION_FUNCTION(BOOST_FUNCTION_FUNCTION&& f) : function_base()
{
this->move_assign(f);
}
#endif

~BOOST_FUNCTION_FUNCTION() { clear(); }

Expand Down Expand Up @@ -785,7 +779,6 @@ namespace boost {
return *this;
}

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
// Move assignment from another BOOST_FUNCTION_FUNCTION
BOOST_FUNCTION_FUNCTION& operator=(BOOST_FUNCTION_FUNCTION&& f)
{
Expand All @@ -802,7 +795,6 @@ namespace boost {
BOOST_CATCH_END
return *this;
}
#endif

void swap(BOOST_FUNCTION_FUNCTION& other)
{
Expand Down Expand Up @@ -1061,25 +1053,21 @@ class function<BOOST_FUNCTION_PARTIAL_SPEC>

function(const base_type& f) : base_type(static_cast<const base_type&>(f)){}

#ifndef BOOST_NO_CXX11_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_CXX11_RVALUE_REFERENCES
self_type& operator=(self_type&& f)
{
self_type(static_cast<self_type&&>(f)).swap(*this);
return *this;
}
#endif

template<typename Functor>
typename boost::enable_if_<
Expand All @@ -1103,13 +1091,11 @@ class function<BOOST_FUNCTION_PARTIAL_SPEC>
return *this;
}

#ifndef BOOST_NO_CXX11_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
Expand Down
3 changes: 0 additions & 3 deletions test/function_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,6 @@ static void test_move_semantics()
BOOST_CHECK(!f1.empty());
BOOST_CHECK(global_int == 1);

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
// Testing rvalue constructors
f1_type f2(static_cast<f1_type&&>(f1));
BOOST_CHECK(f1.empty());
Expand Down Expand Up @@ -796,8 +795,6 @@ static void test_move_semantics()
BOOST_CHECK(global_int == 5);
f4 = static_cast<f1_type&&>(f5);
BOOST_CHECK(global_int == 4);

#endif
}

int main()
Expand Down
4 changes: 0 additions & 4 deletions test/rvalues_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ struct sum_struct {
}
};

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
int three(std::string&&) { return 1; }
std::string&& four(std::string&& s) { return boost::move(s); }
#endif

int main()
{
Expand Down Expand Up @@ -95,13 +93,11 @@ int main()
BOOST_CHECK(om2_sum_2.get_value() == 3);
}

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
function <int(std::string&&)> f3 = three;
function <std::string&& (std::string&& s)> f4 = four;

f3(std::string("Hello"));
BOOST_CHECK(f4(std::string("world")) == "world");
#endif

return boost::report_errors();
}

0 comments on commit a9a0f90

Please sign in to comment.