| 1 | /* |
| 2 | Copyright 2021-2023 Glen Joseph Fernandes |
| 3 | (glenjofe@gmail.com) |
| 4 | |
| 5 | Distributed under the Boost Software License, Version 1.0. |
| 6 | (http://www.boost.org/LICENSE_1_0.txt) |
| 7 | */ |
| 8 | #ifndef BOOST_CORE_IDENTITY_HPP |
| 9 | #define BOOST_CORE_IDENTITY_HPP |
| 10 | |
| 11 | #include <boost/config.hpp> |
| 12 | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
| 13 | #include <utility> |
| 14 | #endif |
| 15 | |
| 16 | namespace boost { |
| 17 | |
| 18 | struct identity { |
| 19 | typedef void is_transparent; |
| 20 | |
| 21 | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
| 22 | template<class T> |
| 23 | BOOST_CONSTEXPR T&& operator()(T&& value) const BOOST_NOEXCEPT { |
| 24 | return std::forward<T>(value); |
| 25 | } |
| 26 | #else |
| 27 | template<class T> |
| 28 | BOOST_CONSTEXPR const T& operator()(const T& value) const BOOST_NOEXCEPT { |
| 29 | return value; |
| 30 | } |
| 31 | |
| 32 | template<class T> |
| 33 | BOOST_CONSTEXPR T& operator()(T& value) const BOOST_NOEXCEPT { |
| 34 | return value; |
| 35 | } |
| 36 | #endif |
| 37 | |
| 38 | template<class> |
| 39 | struct result { }; |
| 40 | |
| 41 | template<class T> |
| 42 | struct result<identity(T&)> { |
| 43 | typedef T& type; |
| 44 | }; |
| 45 | |
| 46 | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
| 47 | template<class T> |
| 48 | struct result<identity(T)> { |
| 49 | typedef T&& type; |
| 50 | }; |
| 51 | |
| 52 | template<class T> |
| 53 | struct result<identity(T&&)> { |
| 54 | typedef T&& type; |
| 55 | }; |
| 56 | #endif |
| 57 | }; |
| 58 | |
| 59 | } /* boost */ |
| 60 | |
| 61 | #endif |
| 62 | |