Debian Codegraph @

3rd_party/range-v3/range/v3/action/join.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_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
23 #include <range/v3/action/action.hpp>
24 #include <range/v3/action/concepts.hpp>
25 #include <range/v3/action/push_back.hpp>
26 #include <range/v3/iterator/concepts.hpp>
27 #include <range/v3/iterator/traits.hpp>
28 #include <range/v3/utility/static_const.hpp>
29
30 #include <range/v3/detail/prologue.hpp>
31
32 namespace ranges
33 {
34 /// \addtogroup group-actions
35 /// @{
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
59 /// \relates actions::join_fn
60 /// \sa action_closure
61 RANGES_INLINE_VARIABLE(action_closure<join_fn>, join)
62 } // namespace actions
63 /// @}
64 } // namespace ranges
65
66 #include <range/v3/detail/epilogue.hpp>
67
68 #endif