diff --git a/include/boost/function/function_template.hpp b/include/boost/function/function_template.hpp index 81f5f0a..2278ea5 100644 --- a/include/boost/function/function_template.hpp +++ b/include/boost/function/function_template.hpp @@ -29,7 +29,7 @@ #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES # define BOOST_FUNCTION_ARGS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, a) #else -# include +# include # define BOOST_FUNCTION_ARG(J,I,D) ::boost::forward< BOOST_PP_CAT(T,I) >(BOOST_PP_CAT(a,I)) # define BOOST_FUNCTION_ARGS BOOST_PP_ENUM(BOOST_FUNCTION_NUM_ARGS,BOOST_FUNCTION_ARG,BOOST_PP_EMPTY) #endif diff --git a/test/rvalues_test.cpp b/test/rvalues_test.cpp index 50c1f7f..977f4ba 100644 --- a/test/rvalues_test.cpp +++ b/test/rvalues_test.cpp @@ -46,6 +46,18 @@ only_movable two(BOOST_RV_REF(only_movable) t) { return BOOST_MOVE_RET(only_movable, t1); } +only_movable two_sum(BOOST_RV_REF(only_movable) t1, BOOST_RV_REF(only_movable) t2) { + only_movable ret(t1.get_value() + t2.get_value()); + return BOOST_MOVE_RET(only_movable, ret); +} + +struct sum_struct { + only_movable operator()(BOOST_RV_REF(only_movable) t1, BOOST_RV_REF(only_movable) t2) const { + only_movable ret(t1.get_value() + t2.get_value()); + return BOOST_MOVE_RET(only_movable, ret); + } +}; + #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES int three(std::string&&) { return 1; } std::string&& four(std::string&& s) { return boost::move(s); } @@ -67,6 +79,21 @@ int test_main(int, char*[]) BOOST_CHECK(om2_2.get_value() == 2); BOOST_CHECK(om2.is_moved()); + { + function f2_sum = two_sum; + only_movable om1_sum(1), om2_sum(2); + only_movable om2_sum_2 = f2_sum(boost::move(om1_sum), boost::move(om2_sum)); + BOOST_CHECK(om2_sum_2.get_value() == 3); + } + + { + sum_struct s; + function f2_sum = s; + only_movable om1_sum(1), om2_sum(2); + only_movable om2_sum_2 = f2_sum(boost::move(om1_sum), boost::move(om2_sum)); + BOOST_CHECK(om2_sum_2.get_value() == 3); + } + #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES function f3 = three; function f4 = four;