Horizon
join.hpp
Go to the documentation of this file.
1 // 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_ACTION_JOIN_HPP
15 #define RANGES_V3_ACTION_JOIN_HPP
16 
17 #include <vector>
18 
19 #include <meta/meta.hpp>
20 
21 #include <range/v3/range_fwd.hpp>
22 
28 #include <range/v3/utility/static_const.hpp>
29 
30 #include <range/v3/detail/prologue.hpp>
31 
32 namespace ranges
33 {
36  namespace actions
37  {
38  template<typename Rng>
39  using join_action_value_t_ =
40  meta::if_c<(bool)ranges::container<range_value_t<Rng>>, //
41  range_value_t<Rng>, //
42  std::vector<range_value_t<range_value_t<Rng>>>>;
43 
44  struct join_fn
45  {
46  template(typename Rng)(
47  requires input_range<Rng> AND input_range<range_value_t<Rng>> AND
48  semiregular<join_action_value_t_<Rng>>)
49  join_action_value_t_<Rng> operator()(Rng && rng) const
50  {
51  join_action_value_t_<Rng> ret;
52  auto last = ranges::end(rng);
53  for(auto it = begin(rng); it != last; ++it)
54  push_back(ret, *it);
55  return ret;
56  }
57  };
58 
62  } // namespace actions
64 } // namespace ranges
65 
66 #include <range/v3/detail/epilogue.hpp>
67 
68 #endif
CPP_concept input_range
\concept input_range
Definition: concepts.hpp:103
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
CPP_concept container
\concept container
Definition: concepts.hpp:79
apply< quote< concat >, ListOfLists > join
Joins a list of lists into a single list.
Definition: meta.hpp:1786
apply< bind_back< quote< list >, Ts... >, L > push_back
Return a new meta::list by adding the element T to the back of L.
Definition: meta.hpp:2173
Tiny meta-programming library.
Definition: action.hpp:141
Definition: join.hpp:45