23 Ranges library [ranges]

23.8 Range adaptors [range.adaptors]

23.8.5 Transform view [range.transform]

23.8.5.2 Class template transform_­view [range.transform.view]

namespace std::ranges {
  template<InputRange V, CopyConstructible F>
    requires View<V> && is_object_v<F> &&
             RegularInvocable<F&, iter_reference_t<iterator_t<V>>>
  class transform_view : public view_interface<transform_view<V, F>> {
  private:
    template<bool> struct iterator;             // exposition only
    template<bool> struct sentinel;             // exposition only

    V base_ = V();                              // exposition only
    semiregular<F> fun_;                        // exposition only

  public:
    transform_view() = default;
    constexpr transform_view(V base, F fun);
    template<InputRange R>
      requires ViewableRange<R> && Constructible<V, all_view<R>>
    constexpr transform_view(R&& r, F fun);

    constexpr V base() const;

    constexpr iterator<false> begin();
    constexpr iterator<true> begin() const
      requires Range<const V> &&
               RegularInvocable<const F&, iter_reference_t<iterator_t<const V>>>;

    constexpr sentinel<false> end();
    constexpr iterator<false> end() requires CommonRange<V>;
    constexpr sentinel<true> end() const
      requires Range<const V> &&
               RegularInvocable<const F&, iter_reference_t<iterator_t<const V>>>;
    constexpr iterator<true> end() const
      requires CommonRange<const V> &&
               RegularInvocable<const F&, iter_reference_t<iterator_t<const V>>>;

    constexpr auto size() requires SizedRange<V> { return ranges::size(base_); }
    constexpr auto size() const requires SizedRange<const V>
    { return ranges::size(base_); }
  };

  template<class R, class F>
    transform_view(R&&, F) -> transform_view<all_view<R>, F>;
}
constexpr transform_view(V base, F fun);
Effects: Initializes base_­ with std::move(base) and fun_­ with std::move(fun).
template<InputRange R> requires ViewableRange<R> && Constructible<V, all_view<R>> constexpr transform_view(R&& r, F fun);
Effects: Initializes base_­ with view::all(std::forward<R>(r)) and fun_­ with std::move(fun).
constexpr V base() const;
Effects: Equivalent to: return base_­;
constexpr iterator<false> begin();
Effects: Equivalent to:
return iterator<false>{*this, ranges::begin(base_)};
constexpr iterator<true> begin() const requires Range<const V> && RegularInvocable<const F&, iter_reference_t<iterator_t<const V>>>;
Effects: Equivalent to:
return iterator<true>{*this, ranges::begin(base_)};
constexpr sentinel<false> end();
Effects: Equivalent to:
return sentinel<false>{ranges::end(base_)};
constexpr iterator<false> end() requires CommonRange<V>;
Effects: Equivalent to:
return iterator<false>{*this, ranges::end(base_)};
constexpr sentinel<true> end() const requires Range<const V> && RegularInvocable<const F&, iter_reference_t<iterator_t<const V>>>;
Effects: Equivalent to:
return sentinel<true>{ranges::end(base_)};
constexpr iterator<true> end() const requires CommonRange<const V> && RegularInvocable<const F&, iter_reference_t<iterator_t<const V>>>;
Effects: Equivalent to:
return iterator<true>{*this, ranges::end(base_)};