/// \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_CONST_HPP #define RANGES_V3_VIEW_CONST_HPP #include #include #include #include #include #include #include #include #include #include #include #include namespace ranges { /// \addtogroup group-views /// @{ template struct const_view : view_adaptor, Rng> { private: friend range_access; template struct adaptor : adaptor_base { using CRng = meta::const_if_c; using value_ = range_value_t; using reference_ = common_reference_t>; using rvalue_reference_ = common_reference_t>; adaptor() = default; CPP_template(bool Other)( // requires Const && (!Other)) constexpr adaptor(adaptor) {} reference_ read(iterator_t const & it) const { return *it; } rvalue_reference_ iter_move(iterator_t const & it) const noexcept(noexcept(rvalue_reference_(ranges::iter_move(it)))) { return ranges::iter_move(it); } }; adaptor()> begin_adaptor() { return {}; } CPP_member auto begin_adaptor() const -> CPP_ret(adaptor)( // requires range) { return {}; } adaptor()> end_adaptor() { return {}; } CPP_member auto end_adaptor() const -> CPP_ret(adaptor)( // requires range) { return {}; } public: const_view() = default; explicit const_view(Rng rng) : const_view::view_adaptor{std::move(rng)} {} CPP_member constexpr auto CPP_fun(size)()(requires sized_range) { return ranges::size(this->base()); } CPP_member constexpr auto CPP_fun(size)()(const requires sized_range) { return ranges::size(this->base()); } }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 template const_view(Rng &&)->const_view>; #endif namespace views { struct const_fn { template auto operator()(Rng && rng) const -> CPP_ret(const_view>)( // requires viewable_range && input_range) { return const_view>{all(static_cast(rng))}; } }; /// \relates const_fn /// \ingroup group-views RANGES_INLINE_VARIABLE(view, const_) } // namespace views /// @} } // namespace ranges #include RANGES_SATISFY_BOOST_RANGE(::ranges::const_view) #endif