Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:58

0001 /*!
0002 @file
0003 Defines `boost::hana::id`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_FUNCTIONAL_ID_HPP
0011 #define BOOST_HANA_FUNCTIONAL_ID_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 
0015 
0016 namespace boost { namespace hana {
0017     //! @ingroup group-functional
0018     //! The identity function -- returns its argument unchanged.
0019     //!
0020     //! ### Example
0021     //! @include example/functional/id.cpp
0022 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0023     constexpr auto id = [](auto&& x) -> decltype(auto) {
0024         return forwarded(x);
0025     };
0026 #else
0027     struct id_t {
0028         template <typename T>
0029         constexpr T operator()(T&& t) const {
0030             return static_cast<T&&>(t);
0031         }
0032     };
0033 
0034     BOOST_HANA_INLINE_VARIABLE constexpr id_t id{};
0035 #endif
0036 }} // end namespace boost::hana
0037 
0038 #endif // !BOOST_HANA_FUNCTIONAL_ID_HPP