File indexing completed on 2025-01-18 09:38:15
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_HOF_GUARD_FUNCTION_IDENTITY_H
0009 #define BOOST_HOF_GUARD_FUNCTION_IDENTITY_H
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include <utility>
0032 #include <initializer_list>
0033 #include <boost/hof/detail/forward.hpp>
0034 #include <boost/hof/detail/static_const_var.hpp>
0035
0036 namespace boost { namespace hof { namespace identity_detail {
0037
0038 struct identity_base
0039 {
0040 template<class T>
0041 constexpr T operator()(T&& x) const
0042 noexcept(std::is_reference<T>::value || BOOST_HOF_IS_NOTHROW_MOVE_CONSTRUCTIBLE(T))
0043 {
0044 return BOOST_HOF_FORWARD(T)(x);
0045 }
0046
0047 template<class T>
0048 constexpr std::initializer_list<T>& operator()(std::initializer_list<T>& x) const noexcept
0049 {
0050 return x;
0051 }
0052
0053 template<class T>
0054 constexpr const std::initializer_list<T>& operator()(const std::initializer_list<T>& x) const noexcept
0055 {
0056 return x;
0057 }
0058
0059 template<class T>
0060 constexpr std::initializer_list<T> operator()(std::initializer_list<T>&& x) const noexcept(noexcept(std::initializer_list<T>(std::move(x))))
0061 {
0062 return BOOST_HOF_FORWARD(std::initializer_list<T>)(x);
0063 }
0064 };
0065
0066 }
0067
0068 BOOST_HOF_DECLARE_STATIC_VAR(identity, identity_detail::identity_base);
0069
0070 }}
0071
0072 #endif