/// \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_WHEN_HPP #define RANGES_V3_ACTION_SPLIT_WHEN_HPP #include #include #include #include #include #include #include #include #include #include #include #include namespace ranges { /// \addtogroup group-actions /// @{ namespace actions { struct split_when_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, Fun fun) const // -> CPP_ret(std::vector>)( // requires forward_range && // invocable, sentinel_t> && invocable< Fun &, iterator_t, iterator_t> && copy_constructible && convertible_to< invoke_result_t, sentinel_t>, std::pair>>) { return views::split_when(rng, std::move(fun)) | views::transform(to>()) | to_vector; } template auto operator()(Rng && rng, Fun fun) const -> CPP_ret(std::vector>)( // requires forward_range && predicate< Fun const &, range_reference_t> && copy_constructible) { return views::split_when(rng, std::move(fun)) | views::transform(to>()) | to_vector; } }; /// \ingroup group-actions /// \relates split_fn /// \sa action RANGES_INLINE_VARIABLE(action, split_when) } // namespace actions /// @} } // namespace ranges #endif