Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:42

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2013-present
0005 //
0006 //  Use, modification and distribution is subject to the
0007 //  Boost Software License, Version 1.0. (See accompanying
0008 //  file LICENSE_1_0.txt or copy at
0009 //  http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // Project home: https://github.com/ericniebler/range-v3
0012 //
0013 
0014 #ifndef RANGES_V3_ACTION_JOIN_HPP
0015 #define RANGES_V3_ACTION_JOIN_HPP
0016 
0017 #include <vector>
0018 
0019 #include <meta/meta.hpp>
0020 
0021 #include <range/v3/range_fwd.hpp>
0022 
0023 #include <range/v3/action/action.hpp>
0024 #include <range/v3/action/concepts.hpp>
0025 #include <range/v3/action/push_back.hpp>
0026 #include <range/v3/iterator/concepts.hpp>
0027 #include <range/v3/iterator/traits.hpp>
0028 #include <range/v3/utility/static_const.hpp>
0029 
0030 #include <range/v3/detail/prologue.hpp>
0031 
0032 namespace ranges
0033 {
0034     /// \addtogroup group-actions
0035     /// @{
0036     namespace actions
0037     {
0038         template<typename Rng>
0039         using join_action_value_t_ =
0040             meta::if_c<(bool)ranges::container<range_value_t<Rng>>, //
0041                        range_value_t<Rng>,                          //
0042                        std::vector<range_value_t<range_value_t<Rng>>>>;
0043 
0044         struct join_fn
0045         {
0046             template(typename Rng)(
0047                 requires input_range<Rng> AND input_range<range_value_t<Rng>> AND
0048                     semiregular<join_action_value_t_<Rng>>)
0049             join_action_value_t_<Rng> operator()(Rng && rng) const
0050             {
0051                 join_action_value_t_<Rng> ret;
0052                 auto last = ranges::end(rng);
0053                 for(auto it = begin(rng); it != last; ++it)
0054                     push_back(ret, *it);
0055                 return ret;
0056             }
0057         };
0058 
0059         /// \relates actions::join_fn
0060         /// \sa action_closure
0061         RANGES_INLINE_VARIABLE(action_closure<join_fn>, join)
0062     } // namespace actions
0063     /// @}
0064 } // namespace ranges
0065 
0066 #include <range/v3/detail/epilogue.hpp>
0067 
0068 #endif