/usr/include/range/v3/action/action.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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | /// \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_CONTAINER_ACTION_HPP
#define RANGES_V3_CONTAINER_ACTION_HPP
#include <type_traits>
#include <meta/meta.hpp>
#include <range/v3/range_fwd.hpp>
#include <range/v3/range_concepts.hpp>
#include <range/v3/action/concepts.hpp>
#include <range/v3/utility/functional.hpp>
#include <range/v3/utility/static_const.hpp>
namespace ranges
{
inline namespace v3
{
/// \addtogroup group-actions
/// @{
namespace action
{
struct action_access
{
template<typename Action>
struct impl
{
template<typename...Ts, typename A = Action>
static auto bind(Ts &&...ts)
RANGES_DECLTYPE_AUTO_RETURN
(
A::bind(static_cast<Ts&&>(ts)...)
)
};
};
struct make_action_fn
{
template<typename Fun>
action<Fun> operator()(Fun fun) const
{
return {detail::move(fun)};
}
};
/// \ingroup group-actions
/// \relates make_action_fn
RANGES_INLINE_VARIABLE(make_action_fn, make_action)
template<typename Action>
struct action : pipeable<action<Action>>
{
private:
Action action_;
friend pipeable_access;
template<typename Rng, typename...Rest>
using ActionConcept = meta::and_<
Range<Rng>,
Invocable<Action const&, Rng, Rest...>>;
template<typename Rng>
using ActionPipeConcept = meta::and_<
Invocable<Action&, Rng>,
Range<Rng>,
meta::not_<std::is_reference<Rng>>>;
// Piping requires things are passed by value.
template<typename Rng, typename Act,
CONCEPT_REQUIRES_(ActionPipeConcept<Rng>())>
static auto pipe(Rng && rng, Act && act)
RANGES_DECLTYPE_AUTO_RETURN
(
invoke(act.action_, detail::move(rng))
)
#ifndef RANGES_DOXYGEN_INVOKED
// For better error messages:
template<typename Rng, typename Act,
CONCEPT_REQUIRES_(!ActionPipeConcept<Rng>())>
static void pipe(Rng &&, Act &&)
{
CONCEPT_ASSERT_MSG(Range<Rng>(),
"The type Rng must be a model of the Range concept.");
// BUGBUG This isn't a very helpful message. This is probably the wrong place
// to put this check:
CONCEPT_ASSERT_MSG(Invocable<Action&, Rng>(),
"This action is not callable with this range type.");
static_assert(!std::is_reference<Rng>(),
"You can't pipe an lvalue into an action. Try using std::move on the argument, "
"and be sure to save the result somewhere or pipe the result to another action. "
"Or, wrap the argument with std::ref to pass it by reference.");
}
#endif
public:
action() = default;
action(Action a)
: action_(detail::move(a))
{}
// Calling directly requires things are passed by reference.
template<typename Rng, typename...Rest,
CONCEPT_REQUIRES_(ActionConcept<Rng &, Rest...>())>
auto operator()(Rng & rng, Rest &&... rest) const
RANGES_DECLTYPE_AUTO_RETURN
(
invoke(action_, rng, static_cast<Rest&&>(rest)...)
)
// Currying overload.
template<typename T, typename...Rest, typename A = Action>
auto operator()(T && t, Rest &&... rest) const
RANGES_DECLTYPE_AUTO_RETURN
(
make_action(action_access::impl<A>::bind(action_, static_cast<T&&>(t),
static_cast<Rest&&>(rest)...))
)
};
template<typename Rng, typename Action,
CONCEPT_REQUIRES_(is_pipeable<Action>() && Range<Rng &>() &&
Invocable<bitwise_or, ref_t<Rng &>, Action &>() &&
Same<ref_t<Rng &>,
result_of_t<bitwise_or(ref_t<Rng &> &&, Action &)>>())>
Rng & operator|=(Rng & rng, Action && action)
{
ref(rng) | action;
return rng;
}
}
/// @}
}
}
#endif
|