identity.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /// \file
  2. // Range v3 library
  3. //
  4. // Copyright Eric Niebler 2013-present
  5. //
  6. // Use, modification and distribution is subject to the
  7. // Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. // Project home: https://github.com/ericniebler/range-v3
  12. //
  13. #ifndef RANGES_V3_FUNCTIONAL_IDENTITY_HPP
  14. #define RANGES_V3_FUNCTIONAL_IDENTITY_HPP
  15. #include <range/v3/detail/config.hpp>
  16. #include <range/v3/detail/prologue.hpp>
  17. namespace ranges
  18. {
  19. /// \addtogroup group-functional
  20. /// @{
  21. struct identity
  22. {
  23. template<typename T>
  24. constexpr T && operator()(T && t) const noexcept
  25. {
  26. return (T &&) t;
  27. }
  28. using is_transparent = void;
  29. };
  30. /// \cond
  31. using ident RANGES_DEPRECATED("Replace uses of ranges::ident with ranges::identity") =
  32. identity;
  33. /// \endcond
  34. namespace cpp20
  35. {
  36. using ranges::identity;
  37. }
  38. /// @}
  39. } // namespace ranges
  40. #include <range/v3/detail/epilogue.hpp>
  41. #endif