/usr/include/range/v3/view/view.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 | /// \file
// Range v3 library
//
// Copyright Eric Niebler 2014-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_VIEW_VIEW_HPP
#define RANGES_V3_VIEW_VIEW_HPP
#include <utility>
#include <type_traits>
#include <meta/meta.hpp>
#include <range/v3/range_fwd.hpp>
#include <range/v3/range_concepts.hpp>
#include <range/v3/range_traits.hpp>
#include <range/v3/utility/functional.hpp>
#include <range/v3/utility/static_const.hpp>
namespace ranges
{
inline namespace v3
{
/// \cond
namespace detail
{
struct null_pipe
{
template<typename Rng>
void operator()(Rng &&) const
{}
};
}
/// \endcond
namespace view
{
/// \addtogroup group-views
/// @{
struct view_access
{
template<typename View>
struct impl
{
template<typename...Ts, typename V = View>
static auto bind(Ts &&...ts)
RANGES_DECLTYPE_AUTO_RETURN
(
V::bind(static_cast<Ts&&>(ts)...)
)
};
};
struct make_view_fn
{
template<typename Fun>
view<Fun> operator()(Fun fun) const
{
return {std::move(fun)};
}
};
/// \ingroup group-views
/// \sa make_view_fn
RANGES_INLINE_VARIABLE(make_view_fn, make_view)
template<typename Rng>
using ViewableRange = meta::and_<
Range<Rng>,
meta::or_<std::is_lvalue_reference<Rng>, View<uncvref_t<Rng>>>>;
template<typename View>
struct view : pipeable<view<View>>
{
private:
View view_;
friend pipeable_access;
template<typename Rng, typename ...Rest>
using ViewConcept = meta::and_<ViewableRange<Rng>, Invocable<View&, Rng, Rest...>>;
// Piping requires range arguments or lvalue containers.
template<typename Rng, typename Vw,
CONCEPT_REQUIRES_(ViewConcept<Rng>())>
static auto pipe(Rng && rng, Vw && v)
RANGES_DECLTYPE_AUTO_RETURN
(
v.view_(static_cast<Rng&&>(rng))
)
#ifndef RANGES_DOXYGEN_INVOKED
// For better error messages:
template<typename Rng, typename Vw,
CONCEPT_REQUIRES_(!ViewConcept<Rng>())>
static void pipe(Rng &&, Vw &&)
{
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<View&, Rng>(),
"This view is not callable with this range type.");
static_assert(ranges::View<Rng>() || std::is_lvalue_reference<Rng>(),
"You can't pipe an rvalue container into a view. First, save the container into "
"a named variable, and then pipe it to the view.");
}
#endif
public:
view() = default;
view(View a)
: view_(std::move(a))
{}
// Calling directly requires View arguments or lvalue containers.
template<typename Rng, typename...Rest,
CONCEPT_REQUIRES_(ViewConcept<Rng, Rest...>())>
auto operator()(Rng && rng, Rest &&... rest) const
RANGES_DECLTYPE_AUTO_RETURN
(
view_(static_cast<Rng&&>(rng), static_cast<Rest&&>(rest)...)
)
// Currying overload.
template<typename...Ts, typename V = View>
auto operator()(Ts &&... ts) const
RANGES_DECLTYPE_AUTO_RETURN
(
make_view(view_access::impl<V>::bind(view_,
static_cast<Ts&&>(ts)...))
)
};
/// \endcond
}
}
}
#endif
|