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.

57 lines
1.4KB

  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_COPY_HPP
  14. #define RANGES_V3_UTILITY_COPY_HPP
  15. #include <concepts/concepts.hpp>
  16. #include <range/v3/range_fwd.hpp>
  17. #include <range/v3/utility/static_const.hpp>
  18. namespace ranges
  19. {
  20. /// \addtogroup group-utility
  21. /// @{
  22. namespace aux
  23. {
  24. struct copy_fn : copy_tag
  25. {
  26. template<typename T>
  27. constexpr auto operator()(T && t) const -> CPP_ret(detail::decay_t<T>)( //
  28. requires constructible_from<detail::decay_t<T>, T>)
  29. {
  30. return static_cast<T &&>(t);
  31. }
  32. /// \ingroup group-utility
  33. /// \sa `copy_fn`
  34. template<typename T>
  35. friend constexpr auto operator|(T && t, copy_fn)
  36. -> CPP_broken_friend_ret(detail::decay_t<T>)( //
  37. requires constructible_from<detail::decay_t<T>, T>)
  38. {
  39. return static_cast<T &&>(t);
  40. }
  41. };
  42. /// \ingroup group-utility
  43. /// \sa `copy_fn`
  44. RANGES_INLINE_VARIABLE(copy_fn, copy)
  45. } // namespace aux
  46. /// @}
  47. } // namespace ranges
  48. #endif