Debian Codegraph @

3rd_party/range-v3/range/v3/utility/move.hpp

raw
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_MOVE_HPP
15 #define RANGES_V3_UTILITY_MOVE_HPP
16
17 #include <type_traits>
18
19 #include <meta/meta.hpp>
20
21 #include <range/v3/range_fwd.hpp>
22
23 #include <range/v3/utility/static_const.hpp>
24
25 #include <range/v3/detail/prologue.hpp>
26
27 namespace ranges
28 {
29 namespace aux
30 {
31 /// \ingroup group-utility
32 struct move_fn : move_tag
33 {
34 template<typename T>
35 constexpr meta::_t<std::remove_reference<T>> && operator()(T && t) const //
36 noexcept
37 {
38 return static_cast<meta::_t<std::remove_reference<T>> &&>(t);
39 }
40
41 /// \ingroup group-utility
42 /// \sa `move_fn`
43 template<typename T>
44 friend constexpr decltype(auto) operator|(T && t, move_fn move) noexcept
45 {
46 return move(t);
47 }
48 };
49
50 /// \ingroup group-utility
51 /// \sa `move_fn`
52 RANGES_INLINE_VARIABLE(move_fn, move)
53
54 /// \ingroup group-utility
55 /// \sa `move_fn`
56 template<typename R>
57 using move_t =
58 meta::if_c<std::is_reference<R>::value, meta::_t<std::remove_reference<R>> &&,
59 detail::decay_t<R>>;
60 } // namespace aux
61 } // namespace ranges
62
63 #include <range/v3/detail/epilogue.hpp>
64
65 #endif