| 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 |
requires constructible_from<detail::decay_t<T>, T>) |
| 35 |
constexpr auto operator()(T && t) const -> detail::decay_t<T> |
| 36 |
{ |
| 37 |
return static_cast<T &&>(t); |
| 38 |
} |
| 39 |
|
| 40 |
/// \ingroup group-utility |
| 41 |
/// \sa `copy_fn` |
| 42 |
template<typename T> |
| 43 |
friend constexpr auto operator|(T && t, copy_fn) |
| 44 |
-> CPP_broken_friend_ret(detail::decay_t<T>)( |
| 45 |
requires constructible_from<detail::decay_t<T>, T>) |
| 46 |
{ |
| 47 |
return static_cast<T &&>(t); |
| 48 |
} |
| 49 |
}; |
| 50 |
|
| 51 |
/// \ingroup group-utility |
| 52 |
/// \sa `copy_fn` |
| 53 |
RANGES_INLINE_VARIABLE(copy_fn, copy) |
| 54 |
} // namespace aux |
| 55 |
/// @} |
| 56 |
} // namespace ranges |
| 57 |
|
| 58 |
#include <range/v3/detail/epilogue.hpp> |
| 59 |
|
| 60 |
#endif |