/usr/include/range/v3/view/map.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 147 148 149 150 151 152 | /// \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_VIEW_MAP_HPP
#define RANGES_V3_VIEW_MAP_HPP
#include <utility>
#include <meta/meta.hpp>
#include <range/v3/range_fwd.hpp>
#include <range/v3/utility/concepts.hpp>
#include <range/v3/utility/functional.hpp>
#include <range/v3/utility/static_const.hpp>
#include <range/v3/view/view.hpp>
#include <range/v3/view/transform.hpp>
namespace ranges
{
inline namespace v3
{
/// \cond
namespace detail
{
template<typename T>
RANGES_CXX14_CONSTEXPR T&
get_first_second_helper(T& t, std::true_type) noexcept
{
return t;
}
template<typename T,
CONCEPT_REQUIRES_(MoveConstructible<T>())>
RANGES_CXX14_CONSTEXPR T
get_first_second_helper(T& t, std::false_type)
noexcept(std::is_nothrow_move_constructible<T>::value)
{
return std::move(t);
}
template<typename P, typename E>
using get_first_second_tag = meta::bool_<
std::is_lvalue_reference<P>::value ||
std::is_lvalue_reference<E>::value>;
struct get_first
{
template<typename Pair>
RANGES_CXX14_CONSTEXPR auto operator()(Pair && p) const
RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
(
get_first_second_helper(p.first,
get_first_second_tag<Pair, decltype(p.first)>{})
)
};
struct get_second
{
template<typename Pair>
RANGES_CXX14_CONSTEXPR auto operator()(Pair && p) const
RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
(
get_first_second_helper(p.second,
get_first_second_tag<Pair, decltype(p.second)>{})
)
};
template<typename T>
using PairLike = meta::and_<
Invocable<get_first const&, T>, Invocable<get_second const&, T>>;
}
/// \endcond
/// \addtogroup group-views
/// @{
namespace view
{
struct keys_fn
{
template<typename Rng>
using Concept = meta::and_<
InputRange<Rng>,
detail::PairLike<range_reference_t<Rng>>>;
template<typename Rng,
CONCEPT_REQUIRES_(Concept<Rng>())>
keys_range_view<all_t<Rng>> operator()(Rng && rng) const
{
return {all(static_cast<Rng&&>(rng)), detail::get_first{}};
}
#ifndef RANGES_DOXYGEN_INVOKED
template<typename Rng,
CONCEPT_REQUIRES_(!Concept<Rng>())>
void operator()(Rng &&) const
{
CONCEPT_ASSERT_MSG(InputRange<Rng>(),
"The argument of view::keys must be a model of the InputRange concept.");
CONCEPT_ASSERT_MSG(detail::PairLike<range_reference_t<Rng>>(),
"The value type of the range passed to view::keys must look like a std::pair; "
"That is, it must have first and second data members.");
}
#endif
};
struct values_fn
{
template<typename Rng>
using Concept = meta::and_<
InputRange<Rng>,
detail::PairLike<range_reference_t<Rng>>>;
template<typename Rng,
CONCEPT_REQUIRES_(Concept<Rng>())>
values_view<all_t<Rng>> operator()(Rng && rng) const
{
return {all(static_cast<Rng&&>(rng)), detail::get_second{}};
}
#ifndef RANGES_DOXYGEN_INVOKED
template<typename Rng,
CONCEPT_REQUIRES_(!Concept<Rng>())>
void operator()(Rng &&) const
{
CONCEPT_ASSERT_MSG(InputRange<Rng>(),
"The argument of view::values must be a model of the InputRange concept.");
CONCEPT_ASSERT_MSG(detail::PairLike<range_reference_t<Rng>>(),
"The value type of the range passed to view::values must look like a std::pair; "
"That is, it must have first and second data members.");
}
#endif
};
/// \relates keys_fn
/// \ingroup group-views
RANGES_INLINE_VARIABLE(view<keys_fn>, keys)
/// \relates values_fn
/// \ingroup group-views
RANGES_INLINE_VARIABLE(view<values_fn>, values)
}
/// @}
}
}
#endif
|