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