diff --git a/include/boost/functional/identity.hpp b/include/boost/functional/identity.hpp index a4929a9..7021c9b 100644 --- a/include/boost/functional/identity.hpp +++ b/include/boost/functional/identity.hpp @@ -34,6 +34,26 @@ struct identity { return value; } #endif + + template + struct result { }; + + template + struct result { + typedef T& type; + }; + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template + struct result { + typedef T&& type; + }; + + template + struct result { + typedef T&& type; + }; +#endif }; } // boost diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 71de379..8767a0b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -8,4 +8,6 @@ test-suite functional : [ run function_test.cpp ] [ run identity_test.cpp ] [ run identity_rvalue_test.cpp ] + [ run identity_result_of_test.cpp ] + [ run identity_result_of_rvalue_test.cpp ] ; diff --git a/test/identity_result_of_rvalue_test.cpp b/test/identity_result_of_rvalue_test.cpp new file mode 100644 index 0000000..48eea5c --- /dev/null +++ b/test/identity_result_of_rvalue_test.cpp @@ -0,0 +1,31 @@ +/* +Copyright 2022 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +#include +#include +#include + +int main() +{ + BOOST_TEST_TRAIT_SAME(boost::result_of::type, + int&&); + BOOST_TEST_TRAIT_SAME(boost::result_of::type, + int&&); + BOOST_TEST_TRAIT_SAME(boost::result_of::type, + int&&); + BOOST_TEST_TRAIT_SAME(boost::result_of::type, + const int&&); + return boost::report_errors(); +} +#else +int main() +{ + return 0; +} +#endif diff --git a/test/identity_result_of_test.cpp b/test/identity_result_of_test.cpp new file mode 100644 index 0000000..822f522 --- /dev/null +++ b/test/identity_result_of_test.cpp @@ -0,0 +1,18 @@ +/* +Copyright 2022 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include + +int main() +{ + BOOST_TEST_TRAIT_SAME(boost::result_of::type, int&); + BOOST_TEST_TRAIT_SAME(boost::result_of::type, + const int&); + return boost::report_errors(); +}