Files
externals/linux/include/ActivBoost/functional/identity.hpp
T
2023-12-15 13:15:08 -05:00

62 lines
1.3 KiB
C++

/*
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)
*/
#ifndef ACTIV_BOOST_FUNCTIONAL_IDENTITY_HPP
#define ACTIV_BOOST_FUNCTIONAL_IDENTITY_HPP
#include <ActivBoost/config.hpp>
#if !defined(ACTIV_BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
namespace Boost {
struct identity {
typedef void is_transparent;
#if !defined(ACTIV_BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T>
ACTIV_BOOST_CONSTEXPR T&& operator()(T&& value) const ACTIV_BOOST_NOEXCEPT {
return std::forward<T>(value);
}
#else
template<class T>
ACTIV_BOOST_CONSTEXPR const T& operator()(const T& value) const ACTIV_BOOST_NOEXCEPT {
return value;
}
template<class T>
ACTIV_BOOST_CONSTEXPR T& operator()(T& value) const ACTIV_BOOST_NOEXCEPT {
return value;
}
#endif
template<class>
struct result { };
template<class T>
struct result<identity(T&)> {
typedef T& type;
};
#if !defined(ACTIV_BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T>
struct result<identity(T)> {
typedef T&& type;
};
template<class T>
struct result<identity(T&&)> {
typedef T&& type;
};
#endif
};
} // boost
#endif