Skip to content

Commit e3860c9

Browse files
jensmaurertkoeppe
authored andcommitted
P2281R1 Clarifying range adaptor objects
Also fixes LWG3509 and LWG3510.
1 parent cfc0da3 commit e3860c9

File tree

2 files changed

+62
-22
lines changed

2 files changed

+62
-22
lines changed

source/lib-intro.tex

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,15 +771,34 @@
771771
\pnum
772772
All instances of a specific customization point object type shall
773773
be equal\iref{concepts.equality}.
774+
The effects of invoking different instances
775+
of a specific customization point object type on the same arguments
776+
are equivalent.
774777

775778
\pnum
776-
The type \tcode{T} of a customization point object shall model
777-
\tcode{\libconcept{invocable}<const T\&, Args...>}\iref{concept.invocable}
779+
The type \tcode{T} of a customization point object,
780+
ignoring \grammarterm{cv-qualifier}s, shall model
781+
\tcode{\libconcept{invocable}<T\&, Args...>},
782+
\tcode{\libconcept{invocable}<const T\&, Args...>},
783+
\tcode{\libconcept{invocable}<T, Args...>}, and
784+
\tcode{\libconcept{invocable}<const T, Args...>}\iref{concept.invocable}
778785
when the types in \tcode{Args...} meet the requirements specified in that
779786
customization point object's definition. When the types of \tcode{Args...} do
780787
not meet the customization point object's requirements, \tcode{T} shall not have
781788
a function call operator that participates in overload resolution.
782789

790+
\pnum
791+
For a given customization point object \tcode{o},
792+
let \tcode{p} be a variable initialized as if by \tcode{auto p = o;}.
793+
Then for any sequence of arguments \tcode{args...},
794+
the following expressions have effects equivalent to \tcode{o(args...)}:
795+
\begin{itemize}
796+
\item \tcode{p(args...)}
797+
\item \tcode{as_const(p)(args...)}
798+
\item \tcode{std::move(p)(args...)}
799+
\item \tcode{std::move(as_const(p))(args...)}
800+
\end{itemize}
801+
783802
\pnum
784803
Each customization point object type constrains its return type to model a
785804
particular concept.

source/ranges.tex

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,20 +3055,30 @@
30553055
a range adaptor closure object \tcode{C} and an expression \tcode{R} such that
30563056
\tcode{decltype((R))} models \libconcept{viewable_range}, the following
30573057
expressions are equivalent and yield a \libconcept{view}:
3058-
30593058
\begin{codeblock}
30603059
C(R)
30613060
R | C
30623061
\end{codeblock}
3063-
30643062
Given an additional range adaptor closure object \tcode{D},
3065-
the expression \tcode{C | D} is well-formed and produces another range adaptor
3066-
closure object such that the following two expressions are equivalent:
3067-
3068-
\begin{codeblock}
3069-
R | C | D
3070-
R | (C | D)
3071-
\end{codeblock}
3063+
the expression \tcode{C | D} produces another range adaptor
3064+
closure object \tcode{E}.
3065+
\tcode{E} is a perfect forwarding call wrapper\iref{func.require}
3066+
with the following properties:
3067+
\begin{itemize}
3068+
\item
3069+
Its target object is an object \tcode{d} of type \tcode{decay_t<decltype((D))>}
3070+
direct-non-list-initialized with \tcode{D}.
3071+
\item
3072+
It has one bound argument entity,
3073+
an object \tcode{c} of type \tcode{decay_t<decltype((C))>}
3074+
direct-non-list-initialized with \tcode{C}.
3075+
\item
3076+
Its call pattern is \tcode{d(c(arg))},
3077+
where \tcode{arg} is the argument used in
3078+
a function call expression of \tcode{E}.
3079+
\end{itemize}
3080+
The expression \tcode{C | D} is well-formed if and only if
3081+
the initializations of the state entities of \tcode{E} are all well-formed.
30723082

30733083
\pnum
30743084
A \term{range adaptor object} is a
@@ -3081,17 +3091,28 @@
30813091
then it is a range adaptor closure object.
30823092

30833093
\pnum
3084-
If a range adaptor object accepts more than one argument,
3085-
then the following expressions are equivalent:
3086-
3087-
\begin{codeblock}
3088-
@\placeholdernc{adaptor}@(range, args...)
3089-
@\placeholdernc{adaptor}@(args...)(range)
3090-
range | @\placeholdernc{adaptor}@(args...)
3091-
\end{codeblock}
3092-
3093-
In this case, \tcode{\placeholdernc{adaptor}(args...)} is a range adaptor
3094-
closure object.
3094+
If a range adaptor object \tcode{adaptor} accepts more than one argument,
3095+
then let \tcode{range} be an expression
3096+
such that \tcode{decltype((range))} models \libconcept{viewable_range},
3097+
let \tcode{args...} be arguments
3098+
such that \tcode{adaptor(range, args...)} is a well-formed expression
3099+
as specified in the rest of subclause\iref{range.adaptors}, and
3100+
let \tcode{BoundArgs} be a pack
3101+
that denotes \tcode{decay_t<decltype((args))>...}.
3102+
The expression \tcode{adaptor(args...)} produces a range adaptor closure object \tcode{f}
3103+
that is a perfect forwarding call wrapper with the following properties:
3104+
\begin{itemize}
3105+
\item
3106+
Its target object is a copy of \tcode{adaptor}.
3107+
\item
3108+
Its bound argument entities \tcode{bound_args} consist of objects of types \tcode{BoundArgs...} direct-non-list-initialized with \tcode{std::forward<decltype((args))>(args)...}, respectively.
3109+
\item
3110+
Its call pattern is \tcode{adaptor(r, bound_args...)},
3111+
where \tcode{r} is the argument used in a function call expression of \tcode{f}.
3112+
\end{itemize}
3113+
The expression \tcode{adaptor(args...)} is well-formed if and only if
3114+
the initialization of the bound argument entities of the result,
3115+
as specified above, are all well-formed.
30953116

30963117
\rSec2[range.semi.wrap]{Semiregular wrapper}
30973118

0 commit comments

Comments
 (0)