/usr/include/range/v3/action/split.hpp is in librange-v3-dev 0.3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | /// \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 <vector>
#include <functional>
#include <meta/meta.hpp>
#include <range/v3/range_fwd.hpp>
#include <range/v3/to_container.hpp>
#include <range/v3/action/action.hpp>
#include <range/v3/action/concepts.hpp>
#include <range/v3/utility/functional.hpp>
#include <range/v3/utility/iterator_concepts.hpp>
#include <range/v3/utility/iterator_traits.hpp>
#include <range/v3/utility/static_const.hpp>
#include <range/v3/view/split.hpp>
#include <range/v3/view/transform.hpp>
namespace ranges
{
inline namespace v3
{
/// \addtogroup group-actions
/// @{
namespace action
{
struct split_fn
{
private:
template<typename Rng>
using split_value_t =
meta::if_c<
(bool) ranges::Container<Rng>(),
uncvref_t<Rng>,
std::vector<range_value_type_t<Rng>>>;
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<typename Rng, typename Fun,
CONCEPT_REQUIRES_(view::split_fn::FunctionConcept<Rng, Fun>())>
std::vector<split_value_t<Rng>> operator()(Rng && rng, Fun fun) const
{
return view::split(rng, std::move(fun))
| view::transform(to_<split_value_t<Rng>>()) | to_vector;
}
template<typename Rng, typename Fun,
CONCEPT_REQUIRES_(view::split_fn::PredicateConcept<Rng, Fun>())>
std::vector<split_value_t<Rng>> operator()(Rng && rng, Fun fun) const
{
return view::split(rng, std::move(fun))
| view::transform(to_<split_value_t<Rng>>()) | to_vector;
}
template<typename Rng,
CONCEPT_REQUIRES_(view::split_fn::ElementConcept<Rng>())>
std::vector<split_value_t<Rng>> operator()(Rng && rng, range_value_type_t<Rng> val) const
{
return view::split(rng, std::move(val))
| view::transform(to_<split_value_t<Rng>>()) | to_vector;
}
template<typename Rng, typename Sub,
CONCEPT_REQUIRES_(view::split_fn::SubRangeConcept<Rng, Sub>())>
std::vector<split_value_t<Rng>> operator()(Rng && rng, Sub && sub) const
{
return view::split(rng, static_cast<Sub&&>(sub))
| view::transform(to_<split_value_t<Rng>>()) | to_vector;
}
#ifndef RANGES_DOXYGEN_INVOKED
template<typename Rng, typename T,
CONCEPT_REQUIRES_(!ConvertibleTo<T, range_value_type_t<Rng>>())>
void operator()(Rng &&, T &&) const volatile
{
CONCEPT_ASSERT_MSG(ForwardRange<Rng>(),
"The object on which action::split operates must be a model of the "
"ForwardRange concept.");
CONCEPT_ASSERT_MSG(ConvertibleTo<T, range_value_type_t<Rng>>(),
"The delimiter argument to action::split must be one of the following: "
"(1) A single element of the range's value type, where the value type is a "
"model of the Regular concept, "
"(2) A ForwardRange whose value type is EqualityComparable to the input "
"range's value type, "
"(3) A Predicate that is callable with one argument of the range's reference "
"type, or "
"(4) An Invocable that accepts two arguments, the range's iterator "
"and sentinel, and that returns a std::pair<bool, I> where I is the "
"input range's difference_type.");
}
#endif
};
/// \ingroup group-actions
/// \relates split_fn
/// \sa action
RANGES_INLINE_VARIABLE(action<split_fn>, split)
}
/// @}
}
}
#endif
|