/// \file // Range v3 library // // Copyright Eric Niebler 2013-present // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/ericniebler/range-v3 // #ifndef RANGES_V3_ACTION_SPLIT_HPP #define RANGES_V3_ACTION_SPLIT_HPP #include #include #include #include #include #include #include #include #include #include #include namespace ranges { /// \addtogroup group-actions /// @{ namespace actions { struct split_fn { private: template using split_value_t = meta::if_c<(bool)ranges::container, uncvref_t, std::vector>>; public: // BUGBUG something is not right with the actions. It should be possible // to move a container into a split and have elements moved into the result. template auto operator()(Rng && rng, range_value_t val) const -> CPP_ret(std::vector>)( // requires input_range && indirectly_comparable< iterator_t, range_value_t const *, ranges::equal_to>) { return views::split(rng, std::move(val)) | views::transform(to>()) | to_vector; } template auto operator()(Rng && rng, Pattern && pattern) const -> CPP_ret(std::vector>)( // requires input_range && viewable_range && forward_range && indirectly_comparable< iterator_t, iterator_t, ranges::equal_to> && (forward_range || detail::tiny_range)) { return views::split(rng, static_cast(pattern)) | views::transform(to>()) | to_vector; } }; /// \ingroup group-actions /// \relates split_fn /// \sa action RANGES_INLINE_VARIABLE(action, split) } // namespace actions /// @} } // namespace ranges #endif