Debian Codegraph @

3rd_party/range-v3/range/v3/view/addressof.hpp

raw
1 /// \file
2 // Range v3 library
3 //
4 // Copyright Andrey Diduh 2019
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_VIEW_ADDRESSOF_HPP
15 #define RANGES_V3_VIEW_ADDRESSOF_HPP
16
17 #include <type_traits>
18 #include <utility>
19
20 #include <meta/meta.hpp>
21
22 #include <range/v3/utility/addressof.hpp>
23 #include <range/v3/view/transform.hpp>
24 #include <range/v3/view/view.hpp>
25
26 #include <range/v3/detail/prologue.hpp>
27
28 namespace ranges
29 {
30 /// \addtogroup group-views
31 /// @{
32 namespace views
33 {
34 struct addressof_fn
35 {
36 private:
37 struct take_address
38 {
39 template<typename V>
40 constexpr V * operator()(V & value) const noexcept
41 {
42 return detail::addressof(value);
43 }
44 };
45
46 public:
47 template(typename Rng)(
48 requires viewable_range<Rng> AND input_range<Rng> AND
49 std::is_lvalue_reference<range_reference_t<Rng>>::value) //
50 constexpr auto CPP_auto_fun(operator())(Rng && rng)(const) //
51 (
52 return transform(all(static_cast<Rng &&>(rng)), take_address{}) //
53 )
54 };
55
56 /// \relates addressof_fn
57 /// \ingroup group-views
58 RANGES_INLINE_VARIABLE(view_closure<addressof_fn>, addressof)
59 } // namespace views
60 /// @}
61 } // namespace ranges
62
63 #include <range/v3/detail/epilogue.hpp>
64
65 #endif // RANGES_V3_VIEW_ADDRESSOF_HPP