/usr/include/range/v3/istream_range.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 | /// \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_ISTREAM_RANGE_HPP
#define RANGES_V3_ISTREAM_RANGE_HPP
#include <istream>
#include <range/v3/range_fwd.hpp>
#include <range/v3/view_facade.hpp>
#include <range/v3/utility/semiregular.hpp>
#include <range/v3/utility/static_const.hpp>
namespace ranges
{
inline namespace v3
{
/// \addtogroup group-core
/// @{
template<typename Val>
struct istream_range
: view_facade<istream_range<Val>, unknown>
{
private:
friend range_access;
std::istream *sin_;
movesemiregular_t<Val> obj_;
struct cursor
{
private:
istream_range *rng_;
public:
cursor() = default;
explicit cursor(istream_range &rng)
: rng_(&rng)
{}
void next()
{
rng_->next();
}
Val &read() const noexcept
{
return rng_->cached();
}
bool equal(default_sentinel) const
{
return !*rng_->sin_;
}
};
void next()
{
*sin_ >> cached();
}
cursor begin_cursor()
{
return cursor{*this};
}
public:
istream_range() = default;
istream_range(std::istream &sin)
: sin_(&sin), obj_{}
{
next(); // prime the pump
}
Val & cached() noexcept
{
return obj_;
}
};
#if !RANGES_CXX_VARIABLE_TEMPLATES
template<typename Val>
istream_range<Val> istream(std::istream & sin)
{
CONCEPT_ASSERT_MSG(DefaultConstructible<Val>(),
"Only DefaultConstructible types are extractable from streams.");
return {sin};
}
#else
template<typename Val, CONCEPT_REQUIRES_(DefaultConstructible<Val>())>
struct istream_fn
{
istream_range<Val> operator()(std::istream & sin) const
{
return {sin};
}
};
#if RANGES_CXX_INLINE_VARIABLES < RANGES_CXX_INLINE_VARIABLES_17
inline namespace
{
template<typename Val>
constexpr auto& istream = static_const<istream_fn<Val>>::value;
}
#else // RANGES_CXX_INLINE_VARIABLES >= RANGES_CXX_INLINE_VARIABLES_17
inline namespace function_objects
{
template<typename Val>
inline constexpr istream_fn<Val> istream{};
}
#endif // RANGES_CXX_INLINE_VARIABLES
#endif // RANGES_CXX_VARIABLE_TEMPLATES
/// @}
}
}
#endif
|