Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::views::to_input,std::ranges::to_input_view

      From cppreference.com
      <cpp‎ |ranges
       
       
      Ranges library
      Range adaptors
       
       
      Defined in header<ranges>
      template<ranges::input_range V>

          requiresranges::view<V>
      class to_input_view

         :publicranges::view_interface<to_input_view<V>>
      (1)(since C++26)
      namespace views{

         inlineconstexpr/* unspecified */ to_input=/* unspecified */;

      }
      (2)(since C++26)
      Call signature
      template<ranges::viewable_range R>

          requires/* see below */

      constexprranges::viewauto to_input( R&& r);
      (since C++26)
      1) A range adaptor that represents a view of an underlyingview as aninput_range-only and not acommon_range.
      2)RangeAdaptorObject. Lete be a subexpression, and letT bedecltype(e). Then the expressionviews::to_input(e) isexpression-equivalent to:

      Consequently,to_input_view never models range concepts that are stronger thaninput_range. In particular, it does not model all of these:

      Additionally,to_input_view does not modelcommon_range. However, it does modelborrowed_range,constant_range, andsized_range when the underlying viewV models respective concepts.

      Contents

      [edit]Data members

      Member Description
      Vbase_(private) the underlying view
      (exposition-only member object*)

      [edit]Member functions

      constructs ato_input_view
      (public member function)
      returns a copy of the underlying (adapted) view
      (public member function)
      returns an iterator to the beginning
      (public member function)
      returns an iterator or a sentinel to the end
      (public member function)
      returns the number of elements. Provided only if the underlying (adapted) range satisfiessized_range.
      (public member function)
      Inherited fromstd::ranges::view_interface
      returns whether the derived view is empty, provided only if it satisfiessized_range orforward_range
      (public member function ofstd::ranges::view_interface<D>)[edit]
      (C++23)
      returns a constant iterator to the beginning of the range
      (public member function ofstd::ranges::view_interface<D>)[edit]
      (C++23)
      returns a sentinel for the constant iterator of the range
      (public member function ofstd::ranges::view_interface<D>)[edit]
      returns whether the derived view is not empty, provided only ifranges::empty is applicable to it
      (public member function ofstd::ranges::view_interface<D>)[edit]
      gets the address of derived view's data, provided only if its iterator type satisfiescontiguous_iterator
      (public member function ofstd::ranges::view_interface<D>)[edit]
      returns the first element in the derived view, provided if it satisfiesforward_range
      (public member function ofstd::ranges::view_interface<D>)[edit]
      returns the last element in the derived view, provided only if it satisfiesbidirectional_range andcommon_range
      (public member function ofstd::ranges::view_interface<D>)[edit]
      returns thenth element in the derived view, provided only if it satisfiesrandom_access_range
      (public member function ofstd::ranges::view_interface<D>)[edit]

      std::ranges::to_input_view::to_input_view

      to_input_view() requiresstd::default_initializable<V>=default;
      (1)(since C++26)
      constexprexplicit to_input_view( V base);
      (2)(since C++26)
      1) Value-initializesbase_ via its default member initializer (= V()).
      2) Initializesbase_ withstd::move(base).

      Parameters

      base - a view

      std::ranges::to_input_view::base

      constexpr V base()const& requiresstd::copy_constructible<V>;
      (1)(since C++26)
      constexpr V base()&&;
      (2)(since C++26)
      1) Copy-constructs the result from the underlying view. Equivalent toreturn base_;.
      2) Move-constructs the result from the underlying view. Equivalent toreturn std::move(base_);.

      std::ranges::to_input_view::begin

      constexprauto begin() requires(!__simple_view<V>);
      (1)(since C++26)
      constexprauto begin()const requiresranges::range<const V>;
      (2)(since C++26)
      1) Equivalent toreturn/*iterator*/<false>(ranges::begin(base_));
      2) Equivalent toreturn/*iterator*/<true>(ranges::begin(base_));

      std::ranges::to_input_view::end

      constexprauto end() requires(!__simple_view<V>);
      (1)(since C++26)
      constexprauto end()const requiresranges::range<const V>;
      (2)(since C++26)
      1,2) Equivalent toreturnranges::end(base_);

      std::ranges::to_input_view::size

      constexprauto size() requiresranges::sized_range<V>;
      (1)(since C++26)
      constexprauto size()const requiresranges::sized_range<const V>;
      (2)(since C++26)
      1,2) Equivalent toreturnranges::size(base_);

      [edit]Deduction guides

      template<class R>
      to_input_view( R&&)-> to_input_view<views::all_t<R>>;
      (since C++26)

      [edit]Nested classes

      the iterator type
      (exposition-only member class template*)

      [edit]Helper templates

      template<class T>

      constexprbool enable_borrowed_range<std::ranges::to_input_view<T>>=

         ranges::enable_borrowed_range<T>;
      (since C++26)

      This specialization ofstd::ranges::enable_borrowed_range makesto_input_view satisfyborrowed_range when the underlying view satisfies it.

      [edit]Notes

      to_input_view can be useful to avoid the overhead necessary to provide support for the operations needed for greater iterator strength.

      Feature-test macroValueStdFeature
      __cpp_lib_ranges_to_input202502L(C++26)std::ranges::to_input_view

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      specifies a range whose iterator type satisfiesinput_iterator
      (concept)[edit]
      converts aview into acommon_range
      (class template)(range adaptor object)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/to_input_view&oldid=181207"

      [8]ページ先頭

      ©2009-2025 Movatter.jp