diff --git a/identity.html b/identity.html deleted file mode 100644 index ee5b208..0000000 --- a/identity.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - -Boost Function Object Adapter Library - - -

Identity

-

The header -<boost/functional/identity.hpp> provides the function object -boost::identity whose operator() returns its -argument. It is an implementation of C++20's std::identity -that supports C++03 and above.

-

Example

-

It is commonly used as the default projection in constrained algorithms.

-
-template<class Range, class Projection = boost::identity>
-void print(Range&& range, Projection projection = {});
-
-

Reference

-
-namespace boost {
-
-struct identity {
-    using is_transparent = unspecified;
-
-    template<class T>
-    T&& operator()(T&& value) const noexcept;
-};
-
-} // boost
-
-

Operators

-
-
template<class T> -T&& operator()(T&& value) const noexcept;
-
Returns std::forward<T>(value)
-
-
-

Copyright 2021 Glen Joseph Fernandes.

-

Distributed under the -Boost Software License, -Version 1.0.

- - diff --git a/include/boost/functional/identity.hpp b/include/boost/functional/identity.hpp index 7021c9b..ac386fb 100644 --- a/include/boost/functional/identity.hpp +++ b/include/boost/functional/identity.hpp @@ -8,54 +8,10 @@ Distributed under the Boost Software License, Version 1.0. #ifndef BOOST_FUNCTIONAL_IDENTITY_HPP #define BOOST_FUNCTIONAL_IDENTITY_HPP -#include -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) -#include -#endif - -namespace boost { - -struct identity { - typedef void is_transparent; - -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - BOOST_CONSTEXPR T&& operator()(T&& value) const BOOST_NOEXCEPT { - return std::forward(value); - } -#else - template - BOOST_CONSTEXPR const T& operator()(const T& value) const BOOST_NOEXCEPT { - return value; - } - - template - BOOST_CONSTEXPR T& operator()(T& value) const BOOST_NOEXCEPT { - 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 +/* +The header file at this path is deprecated; +use instead. +*/ +#include #endif diff --git a/index.html b/index.html index 6511667..f4315a0 100644 --- a/index.html +++ b/index.html @@ -121,12 +121,6 @@ Based on section 20.3.8 of the standard. - - - Identity - identity - [func.identity] in ISO/IEC 14882:2020 -

Usage

diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8767a0b..dbe379c 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -6,8 +6,4 @@ import testing ; 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 deleted file mode 100644 index 48eea5c..0000000 --- a/test/identity_result_of_rvalue_test.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -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 deleted file mode 100644 index 822f522..0000000 --- a/test/identity_result_of_test.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -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(); -} diff --git a/test/identity_rvalue_test.cpp b/test/identity_rvalue_test.cpp deleted file mode 100644 index d4af64d..0000000 --- a/test/identity_rvalue_test.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright 2021 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 -#include -#include -#include - -enum kind { - rvalue, - crvalue, - other -}; - -kind result(std::string&&) -{ - return rvalue; -} - -kind result(const std::string&&) -{ - return crvalue; -} - -template -kind result(T&&) -{ - return other; -} - -void simple_test() -{ - typedef std::string string; - BOOST_TEST(boost::identity()(string("a")) == string("a")); - BOOST_TEST(result(boost::identity()(string("a"))) == rvalue); - typedef const std::string cstring; - BOOST_TEST(boost::identity()(cstring("a")) == cstring("a")); - BOOST_TEST(result(boost::identity()(cstring("a"))) == crvalue); -} - -void algorithm_test() -{ - std::vector v1; - v1.push_back(std::string("a")); - v1.push_back(std::string("b")); - v1.push_back(std::string("c")); - std::vector v2(v1); - std::vector v3; - std::transform(std::make_move_iterator(v2.begin()), - std::make_move_iterator(v2.end()), - std::back_inserter(v3), - boost::identity()); - BOOST_TEST(v3 == v1); -} - -int main() -{ - simple_test(); - algorithm_test(); - return boost::report_errors(); -} -#else -int main() -{ - return 0; -} -#endif diff --git a/test/identity_test.cpp b/test/identity_test.cpp deleted file mode 100644 index 81dc239..0000000 --- a/test/identity_test.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* -Copyright 2021 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 -#include -#include -#include - -enum kind { - ref, - cref, - other -}; - -kind result(std::string&) -{ - return ref; -} - -kind result(const std::string&) -{ - return cref; -} - -template -kind result(T&) -{ - return other; -} - -template -kind result(const T&) -{ - return other; -} - -void simple_test() -{ - std::string s1("a"); - BOOST_TEST(boost::identity()(s1) == s1); - BOOST_TEST(&boost::identity()(s1) == &s1); - BOOST_TEST(result(boost::identity()(s1)) == ref); - const std::string s2("a"); - BOOST_TEST(boost::identity()(s2) == s2); - BOOST_TEST(&boost::identity()(s2) == &s2); - BOOST_TEST(result(boost::identity()(s2)) == cref); -} - -void algorithm_test() -{ - std::vector v1; - v1.push_back(std::string("a")); - v1.push_back(std::string("b")); - v1.push_back(std::string("c")); - std::vector v2; - std::transform(v1.begin(), v1.end(), std::back_inserter(v2), - boost::identity()); - BOOST_TEST(v2 == v1); -} - -int main() -{ - simple_test(); - algorithm_test(); - return boost::report_errors(); -}