22 General utilities library [utilities]

22.5 Optional objects [optional]

22.5.4 Partial specialization of optional for reference types [optional.optional.ref]

22.5.4.5 Iterator support [optional.ref.iterators]

using iterator = implementation-defined; // present only if T is an object type other than an array // of unknown bound
This type models contiguous_iterator ([iterator.concept.contiguous]), meets the Cpp17RandomAccessIterator requirements ([random.access.iterators]), and meets the requirements for constexpr iterators ([iterator.requirements.general]), with value type remove_cv_t<T>.
The reference type is T& for iterator.
All requirements on container iterators ([container.reqmts]) apply to optional​::​iterator.
constexpr auto begin() const noexcept;
Constraints: T is an object type other than an array of unknown bound.
Returns: An object i of type iterator, such that i is an iterator referring to *val if has_value() is true, and a past-the-end iterator value otherwise.
constexpr auto end() const noexcept;
Constraints: T is an object type other than an array of unknown bound.
Returns: begin() + has_value().