Horizon
addressof.hpp
Go to the documentation of this file.
1 // 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>
24 #include <range/v3/view/view.hpp>
25 
26 #include <range/v3/detail/prologue.hpp>
27 
28 namespace ranges
29 {
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 
59  } // namespace views
61 } // namespace ranges
62 
63 #include <range/v3/detail/epilogue.hpp>
64 
65 #endif // RANGES_V3_VIEW_ADDRESSOF_HPP
RANGES_INLINE_VARIABLE(detail::to_container_fn< detail::from_range< std::vector >>, to_vector) template< template< typename... > class ContT > auto to(RANGES_HIDDEN_DETAIL(detail
For initializing a container of the specified type with the elements of an Range.
Definition: conversion.hpp:399
_t< detail::transform_< list< Args... > >> transform
Return a new meta::list constructed by transforming all the elements in L with the unary invocable Fn...
Definition: meta.hpp:1855
Tiny meta-programming library.
Definition: addressof.hpp:35
Definition: view.hpp:178