/usr/include/range/v3/view_facade.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 | /// \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_FACADE_HPP
#define RANGES_V3_VIEW_FACADE_HPP
#include <utility>
#include <type_traits>
#include <meta/meta.hpp>
#include <range/v3/range_fwd.hpp>
#include <range/v3/range_access.hpp>
#include <range/v3/view_interface.hpp>
#include <range/v3/utility/concepts.hpp>
#include <range/v3/utility/iterator_traits.hpp>
#include <range/v3/utility/basic_iterator.hpp>
namespace ranges
{
inline namespace v3
{
/// \cond
namespace detail
{
template<typename Derived>
using begin_cursor_t =
detail::decay_t<decltype(range_access::begin_cursor(std::declval<Derived &>(), 42))>;
template<typename Derived>
using end_cursor_t =
detail::decay_t<decltype(range_access::end_cursor(std::declval<Derived &>(), 42))>;
template<typename Derived>
using facade_iterator_t = basic_iterator<begin_cursor_t<Derived>>;
template<typename Derived>
using facade_sentinel_t =
meta::if_<
Same<begin_cursor_t<Derived>, end_cursor_t<Derived>>,
facade_iterator_t<Derived>,
end_cursor_t<Derived>>;
}
/// \endcond
/// \addtogroup group-core
/// @{
/// \brief A utility for constructing a view from a (derived) type that
/// implements begin and end cursors.
/// \tparam Derived A type that derives from `view_facade` and implements
/// begin and end cursors. This type is permitted to be incomplete.
/// \tparam Cardinality The cardinality of this view: `finite`, `infinite`,
/// or `unknown`. See `ranges::v3::cardinality`.
template<typename Derived, cardinality Cardinality>
struct view_facade
: view_interface<Derived, Cardinality>
{
protected:
friend range_access;
using view_interface<Derived, Cardinality>::derived;
// Default implementations
Derived begin_cursor() const
{
return derived();
}
constexpr default_sentinel end_cursor() const
{
return {};
}
public:
/// Let `d` be `static_cast<Derived &>(*this)`. Let `b` be
/// `std::as_const(d).begin_cursor()` if that expression is well-formed;
/// otherwise, let `b` be `d.begin_cursor()`. Let `B` be the type of
/// `b`.
/// \return `ranges::v3::basic_iterator<B>(b)`
template<typename D = Derived, CONCEPT_REQUIRES_(Same<D, Derived>())>
detail::facade_iterator_t<D> begin()
{
return {range_access::begin_cursor(derived(), 42)};
}
/// \overload
template<typename D = Derived, CONCEPT_REQUIRES_(Same<D, Derived>())>
detail::facade_iterator_t<D const> begin() const
{
return {range_access::begin_cursor(derived(), 42)};
}
/// Let `d` be `static_cast<Derived &>(*this)`. Let `e` be
/// `std::as_const(d).end_cursor()` if that expression is well-formed;
/// otherwise, let `e` be `d.end_cursor()`. Let `E` be the type of
/// `e`.
/// \return `ranges::v3::basic_iterator<E>(e)` if `E` is the same
/// as `B` computed above for `begin()`; otherwise, return `e`.
template<typename D = Derived, CONCEPT_REQUIRES_(Same<D, Derived>())>
detail::facade_sentinel_t<D> end()
{
return static_cast<detail::facade_sentinel_t<D>>(
range_access::end_cursor(derived(), 42));
}
/// \overload
template<typename D = Derived, CONCEPT_REQUIRES_(Same<D, Derived>())>
detail::facade_sentinel_t<D const> end() const
{
return static_cast<detail::facade_sentinel_t<D const>>(
range_access::end_cursor(derived(), 42));
}
};
/// @}
}
}
#endif
|