Skip to content

Commit eb4a802

Browse files
committed
LWG4308 std::optional<T&>::iterator can't be a contiguous iterator for some T
1 parent 4c34e8c commit eb4a802

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

source/utilities.tex

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4469,8 +4469,9 @@
44694469
template<class T>
44704470
class optional<T&> {
44714471
public:
4472-
using value_type = T;
4473-
using iterator = @\impdefnc@; // see~\ref{optional.ref.iterators}
4472+
using value_type = T;
4473+
using iterator = @\impdefnc@; // present only if \tcode{T} is an object type other than an array
4474+
// of unknown bound; see~\ref{optional.ref.iterators}
44744475

44754476
public:
44764477
// \ref{optional.ref.ctor}, constructors
@@ -4503,8 +4504,8 @@
45034504
constexpr void swap(optional& rhs) noexcept;
45044505

45054506
// \ref{optional.ref.iterators}, iterator support
4506-
constexpr iterator begin() const noexcept;
4507-
constexpr iterator end() const noexcept;
4507+
constexpr auto begin() const noexcept;
4508+
constexpr auto end() const noexcept;
45084509

45094510
// \ref{optional.ref.observe}, observers
45104511
constexpr T* operator->() const noexcept;
@@ -4778,7 +4779,8 @@
47784779
\rSec3[optional.ref.iterators]{Iterator support}
47794780

47804781
\begin{itemdecl}
4781-
using iterator = @\impdef@;
4782+
using iterator = @\impdefnc@; // present only if \tcode{T} is an object type other than an array
4783+
// of unknown bound
47824784
\end{itemdecl}
47834785

47844786
\begin{itemdescr}
@@ -4796,22 +4798,31 @@
47964798
\end{itemdescr}
47974799

47984800
\begin{itemdecl}
4799-
constexpr iterator begin() const noexcept;
4801+
constexpr auto begin() const noexcept;
48004802
\end{itemdecl}
48014803

48024804
\begin{itemdescr}
4805+
\pnum
4806+
\constraints
4807+
\tcode{T} is an object type other than an array of unknown bound.
4808+
48034809
\pnum
48044810
\returns
4805-
If \tcode{has_value()} is \tcode{true},
4806-
an iterator referring to \tcode{*\exposid{val}}.
4807-
Otherwise, a past-the-end iterator value.
4811+
An object \tcode{i} of type \tcode{iterator}, such that
4812+
\tcode{i} is an iterator referring to \tcode{*\exposid{val}}
4813+
if \tcode{has_value()} is \tcode{true}, and
4814+
a past-the-end iterator value otherwise.
48084815
\end{itemdescr}
48094816

48104817
\begin{itemdecl}
4811-
constexpr iterator end() const noexcept;
4818+
constexpr auto end() const noexcept;
48124819
\end{itemdecl}
48134820

48144821
\begin{itemdescr}
4822+
\pnum
4823+
\constraints
4824+
\tcode{T} is an object type other than an array of unknown bound.
4825+
48154826
\pnum
48164827
\returns
48174828
\tcode{begin() + has_value()}.

0 commit comments

Comments
 (0)