You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

get.hpp 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_UTILITY_GET_HPP
  14. #define RANGES_V3_UTILITY_GET_HPP
  15. #include <meta/meta.hpp>
  16. #include <concepts/concepts.hpp>
  17. #include <range/v3/detail/adl_get.hpp>
  18. namespace ranges
  19. {
  20. /// \addtogroup group-utility Utility
  21. /// @{
  22. ///
  23. /// \cond
  24. namespace _get_
  25. {
  26. /// \endcond
  27. // clang-format off
  28. template<std::size_t I, typename TupleLike>
  29. constexpr auto CPP_auto_fun(get)(TupleLike &&t)
  30. (
  31. return detail::adl_get<I>(static_cast<TupleLike &&>(t))
  32. )
  33. template<typename T, typename TupleLike>
  34. constexpr auto CPP_auto_fun(get)(TupleLike &&t)
  35. (
  36. return detail::adl_get<T>(static_cast<TupleLike &&>(t))
  37. )
  38. // clang-format on
  39. template<typename T>
  40. T & get(meta::id_t<T> & value) noexcept
  41. {
  42. return value;
  43. }
  44. template<typename T>
  45. T const & get(meta::id_t<T> const & value) noexcept
  46. {
  47. return value;
  48. }
  49. template<typename T>
  50. T && get(meta::id_t<T> && value) noexcept
  51. {
  52. return static_cast<T &&>(value);
  53. }
  54. /// \cond
  55. } // namespace _get_
  56. using namespace _get_;
  57. /// \endcond
  58. /// @}
  59. } // namespace ranges
  60. #endif