24 Ranges library [ranges]

24.6 Range factories [range.factories]

24.6.2 Single view [range.single]

24.6.2.1 Overview [range.single.overview]

single_­view produces a View that contains exactly one element of a specified value.
[Example
:
single_view s{4};
for (int i : s)
  cout << i; // prints 4
end example
]

24.6.2.2 Class template single_­view [range.single.view]

namespace std::ranges {
  template<CopyConstructible T>
    requires is_object_v<T>
  class single_view : public view_interface<single_view<T>> {
  private:
    semiregular<T> value_;      // exposition only
  public:
    single_view() = default;
    constexpr explicit single_view(const T& t);
    constexpr explicit single_view(T&& t);
    template<class... Args>
      requires Constructible<T, Args...>
    constexpr single_view(in_place_t, Args&&... args);

    constexpr T* begin() noexcept;
    constexpr const T* begin() const noexcept;
    constexpr T* end() noexcept;
    constexpr const T* end() const noexcept;
    static constexpr ptrdiff_t size() noexcept;
    constexpr T* data() noexcept;
    constexpr const T* data() const noexcept;
  };
}
constexpr explicit single_view(const T& t);
Effects: Initializes value_­ with t.
constexpr explicit single_view(T&& t);
Effects: Initializes value_­ with std::move(t).
template<class... Args> constexpr single_view(in_place_t, Args&&... args);
Effects: Initializes value_­ as if by value_­{in_­place, std::forward<Args>(args)...}.
constexpr T* begin() noexcept; constexpr const T* begin() const noexcept;
Effects: Equivalent to: return data();
constexpr T* end() noexcept; constexpr const T* end() const noexcept;
Effects: Equivalent to: return data() + 1;
static constexpr ptrdiff_t size() noexcept;
Effects: Equivalent to: return 1;
constexpr T* data() noexcept; constexpr const T* data() const noexcept;
Effects: Equivalent to: return value_­.operator->();

24.6.2.3 view​::​single [range.single.adaptor]

The name view::single denotes a customization point object ([customization.point.object]).
For some subexpression E, the expression view::single(E) is expression-equivalent to single_­view{E}.