[range.single.view] (original) (raw)

25 Ranges library [ranges]

25.6 Range factories [range.factories]

25.6.3 Single view [range.single]

25.6.3.2 Class template single_view [range.single.view]

namespace std::ranges { template<move_constructible T> requires is_object_v<T> class single_view : public view_interface<single_view<T>> { private: movable-box<T> value_; public: single_view() requires default_initializable<T> = default;constexpr explicit single_view(const T& t) requires copy_constructible<T>;constexpr explicit single_view(T&& t);template<class... Args> requires constructible_from<T, Args...> constexpr explicit 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 bool empty() noexcept;static constexpr size_t size() noexcept;constexpr T* data() noexcept;constexpr const T* data() const noexcept;};template<class T> single_view(T) -> single_view<T>;}

Effects: Initializes value_ with t.

constexpr explicit single_view(T&& t);

Effects: Initializes value_ with std​::​move(t).

template<class... Args> requires [constructible_from](concept.constructible#concept:constructible%5Ffrom "18.4.11 Concept constructible_­from [concept.constructible]")<T, Args...> constexpr explicit 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 bool empty() noexcept;

Effects: Equivalent to: return false;

static constexpr size_t size() noexcept;

Effects: Equivalent to: return 1;

constexpr T* data() noexcept;constexpr const T* data() const noexcept;

Effects: Equivalent to: return value_.operator->();