From 3ff31b002a2fbaa3d0169579b0a28b2a833b351e Mon Sep 17 00:00:00 2001 From: Steve Downey Date: Tue, 11 Nov 2025 07:44:14 -0500 Subject: [PATCH] P3913R1 Optimize for std::optional in range adaptors Fixes NB PL 011 (C++26 CD). --- source/ranges.tex | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/ranges.tex b/source/ranges.tex index 2eba8ce3e7..eff1745eb3 100644 --- a/source/ranges.tex +++ b/source/ranges.tex @@ -5898,6 +5898,11 @@ except that the evaluations of \tcode{E} and \tcode{F} are indeterminately sequenced. +\item +Otherwise, if \tcode{T} is a specialization of +\tcode{optional} and \tcode{T} models \libconcept{view}, then +\tcode{(static_cast(F) == D() ? ((void)E, T()) : \exposidnc{decay-copy}(E))}. + \item Otherwise, if \tcode{T} models \libconcept{random_access_range} and \libconcept{sized_range} @@ -6381,6 +6386,11 @@ except that the evaluations of \tcode{E} and \tcode{F} are indeterminately sequenced. +\item +Otherwise, if \tcode{T} is a specialization of \tcode{optional} +and \tcode{T} models \libconcept{view}, then +\tcode{(static_cast(F) == D() ? \exposidnc{decay-copy}(E) : ((void)E, T()))}. + \item Otherwise, if \tcode{T} models \libconcept{random_access_range} and \libconcept{sized_range} @@ -9910,6 +9920,11 @@ If the type of \tcode{E} is a (possibly cv-qualified) specialization of \tcode{reverse_view}, then \tcode{E.base()}. + +\item + Otherwise, if \tcode{E} is specialization of \tcode{optional} and \tcode{E} + models \libconcept{view}, then \tcode{\exposidnc{decay-copy}(E)}. + \item Otherwise, if the type of \tcode{E} is \cv{} \tcode{subrange, reverse_iterator, K>} for some iterator type \tcode{I} and @@ -10061,6 +10076,11 @@ Otherwise, if \tcode{U} denotes \tcode{empty_view} for some type \tcode{X}, then \tcode{auto(views::empty)}. + +\item +Otherwise, if \tcode{U} denotes \tcode{optional} +for some type \tcode{X}, then \tcode{optional(E)}. + \item Otherwise, if \tcode{U} denotes \tcode{span}