} \\
34 | \end{libsumtab}
35 |
--------------------------------------------------------------------------------
/Coroutines/macros.tex:
--------------------------------------------------------------------------------
1 | %!TEX root = std.tex
2 | % Definitions and redefinitions of special commands
3 |
4 | %%--------------------------------------------------
5 | %% Difference markups
6 | \definecolor{addclr}{rgb}{0,.6,.6}
7 | \definecolor{remclr}{rgb}{1,0,0}
8 | \definecolor{noteclr}{rgb}{0,0,1}
9 |
10 | \renewcommand{\added}[1]{\textcolor{addclr}{\uline{#1}}}
11 | \newcommand{\removed}[1]{\textcolor{remclr}{\sout{#1}}}
12 | \renewcommand{\changed}[2]{\removed{#1}\added{#2}}
13 |
14 | \newcommand{\nbc}[1]{[#1]\ }
15 | \newcommand{\addednb}[2]{\added{\nbc{#1}#2}}
16 | \newcommand{\removednb}[2]{\removed{\nbc{#1}#2}}
17 | \newcommand{\changednb}[3]{\removednb{#1}{#2}\added{#3}}
18 | \newcommand{\remitem}[1]{\item\removed{#1}}
19 |
20 | \newcommand{\ednote}[1]{\textcolor{noteclr}{[Editor's note: #1] }}
21 | % \newcommand{\ednote}[1]{}
22 |
23 | \newenvironment{addedblock}
24 | {
25 | \color{addclr}
26 | }
27 | {
28 | \color{black}
29 | }
30 | \newenvironment{removedblock}
31 | {
32 | \color{remclr}
33 | }
34 | {
35 | \color{black}
36 | }
37 |
38 | %%--------------------------------------------------
39 | %% Sectioning macros.
40 | % Each section has a depth, an automatically generated section
41 | % number, a name, and a short tag. The depth is an integer in
42 | % the range [0,5]. (If it proves necessary, it wouldn't take much
43 | % programming to raise the limit from 5 to something larger.)
44 |
45 |
46 | % The basic sectioning command. Example:
47 | % \Sec1[intro.scope]{Scope}
48 | % defines a first-level section whose name is "Scope" and whose short
49 | % tag is intro.scope. The square brackets are mandatory.
50 | \def\Sec#1[#2]#3{%
51 | \ifcase#1\let\s=\chapter
52 | \or\let\s=\section
53 | \or\let\s=\subsection
54 | \or\let\s=\subsubsection
55 | \or\let\s=\paragraph
56 | \or\let\s=\subparagraph
57 | \fi%
58 | \s[#3]{#3\hfill[#2]}\label{#2}}
59 |
60 | % A convenience feature (mostly for the convenience of the Project
61 | % Editor, to make it easy to move around large blocks of text):
62 | % the \rSec macro is just like the \Sec macro, except that depths
63 | % relative to a global variable, SectionDepthBase. So, for example,
64 | % if SectionDepthBase is 1,
65 | % \rSec1[temp.arg.type]{Template type arguments}
66 | % is equivalent to
67 | % \Sec2[temp.arg.type]{Template type arguments}
68 | \newcounter{SectionDepthBase}
69 | \newcounter{scratch}
70 |
71 | \def\rSec#1[#2]#3{%
72 | \setcounter{scratch}{#1}
73 | \addtocounter{scratch}{\value{SectionDepthBase}}
74 | \Sec{\arabic{scratch}}[#2]{#3}}
75 |
76 | \newcommand{\synopsis}[1]{\textbf{#1}}
77 |
78 | %%--------------------------------------------------
79 | % Indexing
80 |
81 | % locations
82 | \newcommand{\indextext}[1]{\index[generalindex]{#1}}
83 | \newcommand{\indexlibrary}[1]{\index[libraryindex]{#1}}
84 | \newcommand{\indexgram}[1]{\index[grammarindex]{#1}}
85 | \newcommand{\indeximpldef}[1]{\index[impldefindex]{#1}}
86 |
87 | \newcommand{\indexdefn}[1]{\indextext{#1}}
88 | \newcommand{\indexgrammar}[1]{\indextext{#1}\indexgram{#1}}
89 | \newcommand{\impldef}[1]{\indeximpldef{#1}implementation-defined}
90 |
91 | % appearance
92 | \newcommand{\idxcode}[1]{#1@\tcode{#1}}
93 | \newcommand{\idxhdr}[1]{#1@\tcode{<#1>}}
94 | \newcommand{\idxgram}[1]{#1@\textit{#1}}
95 |
96 | %%--------------------------------------------------
97 | % General code style
98 | \newcommand{\CodeStyle}{\ttfamily}
99 | \newcommand{\CodeStylex}[1]{\texttt{#1}}
100 |
101 | % Code and definitions embedded in text.
102 | \newcommand{\tcode}[1]{\CodeStylex{#1}}
103 | \newcommand{\techterm}[1]{\textit{#1}\xspace}
104 | \newcommand{\defnx}[2]{\indexdefn{#2}\textit{#1}\xspace}
105 | \newcommand{\defn}[1]{\defnx{#1}{#1}}
106 | \newcommand{\term}[1]{\textit{#1}\xspace}
107 | \newcommand{\grammarterm}[1]{\textit{#1}\xspace}
108 | \newcommand{\placeholder}[1]{\textit{#1}\xspace}
109 |
110 | %%--------------------------------------------------
111 | %% allow line break if needed for justification
112 | \newcommand{\brk}{\discretionary{}{}{}}
113 | % especially for scope qualifier
114 | \newcommand{\colcol}{\brk::\brk}
115 |
116 | %%--------------------------------------------------
117 | %% Macros for funky text
118 | \newcommand{\Rplus}{\protect\hspace{-.1em}\protect\raisebox{.35ex}{\smaller{\smaller\textbf{+}}}}
119 | % \newcommand{\Rplus}{+}
120 | \newcommand{\Cpp}{\mbox{C\Rplus\Rplus}\xspace}
121 | \newcommand{\CppIII}{\Cpp 2003\xspace}
122 | \newcommand{\CppXI}{\Cpp 2011\xspace}
123 | \newcommand{\opt}{{\ensuremath{_\mathit{opt}}}\xspace}
124 | \newcommand{\shl}{<{<}}
125 | \newcommand{\shr}{>{>}}
126 | \newcommand{\dcr}{-{-}}
127 | \newcommand{\exor}{\^{}}
128 | \newcommand{\bigoh}[1]{\ensuremath{\mathscr{O}(#1)}}
129 | \newcommand{\cvvoid}{\textit{cv}{ }\tcode{void}}
130 | \newcommand{\awready}{\textit{e}\tcode{await_ready()}}
131 | \newcommand{\awsuspend}{\textit{e}\tcode{await_resume(\textit{h})}}
132 | \newcommand{\awresume}{\textit{e}{ }\tcode{await_resume()}}
133 |
134 | % Make all tildes a little larger to avoid visual similarity with hyphens.
135 | % FIXME: Remove \tilde in favour of \~.
136 | \renewcommand{\tilde}{\textasciitilde}
137 | \renewcommand{\~}{\textasciitilde}
138 | \let\OldTextAsciiTilde\textasciitilde
139 | \renewcommand{\textasciitilde}{\protect\raisebox{-0.17ex}{\larger\OldTextAsciiTilde}}
140 |
141 | %%--------------------------------------------------
142 | %% States and operators
143 | \newcommand{\state}[2]{\tcode{#1}\ensuremath{_{#2}}}
144 | \newcommand{\bitand}{\ensuremath{\, \mathsf{bitand} \,}}
145 | \newcommand{\bitor}{\ensuremath{\, \mathsf{bitor} \,}}
146 | \newcommand{\xor}{\ensuremath{\, \mathsf{xor} \,}}
147 | \newcommand{\rightshift}{\ensuremath{\, \mathsf{rshift} \,}}
148 | \newcommand{\leftshift}[1]{\ensuremath{\, \mathsf{lshift}_#1 \,}}
149 |
150 | %% Notes and examples
151 | \newcommand{\EnterBlock}[1]{[\,\textit{#1:}\xspace}
152 | \newcommand{\ExitBlock}[1]{\textit{\,---\,end #1}\,]\xspace}
153 | \newcommand{\enternote}{\EnterBlock{Note}}
154 | \newcommand{\exitnote}{\ExitBlock{note}}
155 | \newcommand{\enterexample}{\EnterBlock{Example}}
156 | \newcommand{\exitexample}{\ExitBlock{example}}
157 |
158 | %% Library function descriptions
159 | \newcommand{\Fundescx}[1]{\textit{#1}\xspace}
160 | \newcommand{\Fundesc}[1]{\Fundescx{#1:}}
161 | \newcommand{\required}{\Fundesc{Required behavior}}
162 | \newcommand{\requires}{\Fundesc{Requires}}
163 | \newcommand{\effects}{\Fundesc{Effects}}
164 | \newcommand{\postconditions}{\Fundesc{Postconditions}}
165 | \newcommand{\postcondition}{\Fundesc{Postcondition}}
166 | \newcommand{\preconditions}{\requires}
167 | \newcommand{\precondition}{\requires}
168 | \newcommand{\returns}{\Fundesc{Returns}}
169 | \newcommand{\throws}{\Fundesc{Throws}}
170 | \newcommand{\default}{\Fundesc{Default behavior}}
171 | \newcommand{\complexity}{\Fundesc{Complexity}}
172 | \newcommand{\remark}{\Fundesc{Remark}}
173 | \newcommand{\remarks}{\Fundesc{Remarks}}
174 | \newcommand{\note}{\remark}
175 | \newcommand{\notes}{\remarks}
176 | \newcommand{\realnote}{\Fundesc{Note}}
177 | \newcommand{\realnotes}{\Fundesc{Notes}}
178 | \newcommand{\errors}{\Fundesc{Error conditions}}
179 | \newcommand{\sync}{\Fundesc{Synchronization}}
180 | \newcommand{\implimits}{\Fundesc{Implementation limits}}
181 | \newcommand{\replaceable}{\Fundesc{Replaceable}}
182 | \newcommand{\exceptionsafety}{\Fundesc{Exception safety}}
183 | \newcommand{\returntype}{\Fundesc{Return type}}
184 | \newcommand{\cvalue}{\Fundesc{Value}}
185 | \newcommand{\ctype}{\Fundesc{Type}}
186 | \newcommand{\ctypes}{\Fundesc{Types}}
187 | \newcommand{\dtype}{\Fundesc{Default type}}
188 | \newcommand{\ctemplate}{\Fundesc{Class template}}
189 | \newcommand{\templalias}{\Fundesc{Alias template}}
190 |
191 | %% Cross reference
192 | \newcommand{\xref}{\textsc{See also:}\xspace}
193 | \newcommand{\xsee}{\textsc{See:}\xspace}
194 |
195 | %% NTBS, etc.
196 | \newcommand{\NTS}[1]{\textsc{#1}\xspace}
197 | \newcommand{\ntbs}{\NTS{ntbs}}
198 | \newcommand{\ntmbs}{\NTS{ntmbs}}
199 | \newcommand{\ntwcs}{\NTS{ntwcs}}
200 | \newcommand{\ntcxvis}{\NTS{ntc16s}}
201 | \newcommand{\ntcxxxiis}{\NTS{ntc32s}}
202 |
203 | %% Code annotations
204 | \newcommand{\EXPO}[1]{\textit{#1}}
205 | \newcommand{\expos}{\EXPO{exposition only}}
206 | \newcommand{\impdef}{\EXPO{implementation-defined}}
207 | \newcommand{\impdefx}[1]{\indeximpldef{#1}\EXPO{implementation-defined}}
208 | \newcommand{\notdef}{\EXPO{not defined}}
209 |
210 | \newcommand{\UNSP}[1]{\textit{\texttt{#1}}}
211 | \newcommand{\unspec}{\UNSP{unspecified}\xspace}
212 | \newcommand{\unspecbool}{\UNSP{unspecified-bool-type}}
213 | \newcommand{\seebelow}{\UNSP{see below}}
214 | \newcommand{\unspecuniqtype}{\UNSP{unspecified unique type}}
215 | \newcommand{\unspecalloctype}{\UNSP{unspecified allocator type}}
216 |
217 | %% Double underscore
218 | \newcommand{\ungap}{\kern.5pt}
219 | \newcommand{\unun}{\_\ungap\_}
220 | \newcommand{\xname}[1]{\unun\ungap#1}
221 | \newcommand{\mname}[1]{\tcode{\unun\ungap#1\ungap\unun}}
222 |
223 | %% Ranges
224 | \newcommand{\Range}[4]{\tcode{#1\brk{}#3,\brk{}#4\brk{}#2}\xspace}
225 | \newcommand{\crange}[2]{\Range{[}{]}{#1}{#2}}
226 | \newcommand{\brange}[2]{\Range{(}{]}{#1}{#2}}
227 | \newcommand{\orange}[2]{\Range{(}{)}{#1}{#2}}
228 | \newcommand{\range}[2]{\Range{[}{)}{#1}{#2}}
229 |
230 | %% Change descriptions
231 | \newcommand{\diffdef}[1]{\hfill\break\textbf{#1:}\xspace}
232 | \newcommand{\change}{\diffdef{Change}}
233 | \newcommand{\rationale}{\diffdef{Rationale}}
234 | \newcommand{\effect}{\diffdef{Effect on original feature}}
235 | \newcommand{\difficulty}{\diffdef{Difficulty of converting}}
236 | \newcommand{\howwide}{\diffdef{How widely used}}
237 |
238 | %% Miscellaneous
239 | \newcommand{\uniquens}{\textrm{\textit{\textbf{unique}}} }
240 | \newcommand{\stage}[1]{\item{\textbf{Stage #1:}}\xspace}
241 | \newcommand{\doccite}[1]{\textit{#1}\xspace}
242 | \newcommand{\cvqual}[1]{\textit{#1}}
243 | \newcommand{\cv}{\cvqual{cv}}
244 | \renewcommand{\emph}[1]{\textit{#1}\xspace}
245 | \newcommand{\numconst}[1]{\textsl{#1}\xspace}
246 | \newcommand{\logop}[1]{{\footnotesize #1}\xspace}
247 |
248 | %%--------------------------------------------------
249 | %% Environments for code listings.
250 |
251 | % We use the 'listings' package, with some small customizations. The
252 | % most interesting customization: all TeX commands are available
253 | % within comments. Comments are set in italics, keywords and strings
254 | % don't get special treatment.
255 |
256 | \lstset{language=C++,
257 | basicstyle=\small\CodeStyle,
258 | keywordstyle=,
259 | stringstyle=,
260 | xleftmargin=1em,
261 | showstringspaces=false,
262 | commentstyle=\itshape\rmfamily,
263 | columns=flexible,
264 | keepspaces=true,
265 | texcl=true}
266 |
267 | % Our usual abbreviation for 'listings'. Comments are in
268 | % italics. Arbitrary TeX commands can be used if they're
269 | % surrounded by @ signs.
270 | \newcommand{\CodeBlockSetup}{
271 | \lstset{escapechar=@}
272 | \renewcommand{\tcode}[1]{\textup{\CodeStylex{##1}}}
273 | \renewcommand{\techterm}[1]{\textit{\CodeStylex{##1}}}
274 | \renewcommand{\term}[1]{\textit{##1}}
275 | \renewcommand{\grammarterm}[1]{\textit{##1}}
276 | }
277 | \lstnewenvironment{codeblock}{\CodeBlockSetup}{}
278 |
279 | % A code block in which single-quotes are digit separators
280 | % rather than character literals.
281 | \lstnewenvironment{codeblockdigitsep}{
282 | \CodeBlockSetup
283 | \lstset{deletestring=[b]{'}}
284 | }{}
285 |
286 | % Permit use of '@' inside codeblock blocks (don't ask)
287 | \makeatletter
288 | \newcommand{\atsign}{@}
289 | \makeatother
290 |
291 | %%--------------------------------------------------
292 | %% Indented text
293 | \newenvironment{indented}
294 | {\list{}{}\item\relax}
295 | {\endlist}
296 |
297 | %%--------------------------------------------------
298 | %% Library item descriptions
299 | \lstnewenvironment{itemdecl}
300 | {
301 | \lstset{escapechar=@,
302 | xleftmargin=0em,
303 | aboveskip=2ex,
304 | belowskip=0ex % leave this alone: it keeps these things out of the
305 | % footnote area
306 | }
307 | }
308 | {
309 | }
310 |
311 | \newenvironment{itemdescr}
312 | {
313 | \begin{indented}}
314 | {
315 | \end{indented}
316 | }
317 |
318 |
319 | %%--------------------------------------------------
320 | %% Bnf environments
321 | \newlength{\BnfIndent}
322 | \setlength{\BnfIndent}{\leftmargini}
323 | \newlength{\BnfInc}
324 | \setlength{\BnfInc}{\BnfIndent}
325 | \newlength{\BnfRest}
326 | \setlength{\BnfRest}{2\BnfIndent}
327 | \newcommand{\BnfNontermshape}{\small\rmfamily\itshape}
328 | \newcommand{\BnfTermshape}{\small\ttfamily\upshape}
329 | \newcommand{\nonterminal}[1]{{\BnfNontermshape #1}}
330 |
331 | \newenvironment{bnfbase}
332 | {
333 | \newcommand{\nontermdef}[1]{\nonterminal{##1}\indexgrammar{\idxgram{##1}}:}
334 | \newcommand{\terminal}[1]{{\BnfTermshape ##1}\xspace}
335 | \newcommand{\descr}[1]{\normalfont{##1}}
336 | \newcommand{\bnfindentfirst}{\BnfIndent}
337 | \newcommand{\bnfindentinc}{\BnfInc}
338 | \newcommand{\bnfindentrest}{\BnfRest}
339 | \begin{minipage}{.9\hsize}
340 | \newcommand{\br}{\hfill\\}
341 | \frenchspacing
342 | }
343 | {
344 | \nonfrenchspacing
345 | \end{minipage}
346 | }
347 |
348 | \newenvironment{BnfTabBase}[1]
349 | {
350 | \begin{bnfbase}
351 | #1
352 | \begin{indented}
353 | \begin{tabbing}
354 | \hspace*{\bnfindentfirst}\=\hspace{\bnfindentinc}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\kill}
355 | {
356 | \end{tabbing}
357 | \end{indented}
358 | \end{bnfbase}
359 | }
360 |
361 | \newenvironment{bnfkeywordtab}
362 | {
363 | \begin{BnfTabBase}{\BnfTermshape}
364 | }
365 | {
366 | \end{BnfTabBase}
367 | }
368 |
369 | \newenvironment{bnftab}
370 | {
371 | \begin{BnfTabBase}{\BnfNontermshape}
372 | }
373 | {
374 | \end{BnfTabBase}
375 | }
376 |
377 | \newenvironment{simplebnf}
378 | {
379 | \begin{bnfbase}
380 | \BnfNontermshape
381 | \begin{indented}
382 | }
383 | {
384 | \end{indented}
385 | \end{bnfbase}
386 | }
387 |
388 | \newenvironment{bnf}
389 | {
390 | \begin{bnfbase}
391 | \list{}
392 | {
393 | \setlength{\leftmargin}{\bnfindentrest}
394 | \setlength{\listparindent}{-\bnfindentinc}
395 | \setlength{\itemindent}{\listparindent}
396 | }
397 | \BnfNontermshape
398 | \item\relax
399 | }
400 | {
401 | \endlist
402 | \end{bnfbase}
403 | }
404 |
405 | % non-copied versions of bnf environments
406 | \newenvironment{ncbnftab}
407 | {
408 | \begin{bnftab}
409 | }
410 | {
411 | \end{bnftab}
412 | }
413 |
414 | \newenvironment{ncsimplebnf}
415 | {
416 | \begin{simplebnf}
417 | }
418 | {
419 | \end{simplebnf}
420 | }
421 |
422 | \newenvironment{ncbnf}
423 | {
424 | \begin{bnf}
425 | }
426 | {
427 | \end{bnf}
428 | }
429 |
430 | %%--------------------------------------------------
431 | %% Drawing environment
432 | %
433 | % usage: \begin{drawing}{UNITLENGTH}{WIDTH}{HEIGHT}{CAPTION}
434 | \newenvironment{drawing}[4]
435 | {
436 | \newcommand{\mycaption}{#4}
437 | \begin{figure}[h]
438 | \setlength{\unitlength}{#1}
439 | \begin{center}
440 | \begin{picture}(#2,#3)\thicklines
441 | }
442 | {
443 | \end{picture}
444 | \end{center}
445 | \caption{\mycaption}
446 | \end{figure}
447 | }
448 |
449 | %%--------------------------------------------------
450 | %% Environment for imported graphics
451 | % usage: \begin{importgraphic}{CAPTION}{TAG}{FILE}
452 |
453 | \newenvironment{importgraphic}[3]
454 | {%
455 | \newcommand{\cptn}{#1}
456 | \newcommand{\lbl}{#2}
457 | \begin{figure}[htp]\centering%
458 | \includegraphics[scale=.35]{#3}
459 | }
460 | {
461 | \caption{\cptn}\label{\lbl}%
462 | \end{figure}}
463 |
464 | %% enumeration display overrides
465 | % enumerate with lowercase letters
466 | \newenvironment{enumeratea}
467 | {
468 | \renewcommand{\labelenumi}{\alph{enumi})}
469 | \begin{enumerate}
470 | }
471 | {
472 | \end{enumerate}
473 | }
474 |
475 | % enumerate with arabic numbers
476 | \newenvironment{enumeraten}
477 | {
478 | \renewcommand{\labelenumi}{\arabic{enumi})}
479 | \begin{enumerate}
480 | }
481 | {
482 | \end{enumerate}
483 | }
484 |
485 | %%--------------------------------------------------
486 | %% Definitions section
487 | % usage: \definition{name}{xref}
488 | %\newcommand{\definition}[2]{\rSec2[#2]{#1}}
489 | % for ISO format, use:
490 | \newcommand{\definition}[2]
491 | {\hfill\vspace{.25ex plus .5ex minus .2ex}\\
492 | \addtocounter{subsection}{1}%
493 | \textbf{\thesubsection\hfill\relax[#2]}\\
494 | \textbf{#1}\label{#2}\\
495 | }
496 |
--------------------------------------------------------------------------------
/Coroutines/overloading.tex:
--------------------------------------------------------------------------------
1 |
2 | %%
3 | %% Overloading
4 | %%
5 | %\setcounter{chapter}{12}
6 | \begingroup
7 | \renewcommand{\cleardoublepage}{}
8 | \renewcommand{\clearpage}{}
9 | \rSec0[over]{Overloading}
10 | \endgroup
11 |
12 | \setcounter{section}{3}
13 | \setcounter{subsection}{1}
14 | \setcounter{subsubsection}{1}
15 | %\rSec3[over.match.oper]{Operators in expressions}%
16 | %Add the underlined text to item 3.3.
17 | %
18 | %\begin{quote}
19 | % \setcounter{Paras}{3}
20 | % \begin{itemize}
21 | % \item ...
22 | % \item ...
23 | % \item
24 | %For the operator
25 | %\tcode{,},
26 | %the unary operator
27 | %\tcode{\&},
28 | %\added{
29 | %the unary operator}
30 | %\tcode{\added{co_await}}\added{,}
31 | %or the operator
32 | %\tcode{->},
33 | %the built-in candidates set is empty.
34 | %For all other operators, the built-in candidates include all
35 | %of the candidate operator functions defined in~\cxxref{over.built} that,
36 | %compared to the given operator,
37 | % \end{itemize}
38 | %\end{quote}
39 |
40 | \setcounter{section}{4}
41 | \rSec1[over.oper]{Overloaded operators}
42 |
43 | Add \tcode{co_await} to the list of operators in paragraph 1 before operators \tcode{()} and \tcode{[]}.
44 |
45 | %\rSec1[over.built]{Built-in operators}%
46 | %\indextext{overloading!built-in operators and}
47 | %
48 | %Add the underlined text to the note in paragraph 1.
49 | %
50 | %\begin{quote}
51 | %\pnum
52 | %The candidate operator functions that represent the built-in operators
53 | %defined in Clause~\ref{expr} are specified in this subclause.
54 | %These candidate
55 | %functions participate in the operator overload resolution process as
56 | %described in~\cxxref{over.match.oper} and are used for no other purpose.
57 | %\enternote
58 | %Because built-in operators\added{ except for operator }\tcode{\added{co_await}} take only operands with non-class type,
59 | %and operator overload resolution occurs only when an operand expression
60 | %originally has class or enumeration type,
61 | %operator overload resolution can resolve to a built-in operator only
62 | %when an operand has a class type that has a user-defined conversion to
63 | %a non-class type appropriate for the operator, or when an operand has
64 | %an enumeration type that can be converted to a type appropriate
65 | %for the operator.
66 | %Also note that some of the candidate operator functions given in this subclause are
67 | %more permissive than the built-in operators themselves.
68 | %As
69 | %described in~\cxxref{over.match.oper}, after a built-in operator is selected
70 | %by overload resolution the expression is subject to the requirements for
71 | %the built-in operator given in Clause~\ref{expr}, and therefore to any
72 | %additional semantic constraints given there.
73 | %If there is a user-written
74 | %candidate with the same name and parameter types as a built-in
75 | %candidate operator function, the built-in operator function
76 | %is hidden and is not included in the set of candidate functions.
77 | %\exitnote
78 | %\end{quote}
79 | %
80 | %Add new paragraph after paragraph 25.
81 | %
82 | %\begin{quote}
83 | %\setcounter{Paras}{25}
84 | %\pnum
85 | %For every pair
86 | %(\textit{T},
87 | %\textit{CV}),
88 | %where
89 | %\textit{T}
90 | %is a class type containing declarations of any of the following names: \tcode{await_ready}, \tcode{await_suspend}, \tcode{await_resume}, and
91 | %\textit{CQ}
92 | %is \grammarterm{cv-qualifier-seq}, there exist candidate operator functions of the form
93 | %\begin{codeblock}
94 | % @\textit{CV T}@& operator co_await(@\textit{CV T}@&);
95 | % @\textit{CV T}@&& operator co_await(@\textit{CV T}@&&);
96 | %\end{codeblock}
97 | %which return their operand as the result.
98 | %\end{quote}
99 |
100 | Add the following paragraph after paragraph 5.
101 |
102 | \begin{quote}
103 | \setcounter{Paras}{5}
104 | \pnum
105 | The
106 | \tcode{co_await} operator
107 | is described completely in~\ref{expr.await}.
108 | The attributes and restrictions
109 | found in the rest of this subclause do not apply to it unless explicitly
110 | stated in~\ref{expr.await}.
111 | \end{quote}
112 |
113 | %\setcounter{section}{3}
114 | %\setcounter{subsection}{1}
115 | %\setcounter{subsubsection}{1}
116 | %\rSec3[over.match.oper]{Operators in expressions}%
117 | %
118 | %Change \ref{over.match.oper}/9:
119 | %
120 | %\begin{quote}
121 | %\setcounter{Paras}{8}
122 | %\pnum
123 | %If the operator is the operator
124 | %\tcode{,},
125 | %the unary operator
126 | %\tcode{\&},
127 | %\removed{or} the operator
128 | %\tcode{->},
129 | %\added{or the operator \tcode{co_await}},
130 | %and there are no viable functions, then the operator is
131 | %assumed to be the built-in operator and interpreted according to
132 | %Clause~\ref{expr}.
133 | %\end{quote}
134 | %
135 | %Add a new paragraph after paragraph 8:
136 | %
137 | %\begin{quote}
138 | %\setcounter{Paras}{8}
139 | %\pnum
140 | % When operator \tcode{co_await} returns, the \tcode{co_await} operator is applied to the value returned. The resulting \tcode{co_await} operator is assumed to be the built-in operator and interpreted according to Clause~\ref{expr}.
141 | %\end{quote}
142 |
143 | %\setcounter{subsection}{8}
144 | %\rSec2[over.await]{Await operator}%
145 | %
146 | %\pnum
147 | %If there is no user-declared \tcode{operator await} for type \tcode{X}, but there is a declared member with a name \tcode{await_suspend}, \tcode{await_ready}, or \tcode{await_resume}, then the implementation shall provide the implicit definition of \tcode{operator await} in such a way that the result of the evaluation of an implicit \tcode{operator await(\textit{v})} is \textit{v} itself.
148 |
149 |
--------------------------------------------------------------------------------
/Coroutines/p0664r1.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 | C++ Coroutine TS Issues
8 |
23 |
24 |
25 | C++ Coroutine TS Issues
26 |
27 |
28 | Doc. no. |
29 | P0664R1 |
30 |
31 |
32 | Revises |
33 | P0664R0 |
34 |
35 |
36 | Date: |
37 | Revised 2017-06-18 at 14:25:00 UTC
38 | |
39 |
40 |
41 | Project: |
42 | Programming Language C++ |
43 |
44 |
45 | Reference: |
46 | ISO/IEC PDTS 22277, C++ Extensions for Coroutines |
47 |
48 |
49 | Audience: |
50 | EWG, CWG, LWG |
51 |
52 |
53 | Reply to: |
54 | Gor Nishanov <gorn@microsoft.com> |
55 |
56 |
57 | Introduction
58 | All proposed resolutions wording is relative to N4663 (ISO/IEC PDTS 22277).
59 |
60 | Table of content
61 |
62 |
63 | -
64 | [CWG Approved Toronto-7/12/2017] Coroutine issues reviewed and approved by CWG: 2 6 7 18 21
65 |
66 | -
67 | [LWG Approved Toronto-7/11/2017] Coroutine issues reviewed and approved by LWG: 9 10 11 14 15 22 23
68 |
69 |
70 | Issues rejected or requiring no action for now:
71 |
72 | -
73 | Core comments requesting rebase of a TS to C++17: 3 5 17
74 |
75 | -
76 | Core comments (no action): 4
77 |
78 | -
79 | Core comments (rejected, no consensus for change): 8
80 |
81 | -
82 | LWG issues with no wording: 12 16 19 20
83 |
84 | -
85 | Evolution issues with no wording: 1 13
86 |
87 |
88 |
89 |
90 | Core Issues (with proposed wording)
91 |
92 |
93 | 2. Change to italics await-resume
in 5.3.8/4
94 | Section: 5.3.8 [expr.await] Status: Has wording
95 | Submitter: US002 Opened: 2017-06-05 Last modified: 2017-06-05
96 | Proposed resolution:
97 |
98 | Modify 5.3.8/4
99 |
100 | The await-expression has the same type and value category as the await-resume
await-resume expression.
101 |
102 |
103 | [Accepted: Toronto-7/10/2017]
104 |
105 |
106 | 6. Remove or update stateful allocator example in 8.4.4/12
107 | Section: 8.4.4 [dcl.fct.def.coroutine] Status: Has wording
108 | Submitter: US006 Opened: 2017-06-05 Last modified: 2017-06-05
109 | Issue:
110 |
111 | Stateful allocators (pmr) do not work this way, there's
112 | no mechanism for allocator propagation to the
113 | captured state.
114 |
115 |
116 | Strike section 12, or provide mechanism for holding allocator.
117 |
118 | Proposed resolution:
119 |
120 | Remove example 8.4.4/12
121 |
122 | [Accepted: Toronto-7/10/2017]
123 |
124 |
125 |
7. Fix generator example in 8.4.4/11
126 | Section: 8.4.4/11 [dcl.fct.def.coroutine] Status: Has wording
127 | Submitter: US007 Opened: 2017-06-05 Last modified: 2017-06-05
128 | Issue:
129 |
130 | Is unhandled_exception() a requirement for a promise_type?
131 |
132 |
133 | a) Call std::terminate if not present
134 | or
135 | b) Add unhandled_exception() to the complete example
136 | of promise_type in 8.4.4 paragraph 11, the generator
137 | example.
138 |
139 | Discussion:
140 | unhandled_exception()
is required to be present in a promise_type.
141 | There are more mistakes in the example that are fixed in the proposed resolution. Also,
142 | required includes are added to make the example self contained and runnable in
143 | online compilers.
144 | Proposed resolution:
145 | Modify the example in 8.4.4/11 as follows:
146 |
147 |
148 | #include <iostream>
149 | #include <experimental/coroutine>
150 |
151 | // ::operator new(size_t, nothrow_t) will be used if allocation is needed
152 | struct generator {
153 | struct promise_type;
154 | using handle = std::experimental::coroutine_handle<promise_type>;
155 | struct promise_type {
156 | int current_value;
157 | static auto get_return_object_on_allocation_failure() { return generator{nullptr}; }
158 | auto get_return_object() { return generator{handle::from_promise(*this)}; }
159 | auto initial_suspend() { return std::experimental::suspend_always{}; }
160 | auto final_suspend() { return std::experimental::suspend_always{}; }
161 | void unhandled_exception() { std::terminate(); }
162 | void return_void() {}
163 | auto yield_value(int value) {
164 | current_value = value;
165 | return std::experimental::suspend_always{};
166 | }
167 | };
168 | bool move_next() { return coro ? (coro.resume(), !coro.done()) : false; }
169 | int current_value() { return coro.promise().current_value; }
170 | generator(generator const&) = delete;
171 | generator(generator && rhs) : coro(rhs.coro) { rhs.coro = nullptr; }
172 | ~generator() { if (coro) coro.destroy(); }
173 | private:
174 | generator(handle h) : coro(h) {}
175 | handle coro;
176 | };
177 | generator f() { co_yield 1; co_yield 2; }
178 | int main() {
179 | auto g = f();
180 | while (g.move_next()) std::cout << g.current_value() << std::endl;
181 | }
182 |
183 |
184 |
185 | [Accepted: Toronto-7/10/2017]
186 |
187 |
188 | 18. In intro.refs use required text from ISO directive part2
189 | Section: 2 [intro.refs] Status: Has wording
190 | Submitter: CA018 Opened: 2017-06-05 Last modified: 2017-06-05
191 | Issue:
192 |
193 | The form required by ISO/IEC Directives, Part 2, 2016 subclause 15.5.1 is not followed.
194 |
195 |
196 | Use the text provided by the Directives.
197 |
198 | Proposed resolution:
199 |
200 | Modify [intro.refs] paragraph 1 as follows:
201 |
202 | The following referenced document is indispensable for the
203 | application of this document. For dated references, only the
204 | edition cited applies.
205 | The following documents are referred to in the text in such a way that some or all of their
206 | content constitutes requirements of this document. For dated references, only the edition cited applies.
207 | For undated references, the latest edition of the referenced document (including any amendments) applies.
208 |
209 |
210 | [Accepted: Toronto-7/10/2017]
211 |
212 |
213 | 21. Wording of 'co_return <expr>;' statement for expressions of type void implies that <expr> is not evaluated
214 | Section: 6.6.3.1 [stmt.return.coroutine] Status: Has wording
215 | Submitter: Lewis Baker Opened: 2017-03-11 Last modified: 2017-06-19
216 | Issue:
217 |
218 | This wording seems to indicate that expr is not evaluated in co_return expr if the expression has type void
,
219 | since expr does not occur in the translation. I assume this was not the intention here.
220 |
221 | Perhaps there needs to be an extra case here to explicitly state what co_return expr; translates to if the type of expr
222 | is void
?
223 |
224 |
Proposed resolution:
225 |
226 | Modify paragraph 2 in [stmt.return.coroutine] follows:
227 |
228 | 2. ... where final_suspend is as defined in 8.4.4 and S is an expression defined as follows:
229 | (2.1) — S is p.return_value(
braced-init-list)
, if the operand is a braced-init-list;
230 | (2.2) — S is p.return_value(
expression)
, if the operand is an expression of non-void
type;
231 |
232 | (2.3) — S is {
expressionopt ;
p.return_void(); }
, otherwise;
233 |
234 |
235 |
236 | [Accepted: Toronto-7/12/2017]
237 |
238 |
239 |
240 | Core comments requesting rebase to C++17
241 |
242 |
243 | 3. Update range based for statement after C++17
244 | Section: 6.5.4/1 [stmt.ranged]Status: Comment
245 | Submitter: US003 Opened: 2017-06-05 Last modified: 2017-06-05
246 | Comment:
247 | Update range based for statement after C++17
248 |
249 | [Rejected. Will rebase prior to merge to working paper. Toronto-7/10/2017]
250 |
251 | 5. Modify co_return grammar to match C++17
252 | Section: 6.6.3.1 [stmt.return.coroutine]Status: Comment
253 | Submitter: US005 Opened: 2017-06-05 Last modified: 2017-06-05
254 | Comment:
255 | Simplify the grammar for
256 |
257 | coroutine-return-statement:
258 | co_return expression_opt_;
259 | co_return braced-init-list;
260 |
261 | to
262 | coroutine-return-statement:
263 | co_return co_return expr-or-braced-init-list opt;
264 |
265 |
266 | [Rejected. Will rebase prior to merge to working paper. Toronto-7/10/2017]
267 |
268 | 17. Rebase entire TS on C++17
269 | Section: Status: Comment
270 | Submitter: US017 Opened: 2017-06-05 Last modified: 2017-06-05
271 | Comment:
272 | We are in the process of balloting the final text of the
273 | next C++ standard, provisionally ISO/IEC 14882:2017.
274 | We should hold back publishing this TS long enough to
275 | rebase on the text of the new standard.
276 |
277 |
278 | Other than updating this reference, the change is
279 | almost entirely updating section numbers and crossreferences.
280 | The normative changes would be
281 |
282 | - updating the range based 'for' loop syntax;
283 | - the text for a 'return' statement would need adjusting;
284 | - the wording on restrictions with respect to longjmp
285 | should be reviewed;
286 | - hash support for coroutine_handle should be updated
287 | with the “enabled” terminology.
288 |
289 |
290 | [Rejected. Will rebase prior to merge to working paper. Toronto-7/10/2017]
291 |
292 |
293 | Core comments (no action)
294 |
295 |
296 | 4. It would be good to minimize undefined
297 | behaviour
298 | Section: 6.6.3 6.6.3.1 8.4.4 8.11.2.5 18.10 18.11.2.5 Status: Comment
299 | Submitter: US004 Opened: 2017-06-05 Last modified: 2017-06-05
300 | Comment:
301 |
302 | There are many new cases of undefined behaviour
303 | introduced by the TS which are somewhat easily triggered by independent parts of the mechanisms,
304 | e.g., the result type of the coroutine interacting
305 | through the promise_type to allow flow of control to
306 | run off the end of a coroutine.
307 | In general it would be good to minimize undefined
308 | behaviour.
309 |
310 | No action for now. However, experience with TS
311 | implementation may allow reducing UB. This should form part of any review for integrating coroutines as
312 | part of a future standard.
313 |
314 |
315 | [No Action. Toronto-7/10/2017]
316 |
317 |
318 | Core comments (rejected, no consensus for change)
319 |
320 |
321 |
322 |
323 | 8. Note about possibly undefined behaviour
324 | Section: 8.4.4/11 [dcl.fct.def.coroutine] Status: Has wording
325 | Submitter: US008 Opened: 2017-06-05 Last modified: 2017-06-05
326 | Proposed change:
327 |
328 | Modify note in 8.4.4/11:
329 |
330 | If a coroutine has a parameter passed by reference,
331 | resuming the coroutine
332 | after the lifetime of the entity referred to by that
333 | parameter has ended is likely to results in
334 | undefined behavior.
335 |
336 |
337 | Proposed resolution:
338 |
339 | No change. If after resumption a coroutine does not touch that parameter, there is no
340 | undefined behavior.
341 |
342 | [Reject. No consensus for change. Toronto-7/10/2017]
343 |
344 |
345 | LWG Issues (with proposed wording)
346 |
347 |
348 |
349 | 9. Move row in the language support table
350 | Section: 18.1 [support.general] Table 30 Status: Has wording
351 | Submitter: CA009 Opened: 2017-06-05 Last modified: 2017-06-05
352 |
353 | Issue:
354 | The entry for subclause 18.11 appears before the entry for subclause 18.10.
355 |
356 | Proposed resolution:
357 | Move the insertion of the entry for subclause 18.11
358 | to appear after the entry for subclause 18.10.
359 |
360 | [Accepted. Toronto-7/11/2017]
361 |
362 |
363 | 10. Specify the exact behaviour of user-customization of
364 | coroutine_traits.
365 | Section: 18.11.1 [coroutine.traits] Status: Has wording
366 | Submitter: US010 Opened: 2017-06-05 Last modified: 2017-06-05
367 |
368 | Issue:
369 | Is the template coroutines_traits intended to be a
370 | user-extension point? If so, spell out the contract
371 | for users to customize this trait. Otherwise, restrict
372 | user specialization with the wording for all type
373 | traits in the header. 18.11.1p2
374 | suggests the former, while the latter is much
375 | simpler to specify for the initial TS.
376 |
377 | Proposed resolution:
378 |
379 | -
380 | Modify paragraph 2 of 18.11.1 [coroutine.traits] as follows
381 |
382 | 2. Users may specialize coroutine_traits
to customize the semantics of coroutines.
383 | 2. A program may specialize this template. Such specialization shall define a publicly accessible nested type named promise_type.
384 |
385 |
386 | -
387 | In 18.11.2 [coroutine.handle] add paragraph:
388 |
389 | 2. The behavior of a program that adds specializations for coroutine_handle
is undefined.
390 |
391 |
392 |
393 |
394 |
395 | [Accepted. Toronto-7/11/2017]
396 |
397 |
398 | 11. coroutine_handle: Unclear where specification refer to specialization or primary template
399 | Section: 18.1.2 [coroutine.handle] Status: Comment
400 | Submitter: US011 Opened: 2017-06-05 Last modified: 2017-06-05
401 |
402 | Issue:
403 | The specification of each operation is not explicitly
404 | clear whether it applied to the specialization of
405 | coroutine_handle<void>, or the primary
406 | coroutine_handle template.
407 |
408 | Break this section into two, to clearly provide definitions
409 | for both versions of the template.
410 |
411 |
412 | Proposed resolution:
413 | Use resolution for 23
414 |
415 |
416 | [Accepted. Toronto-7/11/2017]
417 |
418 |
419 | 14. Comment about: a concurrent resumption of a coroutine by multiple
420 | threads may result in a data race
421 | Section: 18.11.2.5 Status: Comment
422 | Submitter: US014 Opened: 2017-06-05 Last modified: 2017-06-05
423 |
424 | Comment:
425 | a concurrent resumption of a coroutine by multiple
426 | threads may result in a data race
427 | Possibly means concurrent destruction here, in the
428 | destroy method.
429 |
430 |
431 | Discussion:
432 | Yes. Any combination of resumptions may result in a data race: resume/resume, resume/destroy or destroy/destroy.
433 | Proposed wording:
434 |
435 |
436 | -
437 | Modify paragraph 3 of 18.11.2.5 [coroutine.handle.resumption] as follows:
438 |
439 | 3. Synchronization: a concurrent resumption of a coroutine by multiple threads may result in a data race.
440 | a concurrent resumption of the coroutine via resume
, operator()
, or destroy
may result in a data race.
441 |
442 |
443 | -
444 | Modify paragraph 6 of 18.11.2.5 [coroutine.handle.resumption] as follows:
445 |
446 | 3. Synchronization: a concurrent resumption of a coroutine by multiple threads may result in a data race.
447 | a concurrent resumption of the coroutine via resume
, operator()
, or destroy
may result in a data race.
448 |
449 |
450 |
451 |
452 |
453 | [Accepted. Toronto-7/11/2017]
454 |
455 |
456 | 15. Make coroutine_handle comparison constexpr
457 | Section: 18.11.2.7 Status: Comment
458 | Submitter: US015 Opened: 2017-06-05 Last modified: 2017-06-05
459 |
460 | Comment:
461 | As coroutine_handle<void> is a literal type, should
462 | the comparison operators be constexpr?
463 | Add constexpr to the declaration/definition of
464 | operator==, operator !=, operator<, operator<=,
465 | operator>=, and operator> for arguments of type
466 | coroutine_handle<>.
467 |
468 |
469 | Discussion:
470 | The only literal coroutine_handle is the default constructed one. Not sure if we need constexpr on comparisons. (LEWG voted 3 5 11 3 0 to add constexpr)
471 | Proposed wording:
472 | Modify function declarations in clause 18.11.2.7 [coroutine.handle.compare] as follows:
473 |
474 |
475 | constexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept;
476 | constexpr bool operator<(coroutine_handle<> x, coroutine_handle<> y) noexcept;
477 | constexpr bool operator!=(coroutine_handle<> x, coroutine_handle<> y) noexcept;
478 | constexpr bool operator>(coroutine_handle<> x, coroutine_handle<> y) noexcept;
479 | constexpr bool operator<=(coroutine_handle<> x, coroutine_handle<> y) noexcept;
480 | constexpr bool operator>=(coroutine_handle<> x, coroutine_handle<> y) noexcept;
481 |
482 |
483 |
484 | [Accepted. Toronto-7/11/2017]
485 |
486 |
487 | 22. Rename [coroutine.handle.import.export] to [coroutine.handle.export.import] for consistency
488 | Section: 18.11 [support.coroutine] Status: Has wording
489 | Submitter: Bryce Lelbach Opened: 2017-03-10 Last modified: 2017-06-19
490 |
491 | Issue:
492 | In the class synopsis for coroutine_handle<> in [coroutine.handle], this section is referred to as "export/import", and the export function (address) is listed before the import function (from_address). Likewise, in the definitions for these two methods in [coroutine.handle.import.export], the section is titled "Export/import" and address appears first. Since from_address mentions address, this seems like the correct order to list things in as it avoids adding forward references to the spec.
493 |
494 | I'd like to rename this stable tag from [coroutine.handle.import.export] to [coroutine.handle.export.import] as an editorial change before PTDS.
495 |
496 | Pull request.
497 |
498 | Proposed resolution:
499 |
500 | s/coroutine.handle.import.export/coroutine.handle.export.import/g
501 |
502 |
503 | [Accepted. Toronto-7/11/2017]
504 |
505 |
506 | 23. coroutine_handle::from_address - consolidate duplicate definitions, add missing constexpr and replace address() with address in precondition wording
507 | Section: 18.11.2 [coroutine.handle] Status: Has wording
508 | Submitter: Bryce Lelbach Opened: 2017-03-10 Last modified: 2017-06-19
509 |
510 | Issue:
511 |
512 | There are currently two definitions of the from_address: one in [coroutine.handle.import.export] and one in [coroutine.handle.import].
513 | In the class synopses in [coroutine.handle], the coroutine_handle<> specialization references [coroutine.handle.import.export]
514 | while primary definition for coroutine_handle references [corouinte.handle.import].
515 | They are nearly identical in wording. although the definition in [coroutine.handle.import.export] is written as if it was out of line
516 | (e.g. coroutine_handle<>::from_address).
517 | Even though the primary template of coroutine_handle inherits from coroutine_handle<> it is necessary to define from_address
518 | in the primary template, since, from_address returns coroutine_handle, which is a different type in the primary template than it is
519 | in coroutine_handle.
520 |
521 |
522 | from_address
's Requires: paragraph in [coroutine.handle.import.export] states the pre-condition that
523 | "addr was obtained via a prior call to address()
". It should be address
, not address()
,
524 | since address()
is an expression not a method
525 |
526 |
527 | from_address
is declared constexpr in the class synopsis ([coroutine.handle],
528 | in both the primary template and the specialization for coroutine_handle<>) but is not constexpr
in the definition.
529 | The design intent, I believe, is for from_address to be constexpr.
530 | Pull request.
531 | Proposed resolution:
532 |
533 | -
534 | Modify 18.11.2 [coroutine.handle] primary template synopsis:
535 |
536 |
537 | // 18.11.2.3 import
538 | // 18.11.2.2 export/import
539 | constexpr static coroutine_handle from_address(void* addr);
540 |
541 |
542 |
543 | -
544 | Modify 18.11.2.2 [coroutine.handle.import.export] as follows:
545 |
546 |
547 | constexpr static coroutine_handle<> coroutine_handle<>::from_address(void* addr);
548 | constexpr static coroutine_handle<Promise> coroutine_handle<Promise<::from_address(void* addr);
549 | Requires: addr was obtained via a prior call to address().
550 |
551 |
552 |
553 | -
554 | Remove section 18.11.2.3 [coroutine.handle.import].
555 |
556 |
557 |
558 | [Accepted. Toronto-7/11/2017]
559 |
560 |
561 |
562 | LWG Issues (no wording)
563 |
564 |
565 |
566 |
567 | 12. Should there be a coroutine_handle type with ownership semantic?
568 | Section: 18.1.2 [coroutine.handle] Status: Comment
569 | Submitter: US012 Opened: 2017-06-05 Last modified: 2017-06-05
570 |
571 | Comment:
572 | Coroutine handles have essentially raw pointer
573 | semantics. Should there be a library type as part of
574 | the TS that does destroy / set to nullptr?
575 |
576 | If a library type is needed, please add it.
577 |
578 |
579 | Discussion:
580 | coroutine handle is a low level type. Ownership semantic is introduced by higher level types such as a generator or task.
581 | Note that not every use of coroutine_handle requires ownership semantic. An iterator does not own the coroutine nor a coroutine_handle
582 | captured by a lambda passed as a callback parameter to an asynchronous API owns the coroutine it refers to.
583 | Proposed resolution:
584 | No action
585 |
586 |
587 | [Reject. No consensus for change. Toronto-7/11/2017]
588 |
589 |
590 | 16. Rename suspend_always to suspend_always_t and suspend_never to suspend_never_t
591 | Section: 18.11.3 Status: Comment
592 | Submitter: US016 Opened: 2017-06-05 Last modified: 2017-06-05
593 |
594 | Comment:
595 | The names suspend_never and suspend_always
596 | should be (inline) constexpr variables of type
597 | suspend_never_t and suspend_always_t
598 | respectively.
599 |
600 | Change suspend_never and suspend_always as
601 | appropriate.
602 |
603 |
604 | Discussion:
605 | Most common pattern observed in the wild for these types are:
606 |
607 | struct promise_type {
608 | suspend_never initial_suspend() { return {}; }
609 | suspend_always yield_value(int value) { ...; return {}; }
610 | ...
611 | };
612 |
613 | Suggested change makes the common case more verbose.
614 | Proposed resolution:
615 | No action
616 |
617 |
618 | [Reject. No consensus for change. Toronto-7/11/2017]
619 |
620 |
621 | 19. Add higher-level coroutine types
622 | Section: Status: Comment
623 | Submitter: US019 Opened: 2017-06-05 Last modified: 2017-06-05
624 |
625 | Comment:
626 | The TS presents only low level mechanisms to
627 | implement coroutines. For final release in a C++
628 | standard, standard library implementations of
629 | generators, futures from coroutines, guard types for
630 | handles, etc. should also ship.
631 |
632 | Please consider adding standard library
633 | implementations of generators, futures from
634 | Coroutines, guard types for handles and any others that
635 | may be needed when Coroutines are incorporated into
636 | the C++ Standard.
637 |
638 |
639 | Discussion:
640 | Yes. We plan to add generator and adapters for network TS and concurrency TS.
641 | Proposed resolution:
642 | No immediate action for PDTS
643 |
644 |
645 | [Accept. No action for now. Toronto-7/11/2017]
646 |
647 |
648 | 20. Disallow storing coroutines in std::function objects that discard their result.
649 | Section: Status: Comment
650 | Submitter: US020 Opened: 2017-06-05 Last modified: 2017-06-05
651 |
652 | Comment:
653 | Coroutines are invokable types, can they be stored
654 | by a std::function? What about a
655 | std::function<void()> that discards the result on
656 | invocation?
657 |
658 | Disallow storing coroutines in std::function objects
659 | that discard their result.
660 |
661 |
662 | Discussion:
663 | Yes, coroutines are functions and they can be stored in a std::function.
664 | Storing a coroutine in a std::function objects that discard their result is no different than
665 | storing a function with the same signature as coroutine in std::function.
666 | Proposed resolution:
667 | No action
668 |
669 |
670 | [Reject. No consensus for change. Toronto-7/11/2017]
671 |
672 |
673 |
674 | Evolution Issues (no wording)
675 |
676 |
677 | 1. Support stackful coroutines
678 | Section: Status: Comment
679 | Submitter: CH001 Opened: 2017-06-05 Last modified: 2017-06-05
680 | Issue:
681 |
682 | This TS disallows stackful coroutines. This is too
683 | restrictive and stackful coroutines should be allowed as
684 | well.
685 |
686 |
687 | Allow as suspension context functions that were called from a top-level coroutine.
688 |
689 |
690 |
691 | [Reject. No consensus for change. Toronto-7/10/2017]
692 |
693 |
694 | 13. Allow both return_void and return_value
695 | Section: Status: Comment
696 | Submitter: US013 Opened: 2017-06-05 Last modified: 2017-06-05
697 | Comment:
698 |
699 | Promise types are required to implement either
700 | return_value() or return_void(), but not both, and it is
701 | undefined behaviour for a coroutine to run off the end,
702 | where return_void would be called.
703 |
704 | Consider implementing both either_return() and
705 | return_value() for promise types, and eliminate the
706 | undefined behaviour.
707 |
708 | Discussion:
709 | The design intent of having one or the other to make sure that co_return
710 | behavior in a coroutine is similar to that of return
in a regular function.
711 | Allowing both would allow this code to compile:
712 |
713 | coro f(bool cond) {
714 | if (cond)
715 | co_return 42;
716 | else
717 | co_return;
718 | }
719 |
720 | which we would like to avoid.
721 | Proposed Resolution:
722 | No change
723 |
724 |
725 | [Reject. No consensus for change. Toronto-7/11/2017]
726 |
727 |
728 |
729 |
--------------------------------------------------------------------------------
/Coroutines/special.tex:
--------------------------------------------------------------------------------
1 |
2 | \begingroup
3 | \renewcommand{\cleardoublepage}{}
4 | \renewcommand{\clearpage}{}
5 | \rSec0[special]{Special member functions}
6 | \endgroup
7 |
8 | \setcounter{section}{0}
9 | \rSec1[class.ctor]{Constructors}%
10 |
11 | Add new paragraph after paragraph 10.
12 |
13 | \setcounter{Paras}{10}
14 | \begin{quote}
15 | \pnum A constructor shall not be a coroutine.
16 | \end{quote}
17 |
18 | \setcounter{section}{3}
19 | \rSec1[class.dtor]{Destructors}%
20 |
21 | Add new paragraph after paragraph 16.
22 |
23 | \setcounter{Paras}{16}
24 | \begin{quote}
25 | \pnum A destructor shall not be a coroutine.
26 | \end{quote}
27 |
28 | \pagebreak
29 |
30 | \setcounter{section}{7}
31 | \rSec1[class.copy]{Copying and moving class objects}%
32 | \setcounter{subsection}{2}
33 | \rSec2[class.copy.elision]{Copy/move elision}%
34 |
35 | Add a bullet to paragraph 1:
36 |
37 | \begin{quote}
38 | \begin{itemize}
39 | \item in a coroutine (\ref{dcl.fct.def.coroutine}), a copy of a coroutine parameter can be omitted
40 | and references to that copy replaced with references to the corresponding parameter if the meaning of the program will
41 | be unchanged except for the execution of a constructor and destructor for the parameter copy object
42 | \end{itemize}
43 | \end{quote}
44 |
45 | Modify paragraph 3 as follows:
46 |
47 | \begin{quote}
48 | \setcounter{Paras}{2}
49 | \pnum
50 | In the following copy-initialization contexts, a move operation might be used instead of a copy operation:
51 | \begin{itemize}
52 | \item If the \grammarterm{expression} in a \tcode{return} \added{or } \tcode{\added{co_return}} statement \iref{stmt.return}
53 | is a (possibly parenthesized) \grammarterm{id-expression}
54 | that names an object with automatic storage duration declared in the body
55 | or \grammarterm{parameter-declaration-clause} of the innermost enclosing
56 | function or \grammarterm{lambda-expression}, or
57 |
58 | \item if the operand of a \grammarterm{throw-expression}\cxxref{expr.throw}
59 | is the name of a non-volatile automatic object
60 | (other than a function or catch-clause parameter)
61 | whose scope does not extend beyond the end of the innermost enclosing
62 | \grammarterm{try-block} (if there is one),
63 | \end{itemize}
64 | overload resolution to select the constructor
65 | for the copy \added{or the }\tcode{\added{return_value}}\added{ overload to call} is first performed as if the object were designated by an
66 | rvalue.
67 | If the first overload resolution fails or was not performed,
68 | or if the type of the first parameter of the selected
69 | constructor \added{or }\tcode{\added{return_value}}\added{ overload }is not an rvalue reference to the object's type (possibly cv-qualified),
70 | overload resolution is performed again, considering the object as an lvalue.
71 | \begin{note}
72 | This two-stage overload resolution must be performed regardless
73 | of whether copy elision will occur. It determines the constructor \added{or }\tcode{\added{return_value}}\added{ overload }to be called if
74 | elision is not performed, and the selected constructor \added{or }\tcode{\added{return_value}}\added{ overload }must be accessible even if
75 | the call is elided.
76 | \end{note}
77 |
78 | \end{quote}
79 |
--------------------------------------------------------------------------------
/Coroutines/statements.tex:
--------------------------------------------------------------------------------
1 | \begingroup
2 | \renewcommand{\cleardoublepage}{}
3 | \renewcommand{\clearpage}{}
4 | \rSec0[stmt.stmt]{Statements}%
5 | \endgroup
6 |
7 | \setcounter{section}{4}
8 | \rSec1[stmt.iter]{Iteration statements}%
9 | Add the underlined text to paragraph 1.
10 | %NOTE: change the grammar
11 |
12 | \begin{quote}
13 | \pnum
14 | Iteration statements specify looping.
15 |
16 | \indextext{statement!\idxcode{while}}%
17 | \indextext{statement!\idxcode{do}}%
18 | \indextext{statement!\idxcode{for}}%
19 | %
20 | \begin{bnf}
21 | \nontermdef{iteration-statement}\br
22 | \terminal{while (} condition \terminal{)} statement\br
23 | \terminal{do} statement \terminal{while (} expression \terminal{) ;}\br
24 | \terminal{for (} for-init-statement condition\opt \terminal{;} expression\opt \terminal{)} statement\br
25 | \terminal{for} \terminal{\added{co_await\opt{}}}
26 | \terminal{(} for-range-declaration \terminal{:} for-range-initializer \terminal{)} statement\br
27 | % \added{\terminal{cofor (} for-range-declaration \terminal{:} for-range-initializer \terminal{)} statement}
28 | \end{bnf}
29 | \end{quote}
30 |
31 | % goes inside and need fixing goes after
32 |
33 | \setcounter{subsection}{3}
34 | \rSec2[stmt.ranged]{The range-based \tcode{for} statement}%
35 | \indextext{statement!range~based \idxcode{for}}
36 |
37 | Add the underlined text to paragraph 1.
38 |
39 | \begin{quote}
40 | \setcounter{Paras}{0}
41 | \pnum
42 | For a range-based \tcode{for} statement of the form
43 |
44 | \begin{ncbnf}
45 | \terminal{for} \terminal{\added{co_await\opt{}}} \terminal{(} for-range-declaration : for-range-initializer \terminal{)} statement
46 | \end{ncbnf}
47 |
48 | %let \textit{range-init} be equivalent to the \grammarterm{expression} surrounded
49 | %by parentheses\footnote{this ensures that a top-level comma operator cannot be
50 | % reinterpreted as a delimiter between \grammarterm{init-declarator}{s} in the
51 | % declaration of \tcode{__range}.}
52 | %
53 | %\begin{ncbnf}
54 | % \terminal{(} expression \terminal{)}
55 | %\end{ncbnf}
56 | %
57 | %and for a range-based \tcode{for} statement of the form
58 | %
59 | %\begin{ncbnf}
60 | % \terminal{for} \terminal{\added{co_await\opt{}}} \terminal{(} for-range-declaration \terminal{:} braced-init-list \terminal{)} statement
61 | %\end{ncbnf}
62 | %
63 | %let \textit{range-init} be equivalent to the \grammarterm{braced-init-list}. In each case, a
64 | %range-based \tcode{for} statement
65 | is equivalent to
66 |
67 | %\begin{codeblock}
68 | % {
69 | % auto && __range = @\textit{for-range-initializer}@;
70 | % for ( auto __begin = @\added{\tcode{co_await}\opt{}}@ begin-expr,
71 | % __end = end-expr;
72 | % __begin != __end;
73 | % @\added{\tcode{co_await}\opt{}}@ ++__begin ) {
74 | % @\textit{for-range-declaration}@ = *__begin;
75 | % @\textit{statement}@
76 | % }
77 | % }
78 | %\end{codeblock}
79 |
80 | \begin{ncbnftab}
81 | \terminal{\{}\br
82 | \>\terminal{auto \&\&__range =} for-range-initializer \terminal{;}\br
83 | \>\terminal{auto __begin =} \terminal{\added{co_await\opt{}}} begin-expr \terminal{;}\br
84 | \>\terminal{auto __end =} end-expr \terminal{;}\br
85 | \>\terminal{for ( ; __begin != __end; \terminal{\added{co_await\opt{}}} ++__begin ) \{}\br
86 | \>\>for-range-declaration \terminal{= *__begin;}\br
87 | \>\>statement\br
88 | \>\terminal{\}}\br
89 | \terminal{\}}
90 | \end{ncbnftab}
91 | \end{quote}
92 |
93 | Insert a new bullet after paragraph 1 bullet 1.
94 |
95 | \begin{quote}
96 | \begin{itemize}
97 | \item
98 | if the \grammarterm{for-range-initializer} is an \grammarterm{expression},
99 | it is regarded as if it were surrounded by parentheses (so that a comma operator
100 | cannot be reinterpreted as delimiting two \grammarterm{init-declarator}{s});
101 | \item \added{\tcode{co_await} is present if and only if it appears immediately after the \tcode{for} keyword;}
102 | \item \tcode{__range}, \tcode{__begin}, and \tcode{__end} are variables defined for
103 | exposition only; and ...
104 | \end{itemize}
105 | \end{quote}
106 |
107 | %\tcode{\added{co_await}}\added{ is present if and only if it appears immediately after the \tcode{for} keyword, and}\linebreak
108 | %\tcode{__range}, \tcode{__begin}, and \tcode{__end} are variables defined for
109 | %exposition only, and \tcode{_RangeT} is the type of the
110 | %\grammarterm{}{expression}, and \textit{begin-expr} and \textit{end-expr} are
111 | %determined as follows: ...
112 |
113 | %\ednote{The remainder of paragraph 1 remains unchanged and is not included here.}
114 |
115 |
116 |
117 | Add the following paragraph after paragraph 2.
118 |
119 | \begin{quote}
120 | \setcounter{Paras}{2}
121 | \pnum
122 | A range-based \tcode{for} statement with \tcode{co_await} shall appear only within a suspension context of a function (\ref{expr.await}).
123 | \end{quote}
124 | %\setcounter{subsection}{4}
125 | %\rSec2[stmt.for.await]{The \tcode{cofor} statement}%
126 | %
127 | %Add this section to \ref{stmt.iter}.
128 | %
129 | %
130 | %\begin{quote}
131 | %\pnum
132 | %A \tcode{cofor} statement of the form
133 | %
134 | %\begin{ncbnf}
135 | % \terminal{cofor (} for-range-declaration : expression \terminal{)} statement
136 | %\end{ncbnf}
137 | %is equivalent to
138 | %
139 | %\begin{codeblock}
140 | % {
141 | % auto && __range = range-init;
142 | % for ( auto __begin = co_await begin-expr,
143 | % + __end = end-expr;
144 | % __begin != __end;
145 | % co_await ++__begin ) {
146 | % @\textit{for-range-declaration}@ = *__begin;
147 | % @\textit{statement}@
148 | % }
149 | % }
150 | %\end{codeblock}
151 | %
152 | %where \tcode{__range}, \tcode{__begin}, \tcode{__end},
153 | %\textit{range-init}, \textit{begin-expr}, and \textit{end-expr} are defined as in the range-based \tcode{for} statement (\cxxref{stmt.ranged}).
154 | %
155 | %\end{quote}
156 | \pagebreak
157 | \setcounter{section}{5}
158 | \rSec1[stmt.jump]{Jump statements}%
159 |
160 | %In paragraph 1 add two productions to the grammar:
161 | Add \grammarterm{coroutine-return-statement} to the grammar production \grammarterm{jump-statement}:
162 |
163 | \begin{quote}
164 | \begin{bnf}
165 | \nontermdef{jump-statement}\br
166 | \terminal{break ;}\br
167 | \terminal{continue ;}\br
168 | \terminal{return} expr-braced-init-list\opt \terminal{;}\br
169 | \added{coroutine-return-statement} \br
170 | \terminal{goto} identifier \terminal{;}
171 | \end{bnf}
172 | \end{quote}
173 |
174 | Add the underlined text to paragraph 2:
175 |
176 | \begin{quote}
177 | \setcounter{Paras}{1}
178 | \pnum
179 | On exit from a scope (however accomplished), objects with automatic storage
180 | duration~(\cxxref{basic.stc.auto}) that have been constructed in that scope are destroyed
181 | in the reverse order of their construction.
182 | \added{
183 | \enternote
184 | A suspension of a coroutine (\ref{expr.await}) is not considered to be an exit from a scope.
185 | \exitnote
186 | }
187 | ...
188 | \end{quote}
189 |
190 | \setcounter{subsection}{2}
191 | \rSec2[stmt.return]{The \tcode{return} statement}%
192 | \indextext{\idxcode{return}}%
193 | \indextext{function~return|see{\tcode{return}}}%
194 |
195 | %Add the underlined text to paragraph 1:
196 | %
197 | %\begin{quote}
198 | %\pnum
199 | %A function returns to its caller by the \tcode{return} statement\added{; that function shall not be a coroutine (\ref{dcl.fct.def.coroutine}).}
200 | %\added{A return statement shall not appear in a coroutine. A coroutine return statement shall be used instead \ref{stmt.return.coroutine}.}
201 | %\added{In this section, function refers to a function that is not a coroutine. The \tcode{return} statement in a coroutine described in section \ref{stmt.return.coroutine}.}
202 | % \added{A \tcode{return} statement shall not appear in a coroutine.}
203 | %\added{Using a \tcode{return} statement in a coroutine makes the program ill-formed.}
204 | %\end{quote}
205 |
206 | Add the underlined text to paragraph 2:
207 |
208 | \begin{quote}
209 | \setcounter{Paras}{1}
210 | \pnum ... Flowing off the end of
211 | a constructor,
212 | a destructor, or
213 | a function \added{that is not a coroutine} with a \cv{}~\tcode{void} return type is
214 | equivalent to a \tcode{return} with no operand. Otherwise, flowing off the end of a function other than main (\cxxref{basic.start.main}) \added{or a coroutine (\ref{dcl.fct.def.coroutine})}
215 | results in undefined behavior.
216 | \end{quote}
217 |
218 | %NOTE
219 |
220 | %Add a note:
221 | %
222 | %\begin{quote}
223 | %\enternote
224 | %In this section a function refers to non-coroutines only.
225 | %The return statement in coroutines is described in \ref{stmt.return.coroutine}
226 | %\exitnote
227 | %\end{quote}
228 |
229 | %Modify paragraphs 1 through 3 as follows.
230 | %
231 | %\begin{quote}
232 | %\pnum
233 | %A function returns to its caller by the \tcode{return} statement.
234 | %\added{A coroutine also returns to its caller
235 | %when suspended at suspend-resume point.}
236 | %
237 | %\pnum
238 | %\added{In a non-coroutine a}\removed{A} return statement
239 | %with neither an \grammarterm{expression} nor a \grammarterm{braced-init-list}
240 | %can be used only in functions
241 | %that do not return a value, that is, a function with the return type
242 | %\cv\ \tcode{void}, a constructor~(\cxxref{class.ctor}), or a
243 | %destructor~(\cxxref{class.dtor}).
244 | %\indextext{\idxcode{return}!constructor~and}%
245 | %\indextext{\idxcode{return}!constructor~and}%
246 | %\added{In a coroutine a return statement
247 | % with neither an \grammarterm{expression} nor a \grammarterm{braced-init-list}
248 | % can be used only in functions
249 | % with eventual return type \tcode{void}.}
250 | %A return statement with an expression of non-void type can be used only
251 | %in \added{non-coroutine} functions returning a value
252 | %\added{or coroutines returning an eventual value}; the value of the expression is returned
253 | %to the caller of the function.
254 | %\indextext{conversion!return~type}%
255 | %The value of the expression is implicitly converted to the return type of the
256 | %function in which it appears. A return statement can involve the
257 | %construction and copy or move of a temporary object~(\cxxref{class.temporary}).
258 | %\enternote
259 | %A copy or move operation associated with a return statement may be elided or
260 | %considered as an rvalue for the purpose of overload resolution in
261 | %selecting a constructor~(\cxxref{class.copy}).
262 | %\exitnote A return statement with a \grammarterm{braced-init-list} initializes the object or reference to be returned from the function by copy-list-initialization~(\cxxref{dcl.init.list}) from the specified initializer list. \enterexample
263 | %
264 | %\begin{codeblock}
265 | % std::pair f(const char* p, int x) {
266 | % return {p,x};
267 | % }
268 | %\end{codeblock}
269 | %\exitexample
270 | %
271 | %Flowing off the end of a function is equivalent to a \tcode{return} with
272 | %no value; this results in undefined behavior in a value-returning
273 | %\added{non-coroutine} function \added{or in an eventual-value-returning coroutine}.
274 | %
275 | %\pnum
276 | %A return statement with an expression of type \tcode{void}
277 | %can be used only in \added{non-coroutine} functions with a return type of
278 | %\cvqual{cv} \tcode{void} \added{or coroutines with eventual return type of \tcode{void}};
279 | %the expression is evaluated just before the function
280 | %returns to its caller.
281 | %\end{quote}
282 | %
283 | %%Add underlined text to paragraph 1:
284 | %%\pnum
285 | %%A function returns to its caller by the \tcode{return} statement
286 | %%\added{or by reaching suspend-resume-point}.
287 | %
288 | %Add paragraph 4.
289 | %
290 | %\begin{quote}
291 | %\setcounter{Paras}{3}
292 | %\pnum
293 | %In a coroutine return statement is replaced with
294 | %a call to __pr.set_result, where _p
295 | %\end{quote}
296 |
297 | \rSec3[stmt.return.coroutine]{The \tcode{co_return} statement}%
298 |
299 | Add this subclause to \ref{stmt.return}.
300 |
301 | \begin{quote}
302 | %\enternote
303 | %In this section function refers to coroutine only.
304 | %The return statement in non-coroutines is described in \ref{stmt.return}
305 | %\exitnote
306 |
307 | \begin{bnf}
308 | \nontermdef{coroutine-return-statement}\br
309 | \terminal{co_return} expr-or-braced-init-list\opt \terminal{;}\br
310 | \end{bnf}
311 |
312 | \pnum
313 | A coroutine returns to its caller or resumer (\ref{dcl.fct.def.coroutine}) by the \tcode{co_return} statement
314 | or when suspended (\ref{expr.await}). A coroutine shall not return to its caller or resumer by a \tcode{return} statement (\ref{stmt.return}).
315 |
316 | \pnum
317 | The \grammarterm{expr-braced-init-list} of a \tcode{co_return} statement is called its operand.
318 | Let $p$ be an lvalue naming the coroutine promise object (\ref{dcl.fct.def.coroutine}) and $P$ be the type of that object,
319 | then a \tcode{co_return} statement is equivalent to:
320 |
321 | %Let $P$ be the coroutine promise type (\ref{dcl.fct.def.coroutine}) and $p$ be an lvalue naming the coroutine promise object (\ref{dcl.fct.def.coroutine}),
322 |
323 | %the the \grammarterm{unqualified-id}{s}
324 | %\tcode{return_void} and \tcode{return_value} are looked up in the scope of class $P$.
325 | %If both are found, the program is ill-formed. If none are found, the coroutine does not have an eventual return type.
326 | %If \tcode{return_void} was found, the coroutine has an eventual return type of \tcode{void}.
327 | %If \tcode{return_value} was found, the coroutine has non-void eventual return type.
328 | %\pnum
329 |
330 | \begin{codeblock}
331 | { @$S$@; goto @$final{\_}suspend$@; }
332 | \end{codeblock}
333 |
334 | where $final$\tcode{\_}$suspend$ is as defined in \ref{dcl.fct.def.coroutine} and $S$ is defined as follows:
335 |
336 | \begin{itemize}
337 | \item $S$ is $p$\tcode{.return_value(}\grammarterm{expr-or-braced-init-list}{}\tcode{)}, if the operand is a \grammarterm{braced-init-list} or an expression of non-\tcode{void} type;
338 | % \item $S$ is $p$\tcode{.return_value(}\grammarterm{expression}{}\tcode{)}, if the operand is an expression of non-\tcode{void} type;
339 | \item $S$ is \tcode{\{}{ }\grammarterm{expression}\opt \tcode{;} $p$\tcode{.return_void()}\tcode{;{ }\}}, otherwise;
340 | \end{itemize}
341 | $S$ shall be a prvalue of type \tcode{void}.
342 |
343 | \pnum
344 | If $p$\tcode{.return_void()} is a valid expression, flowing off the end of a coroutine is equivalent to a \tcode{co_return} with no operand; otherwise flowing off the end of a coroutine results in undefined behavior.
345 | %If none are found, the coroutine does not have an eventual return type.
346 | % $expression$ is treated as an xvalue;
347 |
348 | % this is fishy ^^^^
349 |
350 | %\enternote
351 | %If coroutine instance lifetime is controlled
352 | %by a RAII object, it is expected that \tcode{_Pr.final_suspend()} returns true
353 | %and coroutine state will be destroyed when
354 | %destructor of an owner object runs.
355 | %
356 | %For detached tasks, where lifetime of the coroutine ends
357 | %when the task completes, \tcode{_Pr.final_suspend()} would return false.
358 | %\exitnote
359 |
360 | \end{quote}
361 |
362 | %\rSec2[stmt.yield]{The \tcode{yield} statement}%
363 | %
364 | %Add this section to \ref{stmt.jump}.
365 | %
366 | %\begin{quote}
367 | %
368 | %Let \textit{yielded value} be the operand of the \tcode{co_yield} statement and \textit{p} be the promise object of the enclosing coroutine.
369 | %If the result type of \tcode{\textit{p}.yield_value(\textit{yielded-value})} is of type \cvvoid, then the \tcode{co_yield} statement is equivalent to:
370 | %
371 | %\begin{codeblock}
372 | % @\textit{p}@.yield_value(@\textit{yielded-value}@);
373 | % @\textit{suspend-resume-point}
374 | %\end{codeblock}
375 | %
376 | %otherwise, it is equivalent to:
377 | %
378 | %\begin{codeblock}
379 | % if (@\textit{p}@.yield_value(@\textit{yielded-value}@)) {
380 | % @\textit{suspend-resume-point}@
381 | % }
382 | %
383 | %\end{codeblock}
384 |
385 | %\pnum
386 | %A \tcode{co_yield} statement may only appear if a \tcode{yield_value} member
387 | %function is defined in the promise type of the enclosing coroutine.
388 |
389 | %NOTE: not pretty, can we remove the duplication
390 | %NOTE: make if first
391 | %
392 | %\pnum
393 | %\enternote
394 | %A promise object may have more than one overload of a \tcode{yield_value}.
395 | %
396 | %\enterexample
397 | %\begin{codeblock}
398 | % recursive_generator flatten(node* n)
399 | % {
400 | % if (n == nullptr)
401 | % return;
402 | %
403 | % co_yield flatten(n->left);
404 | % co_yield n->value;
405 | % co_yield flatten(n->right);
406 | % }
407 | %\end{codeblock}
408 | %
409 | %The promise for the \tcode{flatten} function should contain overloads that can accept a value of type \tcode{int} and a value of type \tcode{recursive_generator}.
410 | %In the former case, yielding a value is unconditional. In the latter case, the nested generator may produce an empty sequence of values and thus suspension at the yield point no yielding occurs and \tcode{yield_value} should return \tcode{false}.
411 | %\exitexample
412 | %\exitnote
413 |
414 | %\end{quote}
--------------------------------------------------------------------------------
/Coroutines/styles.tex:
--------------------------------------------------------------------------------
1 | %!TEX root = std.tex
2 | %% styles.tex -- set styles for:
3 | % chapters
4 | % pages
5 | % footnotes
6 |
7 | %%--------------------------------------------------
8 | %% create chapter style
9 |
10 | \makechapterstyle{cppstd}{%
11 | \renewcommand{\beforechapskip}{\onelineskip}
12 | \renewcommand{\afterchapskip}{\onelineskip}
13 | \renewcommand{\chapternamenum}{}
14 | \renewcommand{\chapnamefont}{\chaptitlefont}
15 | \renewcommand{\chapnumfont}{\chaptitlefont}
16 | \renewcommand{\printchapternum}{\chapnumfont\thechapter\quad}
17 | \renewcommand{\afterchapternum}{}
18 | }
19 |
20 | %%--------------------------------------------------
21 | %% create page styles
22 |
23 | \makepagestyle{cpppage}
24 | \makeevenhead{cpppage}{\copyright\,\textsc{ISO/IEC}}{}{\textbf{\docno}}
25 | \makeoddhead{cpppage}{\copyright\,\textsc{ISO/IEC}}{}{\textbf{\docno}}
26 | \makeevenfoot{cpppage}{\leftmark}{}{\thepage}
27 | \makeoddfoot{cpppage}{\leftmark}{}{\thepage}
28 | %\makeevenfoot{cpppage}{}{}{\thepage}
29 | %\makeoddfoot{cpppage}{}{}{\thepage}
30 |
31 | \makeatletter
32 | \makepsmarks{cpppage}{%
33 | \let\@mkboth\markboth
34 | \def\chaptermark##1{\markboth{##1}{##1}}%
35 | \def\sectionmark##1{\markboth{%
36 | \ifnum \c@secnumdepth>\z@
37 | \textsection\space\thesection
38 | \fi
39 | }{\rightmark}}%
40 | \def\subsectionmark##1{\markboth{%
41 | \ifnum \c@secnumdepth>\z@
42 | \textsection\space\thesubsection
43 | \fi
44 | }{\rightmark}}%
45 | \def\subsubsectionmark##1{\markboth{%
46 | \ifnum \c@secnumdepth>\z@
47 | \textsection\space\thesubsubsection
48 | \fi
49 | }{\rightmark}}%
50 | \def\paragraphmark##1{\markboth{%
51 | \ifnum \c@secnumdepth>\z@
52 | \textsection\space\theparagraph
53 | \fi
54 | }{\rightmark}}}
55 | \makeatother
56 |
57 | \aliaspagestyle{chapter}{cpppage}
58 |
59 | %%--------------------------------------------------
60 | %% set heading styles for main matter
61 | \newcommand{\beforeskip}{-.7\onelineskip plus -1ex}
62 | \newcommand{\afterskip}{.3\onelineskip minus .2ex}
63 |
64 | \setbeforesecskip{\beforeskip}
65 | \setsecindent{0pt}
66 | \setsecheadstyle{\large\bfseries\raggedright}
67 | \setaftersecskip{\afterskip}
68 |
69 | \setbeforesubsecskip{\beforeskip}
70 | \setsubsecindent{0pt}
71 | \setsubsecheadstyle{\large\bfseries\raggedright}
72 | \setaftersubsecskip{\afterskip}
73 |
74 | \setbeforesubsubsecskip{\beforeskip}
75 | \setsubsubsecindent{0pt}
76 | \setsubsubsecheadstyle{\normalsize\bfseries\raggedright}
77 | \setaftersubsubsecskip{\afterskip}
78 |
79 | \setbeforeparaskip{\beforeskip}
80 | \setparaindent{0pt}
81 | \setparaheadstyle{\normalsize\bfseries\raggedright}
82 | \setafterparaskip{\afterskip}
83 |
84 | \setbeforesubparaskip{\beforeskip}
85 | \setsubparaindent{0pt}
86 | \setsubparaheadstyle{\normalsize\bfseries\raggedright}
87 | \setaftersubparaskip{\afterskip}
88 |
89 | %%--------------------------------------------------
90 | % set heading style for annexes
91 | \newcommand{\Annex}[3]{\chapter[#2]{(#3)\protect\\#2\hfill[#1]}\relax\label{#1}}
92 | \newcommand{\infannex}[2]{\Annex{#1}{#2}{informative}}
93 | \newcommand{\normannex}[2]{\Annex{#1}{#2}{normative}}
94 |
95 | %%--------------------------------------------------
96 | %% set footnote style
97 | \footmarkstyle{\smaller#1) }
98 |
99 | %%--------------------------------------------------
100 | % set style for main text
101 | \setlength{\parindent}{0pt}
102 | \setlength{\parskip}{1ex}
103 | \setlength{\partopsep}{-1.5ex}
104 |
105 | %%--------------------------------------------------
106 | %% set caption style and delimiter
107 | \captionstyle{\centering}
108 | \captiondelim{ --- }
109 | % override longtable's caption delimiter to match
110 | \makeatletter
111 | \def\LT@makecaption#1#2#3{%
112 | \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
113 | \sbox\@tempboxa{#1{#2 --- }#3}%
114 | \ifdim\wd\@tempboxa>\hsize
115 | #1{#2 --- }#3%
116 | \else
117 | \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
118 | \fi
119 | \endgraf\vskip\baselineskip}%
120 | \hss}}}
121 | \makeatother
122 |
123 | %%--------------------------------------------------
124 | %% set global styles that get reset by \mainmatter
125 | \newcommand{\setglobalstyles}{
126 | \counterwithout{footnote}{chapter}
127 | \counterwithout{table}{chapter}
128 | \counterwithout{figure}{chapter}
129 | \renewcommand{\chaptername}{}
130 | \renewcommand{\appendixname}{Annex }
131 | }
132 |
133 | %%--------------------------------------------------
134 | %% change list item markers to number and em-dash
135 |
136 | \renewcommand{\labelitemi}{---\parabullnum{Bullets1}{\labelsep}}
137 | \renewcommand{\labelitemii}{---\parabullnum{Bullets2}{\labelsep}}
138 | \renewcommand{\labelitemiii}{---\parabullnum{Bullets3}{\labelsep}}
139 | \renewcommand{\labelitemiv}{---\parabullnum{Bullets4}{\labelsep}}
140 |
141 | %%--------------------------------------------------
142 | %% set section numbering limit, toc limit
143 | \maxsecnumdepth{subparagraph}
144 | \setcounter{tocdepth}{1}
145 |
--------------------------------------------------------------------------------
/Coroutines/support.tex:
--------------------------------------------------------------------------------
1 |
2 | %\setcounter{chapter}{17}
3 | \rSec0[language.support]{Language support library}
4 |
5 | \rSec1[support.general]{General}
6 |
7 | Add a row to Table~\ref{tab:lang.sup.lib.summary} for coroutine support header \tcode{}.
8 |
9 | \setcounter{table}{31}
10 | \begin{libsumtab}{Language support library summary}{tab:lang.sup.lib.summary}
11 | \cxxref{support.types} & Types & \tcode{} \\ \rowsep
12 | & & \tcode{} \\
13 | \cxxref{support.limits} & Implementation properties & \tcode{} \\
14 | & & \tcode{} \\ \rowsep
15 | \cxxref{cstdint} & Integer types & \tcode{} \\ \rowsep
16 | \cxxref{support.start.term} & Start and termination & \tcode{} \\ \rowsep
17 | \cxxref{support.dynamic} & Dynamic memory management & \tcode{} \\ \rowsep
18 | \cxxref{support.rtti} & Type identification & \tcode{} \\ \rowsep
19 | \cxxref{support.exception} & Exception handling & \tcode{} \\ \rowsep
20 | \cxxref{support.initlist} & Initializer lists & \tcode{} \\ \rowsep
21 | & & \tcode{} \\
22 | & & \tcode{} \\
23 | & & \tcode{} \\
24 | \cxxref{support.runtime} & Other runtime support & \tcode{} \\
25 | & & \tcode{} \\
26 | & & \tcode{} \\
27 | & & \tcode{} \\ \rowsep
28 | \added{\ref{support.coroutine}}
29 | & \added{Coroutines support}
30 | & \added{\tcode{}} \\
31 |
32 | \end{libsumtab}
33 |
34 |
35 | \setcounter{section}{10}
36 | \setcounter{subsection}{1}
37 | \rSec2[csetjmp.syn]{Header \tcode{} synopsis}
38 |
39 | Add underlined text to paragraph 2.
40 |
41 | \begin{quote}
42 | \setcounter{Paras}{3}
43 | \pnum
44 | The function signature
45 | \indexlibrary{\idxcode{longjmp}}%
46 | \tcode{longjmp(jmp_buf jbuf, int val)}
47 | has more restricted behavior in this International Standard.
48 | A \tcode{setjmp}/\tcode{longjmp} call pair has undefined
49 | behavior if replacing the \tcode{setjmp} and \tcode{longjmp}
50 | by \tcode{catch} and \tcode{throw} would invoke any non-trivial destructors for any automatic
51 | objects.
52 | %
53 | \added{A call to \tcode{setjmp} or \tcode{longjmp} has undefined
54 | behavior if invoked in a suspension context of a coroutine (\ref{expr.await}).}
55 |
56 | \xref ISO C~7.13.
57 | \end{quote}
58 |
59 | \setcounter{section}{10}
60 | \rSec1[support.coroutine]{Coroutines support library}
61 |
62 | Add this subclause to Clause \ref{language.support}.
63 |
64 | \begin{quote}
65 |
66 | \pnum
67 | The header
68 | \tcode{}
69 | defines several types providing compile and run-time support for coroutines in a \Cpp program.
70 |
71 | \synopsis{Header \tcode{} synopsis}
72 |
73 | \indextext{\idxhdr{coroutine}}%
74 | \indexlibrary{\idxhdr{coroutine}}%
75 | \begin{codeblock}
76 | namespace std {
77 | namespace experimental {
78 | inline namespace coroutines_v1 {
79 |
80 | // \ref{coroutine.traits} coroutine traits
81 | template
82 | struct coroutine_traits;
83 |
84 | // \ref{coroutine.handle} coroutine handle
85 | template
86 | struct coroutine_handle;
87 |
88 | // \ref{coroutine.promise.noop} noop coroutine promise
89 | struct noop_coroutine_promise;
90 | template <> struct coroutine_handle;
91 | // noop coroutine handle
92 | using noop_coroutine_handle = coroutine_handle;
93 |
94 | // \ref{coroutine.noop} noop coroutine
95 | noop_coroutine_handle noop_coroutine() noexcept;
96 |
97 | // \ref{coroutine.handle.compare} comparison operators:
98 | constexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept;
99 | constexpr bool operator!=(coroutine_handle<> x, coroutine_handle<> y) noexcept;
100 | constexpr bool operator<(coroutine_handle<> x, coroutine_handle<> y) noexcept;
101 | constexpr bool operator>(coroutine_handle<> x, coroutine_handle<> y) noexcept;
102 | constexpr bool operator<=(coroutine_handle<> x, coroutine_handle<> y) noexcept;
103 | constexpr bool operator>=(coroutine_handle<> x, coroutine_handle<> y) noexcept;
104 |
105 | // \ref{coroutine.trivial.awaitables} trivial awaitables
106 | struct suspend_never;
107 | struct suspend_always;
108 |
109 | } // namespace coroutines_v1
110 | } // namespace experimental
111 |
112 | // \ref{coroutine.handle.hash} hash support:
113 | template struct hash;
114 | template struct hash>;
115 |
116 | } // namespace std
117 | \end{codeblock}
118 |
119 | \rSec2[coroutine.traits]{Coroutine traits}
120 | \pnum
121 | This subclause defines requirements on classes representing
122 | \term{coroutine traits},
123 | and defines the class template
124 | \tcode{coroutine_traits}
125 | that satisfies those requirements.
126 |
127 | %\pnum
128 | %Coroutines need a set of related types and functions
129 | %to complete the definition of their semantics.
130 | %These types and functions are provided as a set of member types or typedefs
131 | %and functions in the instantiation of struct template
132 | %\tcode{coroutine_traits}. This subclause defines the semantics of these
133 | %members.
134 |
135 | %\removed{\pnum
136 | %Users may specialize \tcode{coroutine_traits}
137 | %to customize the semantics of coroutines.}
138 |
139 | %\rSec3[coroutine.traits.requirements]{Coroutine traits requirements}
140 | %\pnum
141 | %In Table~\ref{tab:coroutine.traits.requirements}, X denotes
142 | %a trait class instantiated as described in \ref{dcl.fct.def.coroutine}.
143 | %
144 | %;
145 | %If a coroutine is a member function, then $a_1$ denotes the implicit \tcode{this} parameter, $a_2$, ... $a_n$ refer to explicit parameters of the coroutine, otherwise, $a_1$, $a_2$, ... $a_n$ denote the parameters of the coroutine.
146 | %
147 | %\begin{concepttable}{Coroutine traits requirements}{tab:coroutine.traits.requirements}
148 | % {p{1.6in}p{4.15in}}
149 | % \topline
150 | % Expression & Behavior \\ \capsep
151 | % \tcode{X::promise_type} &
152 | % \tcode{X::promise_type} must be a type satisfying coroutine promise requirements (\ref{coroutine.promise})
153 | %\\
154 | %\end{concepttable}
155 |
156 | \rSec3[coroutine.traits.primary]{Class template \tcode{coroutine_traits}}
157 | \pnum The header \tcode{} defines
158 | the primary template \tcode{coroutine_traits} such that
159 | if \tcode{ArgTypes} is a parameter pack of types and
160 | if the \grammarterm{qualified-id} \tcode{R::promise_type} is valid and
161 | denotes a type (\cxxref{temp.deduct}),
162 | then
163 | \tcode{coroutine_traits} has the following publicly accessible member:
164 |
165 | \begin{codeblock}
166 | using promise_type = typename R::promise_type;
167 | \end{codeblock}
168 |
169 | Otherwise, \tcode{coroutine_traits} has no members.
170 |
171 | \pnum Program defined specializations of this template shall define a publicly accessible nested type named \tcode{promise_type}.
172 |
173 | %\pnum A user specialization of \tcode{coroutine_traits} shall have a valid member type \tcode{promise_type}.
174 |
175 | \rSec2[coroutine.handle]{Class template \tcode{coroutine_handle}}
176 |
177 | \indexlibrary{\idxcode{coroutine_handle}}%
178 | \begin{codeblock}
179 | namespace std {
180 | namespace experimental {
181 | inline namespace coroutines_v1 {
182 |
183 | template <>
184 | struct coroutine_handle
185 | {
186 | // \ref{coroutine.handle.con} construct/reset
187 | constexpr coroutine_handle() noexcept;
188 | constexpr coroutine_handle(nullptr_t) noexcept;
189 | coroutine_handle& operator=(nullptr_t) noexcept;
190 |
191 | // \ref{coroutine.handle.export.import} export/import
192 | constexpr void* address() const noexcept;
193 | constexpr static coroutine_handle from_address(void* addr);
194 |
195 | // \ref{coroutine.handle.observers} observers
196 | constexpr explicit operator bool() const noexcept;
197 | bool done() const;
198 |
199 | // \ref{coroutine.handle.resumption} resumption
200 | void operator()() const;
201 | void resume() const;
202 | void destroy() const;
203 |
204 | private:
205 | void* ptr; // exposition only
206 | };
207 |
208 | template
209 | struct coroutine_handle : coroutine_handle<>
210 | {
211 | // \ref{coroutine.handle.con} construct/reset
212 | using coroutine_handle<>::coroutine_handle;
213 | static coroutine_handle from_promise(Promise&);
214 | coroutine_handle& operator=(nullptr_t) noexcept;
215 |
216 | // \ref{coroutine.handle.export.import} export/import
217 | constexpr static coroutine_handle from_address(void* addr);
218 |
219 | // \ref{coroutine.handle.promise} promise access
220 | Promise& promise() const;
221 | };
222 |
223 | template <> struct coroutine_handle : coroutine_handle<>
224 | {
225 | // \ref{coroutine.handle.noop.observers} noop observers
226 | constexpr explicit operator bool() const noexcept;
227 | constexpr bool done() const noexcept;
228 |
229 | // \ref{coroutine.handle.noop.resumption} noop resumption
230 | constexpr void operator()() const noexcept;
231 | constexpr void resume() const noexcept;
232 | constexpr void destroy() const noexcept;
233 |
234 | // \ref{coroutine.handle.noop.promise} noop promise access
235 | noop_coroutine_promise& promise() const noexcept;
236 |
237 | // \ref{coroutine.handle.noop.address} noop address
238 | constexpr void* address() const noexcept;
239 | private:
240 | coroutine_handle(@\textit{unspecified}@);
241 | };
242 |
243 | } // namespace coroutines_v1
244 | } // namespace experimental
245 | } // namespace std
246 | \end{codeblock}
247 |
248 | \pnum
249 | Let \textit{P} be the promise type of a coroutine (\ref{dcl.fct.def.coroutine}). An object of type \tcode{coroutine_handle<\textit{P}>} is called a \term{coroutine handle}
250 | and can be used to refer to a suspended or executing coroutine.
251 | A default constructed \tcode{coroutine_handle} object does not refer to any coroutine.
252 |
253 | \pnum If a program declares an explicit or partial specialization of \tcode{coroutine_handle}, the behavior is undefined.
254 |
255 | %Such a function is called a \textit{target} of a coroutine handle.
256 | %A default constructed \tcode{coroutine_handle} object has no target.
257 |
258 |
259 | \rSec3[coroutine.handle.con]{\tcode{coroutine_handle} construct/reset}
260 | \begin{itemdecl}
261 | constexpr coroutine_handle() noexcept;
262 | constexpr coroutine_handle(nullptr_t) noexcept;
263 | \end{itemdecl}
264 | \begin{itemdescr}
265 | \pnum\postconditions \tcode{address() == nullptr}.
266 | \end{itemdescr}
267 |
268 | \begin{itemdecl}
269 | static coroutine_handle from_promise(Promise& p);
270 | \end{itemdecl}
271 | \begin{itemdescr}
272 | \pnum
273 | \precondition \tcode{p} is a reference to a promise object of a coroutine.
274 |
275 | \pnum
276 | \returns A coroutine handle $h$ referring to the coroutine.
277 |
278 | \pnum\postconditions \tcode{addressof(}$h$\tcode{.promise()) == addressof(p)}.
279 | \end{itemdescr}
280 |
281 | \begin{itemdecl}
282 | coroutine_handle& operator=(nullptr_t) noexcept;
283 | \end{itemdecl}
284 | \begin{itemdescr}
285 | \pnum\postconditions \tcode{address() == nullptr}.
286 |
287 | \pnum\returns \tcode{*this}.
288 | \end{itemdescr}
289 |
290 | \rSec3[coroutine.handle.export.import]{\tcode{coroutine_handle} export/import}
291 |
292 | \begin{itemdecl}
293 | constexpr void* address() const noexcept;
294 | \end{itemdecl}
295 |
296 | \begin{itemdescr}
297 | \pnum
298 | \returns \tcode{ptr}.
299 | \end{itemdescr}
300 |
301 |
302 | \begin{itemdecl}
303 | constexpr static coroutine_handle<> coroutine_handle<>::from_address(void* addr);
304 | constexpr static coroutine_handle coroutine_handle::from_address(void* addr);
305 | \end{itemdecl}
306 |
307 | \begin{itemdescr}
308 | \pnum
309 | \precondition \tcode{addr} was obtained via a prior call to \tcode{address}.
310 |
311 | \pnum
312 | \postconditions \tcode{from_address(address()) == *this}.
313 | \end{itemdescr}
314 |
315 | \rSec3[coroutine.handle.observers]{\tcode{coroutine_handle} observers}
316 | \begin{itemdecl}
317 | constexpr explicit operator bool() const noexcept;
318 | \end{itemdecl}
319 |
320 | \begin{itemdescr}
321 | \pnum
322 | \returns \tcode{address() != nullptr}.
323 | \end{itemdescr}
324 |
325 | \begin{itemdecl}
326 | bool done() const;
327 | \end{itemdecl}
328 | \begin{itemdescr}
329 | \pnum
330 | \precondition \tcode{*this} refers to a suspended coroutine.
331 |
332 | \pnum
333 | \returns \tcode{true} if the coroutine is suspended
334 | at its final suspend point, otherwise \tcode{false}.
335 | \end{itemdescr}
336 |
337 | \rSec3[coroutine.handle.resumption]{\tcode{coroutine_handle} resumption}
338 | \begin{itemdecl}
339 | void operator()() const;
340 | void resume() const;
341 | \end{itemdecl}
342 | \begin{itemdescr}
343 | \pnum
344 | \precondition \tcode{*this} refers to a suspended coroutine.
345 |
346 | \pnum
347 | \effects Resumes the execution of the coroutine. If the coroutine was suspended
348 | at its final suspend point, behavior is undefined.
349 |
350 | \pnum
351 | \enternote A concurrent resumption of the coroutine via \tcode{resume}, \tcode{operator()}, or \tcode{destroy} may result in a data race.
352 | \exitnote
353 | \end{itemdescr}
354 |
355 | \begin{itemdecl}
356 | void destroy() const;
357 | \end{itemdecl}
358 | \begin{itemdescr}
359 | \pnum
360 | \precondition \tcode{*this} refers to a suspended coroutine.
361 |
362 | \pnum
363 | \effects Destroys the coroutine (\ref{dcl.fct.def.coroutine}).
364 |
365 | \pnum
366 | \enternote A concurrent resumption of the coroutine via \tcode{resume}, \tcode{operator()}, or \tcode{destroy} may result in a data race.
367 | \exitnote
368 | \end{itemdescr}
369 |
370 | \rSec3[coroutine.handle.promise]{\tcode{coroutine_handle} promise access}
371 | \begin{itemdecl}
372 | Promise& promise() const;
373 | \end{itemdecl}
374 |
375 | \begin{itemdescr}
376 | \pnum
377 | \precondition \tcode{*this} refers to a coroutine.
378 |
379 | \pnum
380 | \returns A reference to the promise of the coroutine.
381 | \end{itemdescr}
382 |
383 | \rSec3[coroutine.handle.compare]{Comparison operators}
384 |
385 | \begin{itemdecl}
386 | constexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept;
387 | \end{itemdecl}
388 |
389 | \begin{itemdescr}
390 | \pnum
391 | \returns \tcode{x.address() == y.address()}.
392 | \end{itemdescr}
393 |
394 | \begin{itemdecl}
395 | constexpr bool operator!=(coroutine_handle<> x, coroutine_handle<> y) noexcept;
396 | \end{itemdecl}
397 |
398 | \begin{itemdescr}
399 | \pnum
400 | \returns \tcode{!(x == y)}.
401 | \end{itemdescr}
402 |
403 | \begin{itemdecl}
404 | constexpr bool operator<(coroutine_handle<> x, coroutine_handle<> y) noexcept;
405 | \end{itemdecl}
406 |
407 | \begin{itemdescr}
408 | \pnum
409 | \returns \tcode{less<>()(x.address(), y.address())}.
410 | \end{itemdescr}
411 |
412 | \begin{itemdecl}
413 | constexpr bool operator>(coroutine_handle<> x, coroutine_handle<> y) noexcept;
414 | \end{itemdecl}
415 |
416 | \begin{itemdescr}
417 | \pnum
418 | \returns \tcode{(y < x)}.
419 | \end{itemdescr}
420 |
421 | \begin{itemdecl}
422 | constexpr bool operator<=(coroutine_handle<> x, coroutine_handle<> y) noexcept;
423 | \end{itemdecl}
424 |
425 | \begin{itemdescr}
426 | \pnum
427 | \returns \tcode{!(x > y)}.
428 | \end{itemdescr}
429 |
430 | \begin{itemdecl}
431 | constexpr bool operator>=(coroutine_handle<> x, coroutine_handle<> y) noexcept;
432 | \end{itemdecl}
433 |
434 | \begin{itemdescr}
435 | \pnum
436 | \returns \tcode{!(x < y)}.
437 | \end{itemdescr}
438 |
439 | \rSec3[coroutine.handle.hash]{Hash support}
440 |
441 | \begin{itemdecl}
442 | template struct hash>;
443 | \end{itemdecl}
444 |
445 | \begin{itemdescr}
446 | \pnum
447 | %The template specialization shall meet the requirements of class template hash (\cxxref{unord.hash}).
448 | The specialization is enabled\iref{unord.hash}.
449 | \end{itemdescr}
450 |
451 | \rSec3[coroutine.handle.noop.observers]{\tcode{noop_coroutine_handle} observers}
452 | \begin{itemdecl}
453 | constexpr explicit operator bool() const noexcept;
454 | \end{itemdecl}
455 |
456 | \begin{itemdescr}
457 | \pnum
458 | \returns \tcode{true}.
459 | \end{itemdescr}
460 |
461 | \begin{itemdecl}
462 | constexpr bool done() const noexcept;
463 | \end{itemdecl}
464 |
465 | \begin{itemdescr}
466 | \pnum
467 | \returns \tcode{false}.
468 | \end{itemdescr}
469 |
470 | \rSec3[coroutine.handle.noop.resumption]{\tcode{noop_coroutine_handle} resumption}
471 | \begin{itemdecl}
472 | constexpr void operator()() const noexcept;
473 | constexpr void resume() const noexcept;
474 | constexpr void destroy() const noexcept;
475 | \end{itemdecl}
476 |
477 | \begin{itemdescr}
478 | \pnum
479 | \effects None.
480 |
481 | \pnum
482 | \remarks If \tcode{noop_coroutine_handle} is converted to \tcode{coroutine_handle<>}, calls to \tcode{operator()}, \tcode{resume} and \tcode{destroy} on that handle will also have no observable effects.
483 | \end{itemdescr}
484 |
485 | \rSec3[coroutine.handle.noop.promise]{\tcode{noop_coroutine_handle} promise access}
486 | \begin{itemdecl}
487 | noop_coroutine_promise& promise() const noexcept;
488 | \end{itemdecl}
489 |
490 | \begin{itemdescr}
491 | \pnum
492 | \returns A reference to the promise object associated with this coroutine handle.
493 | \end{itemdescr}
494 |
495 | \rSec3[coroutine.handle.noop.address]{\tcode{noop_coroutine_handle} address}
496 | \begin{itemdecl}
497 | constexpr void* address() const noexcept;
498 | \end{itemdecl}
499 |
500 | \begin{itemdescr}
501 | \pnum
502 | \returns \tcode{ptr}.
503 |
504 | \pnum
505 | \remarks A \tcode{noop_coroutine_handle}'s \tcode{ptr} is always a non-\tcode{null} pointer value.
506 | \end{itemdescr}
507 |
508 | \rSec2[coroutine.promise.noop]{Class \tcode{noop_coroutine_promise}}
509 | \begin{itemdecl}
510 | struct noop_coroutine_promise {};
511 | \end{itemdecl}
512 |
513 | \begin{itemdescr}
514 | \pnum The class \tcode{noop_coroutine_promise} defines the promise type for the coroutine referred to by \tcode{noop_coroutine_handle} (\ref{support.coroutine}).
515 | \end{itemdescr}
516 |
517 | \rSec2[coroutine.noop]{Function \tcode{noop_coroutine}}
518 |
519 | \begin{itemdecl}
520 | noop_coroutine_handle noop_coroutine() noexcept;
521 | \end{itemdecl}
522 |
523 | \begin{itemdescr}
524 | \pnum\returns A handle to a coroutine that has no observable effects when resumed or destroyed.
525 |
526 | \pnum\remarks A handle returned from \tcode{noop_coroutine} may or may not compare equal to a handle returned from another invocation of \tcode{noop_coroutine}.
527 | \end{itemdescr}
528 |
529 | \rSec2[coroutine.trivial.awaitables]{Trivial awaitables}
530 | The header \tcode{} defines \tcode{suspend_never} and \tcode{suspend_always} as follows.
531 | \begin{codeblock}
532 | namespace std {
533 | namespace experimental {
534 | inline namespace coroutines_v1 {
535 |
536 | struct suspend_never {
537 | constexpr bool await_ready() const noexcept { return true; }
538 | constexpr void await_suspend(coroutine_handle<>) const noexcept {}
539 | constexpr void await_resume() const noexcept {}
540 | };
541 | struct suspend_always {
542 | constexpr bool await_ready() const noexcept { return false; }
543 | constexpr void await_suspend(coroutine_handle<>) const noexcept {}
544 | constexpr void await_resume() const noexcept {}
545 | };
546 |
547 | } // namespace coroutines_v1
548 | } // namespace experimental
549 | } // namespace std
550 | \end{codeblock}
551 | \end{quote}
552 |
553 | %\rSec2[coroutine.promise]{Coroutine promise requirements}
554 | %
555 | %\pnum
556 | %A user supplies the definition of the coroutine promise to implement
557 | %desired high-level semantics associated with a coroutines
558 | %discovered via instantiation of class template \tcode{coroutine_traits}.
559 | %The following tables describe the requirements on
560 | %coroutine promise types.
561 | %
562 | %%\pnum
563 | %%The template struct \tcode{allocator_traits}~(\ref{allocator.traits}) supplies
564 | %%a uniform interface to all allocator types.
565 | %%Table~\ref{tab:desc.var.def} describes the types manipulated
566 | %%through allocators. Table~\ref{tab:utilities.allocator.requirements}
567 | %%describes the requirements on allocator types
568 | %%and thus on types used to instantiate \tcode{allocator_traits}. A requirement
569 | %%is optional if the last column of
570 | %Table~\ref{tab:utilities.allocator.requirements} specifies a default for a
571 | %%given expression. Within the standard library \tcode{allocator_traits}
572 | %%template, an optional requirement that is not supplied by an allocator is
573 | %%replaced by the specified default expression. A user specialization of
574 | %%\tcode{allocator_traits} may provide different defaults and may provide
575 | %%defaults for different requirements than the primary template. Within
576 | %%Tables~\ref{tab:desc.var.def} and~\ref{tab:utilities.allocator.requirements},
577 | %%the use of \tcode{move} and \tcode{forward} always refers to \tcode{std::move}
578 | %%and \tcode{std::forward}, respectively.
579 | %
580 | %\begin{libreqtab2}
581 | % {Descriptive variable definitions}
582 | % {tab:desc.var.def}
583 | % \\ \topline
584 | % \lhdr{Variable} & \rhdr{Definition} \\ \capsep
585 | % \endfirsthead
586 | % \continuedcaption\\
587 | % \hline
588 | % \lhdr{Variable} & \rhdr{Definition} \\ \capsep
589 | % \endhead
590 | % \tcode{Promise} & a coroutine promise type \\ \rowsep
591 | % \tcode{p} & a value of type \tcode{Promise} \\ \rowsep
592 | % \tcode{e} & a value of \tcode{exception_ptr} type \\ \rowsep
593 | % \tcode{h} & a value of \tcode{coroutine_handle} type \\ \rowsep
594 | % \tcode{v} & an \grammarterm{expression} or \grammarterm{braced-init-list} \\ \rowsep
595 | %\end{libreqtab2}
596 | %
597 | %\indextext{requirements!\idxcode{CoroutinePromise}}%
598 | %\begin{concepttable}{\tcode{CoroutinePromise} requirements}{CoroutinePromise}
599 | % {p{1.6in}p{4.15in}}
600 | % \topline
601 | % Expression & Note \\ \capsep
602 | % \tcode{Promise\{\}} & Construct an object of type \tcode{Promise}\\ \rowsep
603 | % \tcode{p.get_return_object()} &
604 | %The \tcode{get_return_object} is invoked by the coroutine to construct the
605 | %return object prior to reaching the first suspend-resume point,
606 | %a \tcode{return} statement, or flowing off the end of the function.
607 | % \\ \rowsep
608 | % \tcode{Promise::get_return_object_on_allocation_failure()} &
609 | % \textit{(Optional)} The \tcode{get_return_object_on_allocation_failure} is invoked by the coroutine to construct the
610 | % return object if allocation of the coroutine state failed.
611 | % \\ \rowsep
612 | % \tcode{p.return_value(v)} &
613 | %%If present, an enclosing coroutine supports an
614 | %%eventual value of a type that \tcode{v} can be converted to.
615 | %
616 | %\textit{(Optional)} Invoked by
617 | %a coroutine when
618 | %a \tcode{return} statement with an operand
619 | %is encountered in a coroutine as described in (\ref{stmt.return.coroutine}).
620 | %%If a promise type does not satisfy this requirement, the presence of
621 | %%a \tcode{coreturn} statement
622 | %%with an \grammarterm{expression}
623 | %%or a \grammarterm{braced-init-list}
624 | %%statement in the body results in a compile time error.
625 | % \\ \rowsep
626 | % \tcode{p.return_void()} &
627 | %%If present, an enclosing coroutine supports an eventual value of type \tcode{void}.
628 | %\textit{(Optional)} Invoked when
629 | %a \tcode{return} statement is encountered as described in (\ref{stmt.return.coroutine}).
630 | % \\ \rowsep
631 | % \tcode{p.set_exception(e)} &
632 | %\textit{(Optional)} If present, the \tcode{set_exception} is invoked by a coroutine when an
633 | %unhandled exception occurs within a \grammarterm{function-body} of the coroutine.
634 | %If the promise does not provide \tcode{set_exception}, an unhandled exception
635 | %will propagate from the coroutine normally.
636 | %\\ \rowsep
637 | % \tcode{p.yield_value(v)} &
638 | %\textit{(Optional)} The \tcode{yield_value} is invoked
639 | % when \tcode{co_yield} statement is
640 | % encountered in the coroutine. If
641 | % promise does not define \tcode{yield_value}, \tcode{co_yield}
642 | % statement shall not appear in the coroutine body.
643 | % \\ \rowsep
644 | % \tcode{p.initial_suspend()} &
645 | %A coroutine invokes \tcode{p.initial_suspend()} to obtain awaitable for \textit{initial suspend point} (\ref{dcl.fct.def.coroutine}).
646 | % \\ \rowsep
647 | % \tcode{p.final_suspend()} &
648 | %A coroutine invokes \tcode{p.final_suspend()} to obtain awaitable for \textit{final suspend point} (\ref{dcl.fct.def.coroutine}).
649 | %\\
650 | %\end{concepttable}
651 | %
652 | %\pagebreak
653 | %\pnum
654 | %\enterexample
655 | %This example illustrates full implementation
656 | %of a promise type for a simple generator.
657 | %\begin{codeblock}
658 | % #include
659 | % #include
660 | %
661 | % struct generator {
662 | % struct promise_type {
663 | % int current_value;
664 | % auto get_return_object() { return generator{*this}; }
665 | % auto initial_suspend() { return std::experimental::suspend_always{}; }
666 | % auto final_suspend() { return std::experimental::suspend_always{}; }
667 | % auto yield_value(int value) {
668 | % current_value = value;
669 | % return std::experimental::suspend_always{};
670 | % }
671 | % };
672 | %
673 | % bool move_next() {
674 | % coro.resume();
675 | % return !coro.done();
676 | % }
677 | %
678 | % int current_value() { return coro.promise().current_value; }
679 | %
680 | % ~generator() { coro.destroy(); }
681 | % private:
682 | % using handle = std::experimental::coroutine_handle;
683 | % explicit generator(promise_type& myPromise): coro(handle::from_promise(myPromise)) {}
684 | % handle coro;
685 | % };
686 | %
687 | % generator f() {
688 | % co_yield 1;
689 | % co_yield 2;
690 | % }
691 | %
692 | % int main() {
693 | % auto g = f();
694 | % while (g.move_next()) std::cout << g.current_value() << std::endl;
695 | % }
696 | %
697 | %\end{codeblock}
698 | %\exitexample
699 | %
700 | %\end{quote}
701 |
--------------------------------------------------------------------------------
/Coroutines/tables.tex:
--------------------------------------------------------------------------------
1 | %!TEX root = std.tex
2 | % Definitions of table environments
3 |
4 | %%--------------------------------------------------
5 | %% Table environments
6 |
7 | % Set parameters for floating tables
8 | \setcounter{totalnumber}{10}
9 |
10 | % Base definitions for tables
11 | \newenvironment{TableBase}
12 | {
13 | \renewcommand{\tcode}[1]{{\CodeStylex{##1}}}
14 | \newcommand{\topline}{\hline}
15 | \newcommand{\capsep}{\hline\hline}
16 | \newcommand{\rowsep}{\hline}
17 | \newcommand{\bottomline}{\hline}
18 |
19 | %% vertical alignment
20 | \newcommand{\rb}[1]{\raisebox{1.5ex}[0pt]{##1}} % move argument up half a row
21 |
22 | %% header helpers
23 | \newcommand{\hdstyle}[1]{\textbf{##1}} % set header style
24 | \newcommand{\Head}[3]{\multicolumn{##1}{##2}{\hdstyle{##3}}} % add title spanning multiple columns
25 | \newcommand{\lhdrx}[2]{\Head{##1}{|c}{##2}} % set header for left column spanning #1 columns
26 | \newcommand{\chdrx}[2]{\Head{##1}{c}{##2}} % set header for center column spanning #1 columns
27 | \newcommand{\rhdrx}[2]{\Head{##1}{c|}{##2}} % set header for right column spanning #1 columns
28 | \newcommand{\ohdrx}[2]{\Head{##1}{|c|}{##2}} % set header for only column spanning #1 columns
29 | \newcommand{\lhdr}[1]{\lhdrx{1}{##1}} % set header for single left column
30 | \newcommand{\chdr}[1]{\chdrx{1}{##1}} % set header for single center column
31 | \newcommand{\rhdr}[1]{\rhdrx{1}{##1}} % set header for single right column
32 | \newcommand{\ohdr}[1]{\ohdrx{1}{##1}}
33 | \newcommand{\br}{\hfill\break} % force newline within table entry
34 |
35 | %% column styles
36 | \newcolumntype{x}[1]{>{\raggedright\let\\=\tabularnewline}p{##1}} % word-wrapped ragged-right
37 | % column, width specified by #1
38 | % \newcolumntype{m}[1]{>{\CodeStyle}l{##1}} % variable width column, all entries in CodeStyle
39 | \newcolumntype{m}[1]{l{##1}} % variable width column, all entries in CodeStyle
40 |
41 | % do not number bullets within tables
42 | \renewcommand{\labelitemi}{---}
43 | \renewcommand{\labelitemii}{---}
44 | \renewcommand{\labelitemiii}{---}
45 | \renewcommand{\labelitemiv}{---}
46 | }
47 | {
48 | }
49 |
50 | % General Usage: TITLE is the title of the table, XREF is the
51 | % cross-reference for the table. LAYOUT is a sequence of column
52 | % type specifiers (e.g. cp{1.0}c), without '|' for the left edge
53 | % or right edge.
54 |
55 | % usage: \begin{floattablebase}{TITLE}{XREF}{COLUMNS}{PLACEMENT}
56 | % produces floating table, location determined within limits
57 | % by LaTeX.
58 | \newenvironment{floattablebase}[4]
59 | {
60 | \begin{TableBase}
61 | \begin{table}[#4]
62 | \caption{\label{#2}#1}
63 | \begin{center}
64 | \begin{tabular}{|#3|}
65 | }
66 | {
67 | \bottomline
68 | \end{tabular}
69 | \end{center}
70 | \end{table}
71 | \end{TableBase}
72 | }
73 |
74 | % usage: \begin{floattable}{TITLE}{XREF}{COLUMNS}
75 | % produces floating table, location determined within limits
76 | % by LaTeX.
77 | \newenvironment{floattable}[3]
78 | {
79 | \begin{floattablebase}{#1}{#2}{#3}{htbp}
80 | }
81 | {
82 | \end{floattablebase}
83 | }
84 |
85 | % usage: \begin{tokentable}{TITLE}{XREF}{HDR1}{HDR2}
86 | % produces six-column table used for lists of replacement tokens;
87 | % the columns are in pairs -- left-hand column has header HDR1,
88 | % right hand column has header HDR2; pairs of columns are separated
89 | % by vertical lines. Used in "trigraph sequences" table in standard.
90 | \newenvironment{tokentable}[4]
91 | {
92 | \begin{floattablebase}{#1}{#2}{cc|cc|cc}{htbp}
93 | \topline
94 | #3 & #4 &
95 | #3 & #4 &
96 | #3 & #4 \\ \capsep
97 | }
98 | {
99 | \end{floattablebase}
100 | }
101 |
102 | % usage: \begin{libsumtabbase}{TITLE}{XREF}{HDR1}{HDR2}
103 | % produces three-column table with column headers HDR1 and HDR2.
104 | % Used in "Library Categories" table in standard, and used as
105 | % base for other library summary tables.
106 | \newenvironment{libsumtabbase}[4]
107 | {
108 | \begin{floattable}{#1}{#2}{lll}
109 | \topline
110 | \lhdrx{2}{#3} & \hdstyle{#4} \\ \capsep
111 | }
112 | {
113 | \end{floattable}
114 | }
115 |
116 | % usage: \begin{libsumtab}{TITLE}{XREF}
117 | % produces three-column table with column headers "Subclause" and "Header(s)".
118 | % Used in "C++ Headers for Freestanding Implementations" table in standard.
119 | \newenvironment{libsumtab}[2]
120 | {
121 | \begin{libsumtabbase}{#1}{#2}{Subclause}{Header(s)}
122 | }
123 | {
124 | \end{libsumtabbase}
125 | }
126 |
127 | % usage: \begin{LibSynTab}{CAPTION}{TITLE}{XREF}{COUNT}{LAYOUT}
128 | % produces table with COUNT columns. Used as base for
129 | % C library description tables
130 | \newcounter{LibSynTabCols}
131 | \newcounter{LibSynTabWd}
132 | \newenvironment{LibSynTabBase}[5]
133 | {
134 | \setcounter{LibSynTabCols}{#4}
135 | \setcounter{LibSynTabWd}{#4}
136 | \addtocounter{LibSynTabWd}{-1}
137 | \newcommand{\centry}[1]{\textbf{##1}:}
138 | \newcommand{\macro}{\centry{Macro}}
139 | \newcommand{\macros}{\centry{Macros}}
140 | \newcommand{\function}{\centry{Function}}
141 | \newcommand{\functions}{\centry{Functions}}
142 | \newcommand{\mfunctions}{\centry{Math Functions}}
143 | \newcommand{\cfunctions}{\centry{Classification/comparison Functions}}
144 | \newcommand{\type}{\centry{Type}}
145 | \newcommand{\types}{\centry{Types}}
146 | \newcommand{\values}{\centry{Values}}
147 | \newcommand{\struct}{\centry{Struct}}
148 | \newcommand{\cspan}[1]{\multicolumn{\value{LibSynTabCols}}{|l|}{##1}}
149 | \begin{floattable}{#1 \tcode{<#2>} synopsis}{#3}
150 | {#5}
151 | \topline
152 | \lhdr{Type} & \rhdrx{\value{LibSynTabWd}}{Name(s)} \\ \capsep
153 | }
154 | {
155 | \end{floattable}
156 | }
157 |
158 | % usage: \begin{LibSynTab}{TITLE}{XREF}{COUNT}{LAYOUT}
159 | % produces table with COUNT columns. Used as base for description tables
160 | % for C library
161 | \newenvironment{LibSynTab}[4]
162 | {
163 | \begin{LibSynTabBase}{Header}{#1}{#2}{#3}{#4}
164 | }
165 | {
166 | \end{LibSynTabBase}
167 | }
168 |
169 | % usage: \begin{LibSynTabAdd}{TITLE}{XREF}{COUNT}{LAYOUT}
170 | % produces table with COUNT columns. Used as base for description tables
171 | % for additions to C library
172 | \newenvironment{LibSynTabAdd}[4]
173 | {
174 | \begin{LibSynTabBase}{Additions to header}{#1}{#2}{#3}{#4}
175 | }
176 | {
177 | \end{LibSynTabBase}
178 | }
179 |
180 | % usage: \begin{libsyntabN}{TITLE}{XREF}
181 | % \begin{libsyntabaddN}{TITLE}{XREF}
182 | % produces a table with N columns for C library description tables
183 | \newenvironment{libsyntab2}[2]
184 | {
185 | \begin{LibSynTab}{#1}{#2}{2}{ll}
186 | }
187 | {
188 | \end{LibSynTab}
189 | }
190 |
191 | \newenvironment{libsyntab3}[2]
192 | {
193 | \begin{LibSynTab}{#1}{#2}{3}{lll}
194 | }
195 | {
196 | \end{LibSynTab}
197 | }
198 |
199 | \newenvironment{libsyntab4}[2]
200 | {
201 | \begin{LibSynTab}{#1}{#2}{4}{llll}
202 | }
203 | {
204 | \end{LibSynTab}
205 | }
206 |
207 | \newenvironment{libsyntab5}[2]
208 | {
209 | \begin{LibSynTab}{#1}{#2}{5}{lllll}
210 | }
211 | {
212 | \end{LibSynTab}
213 | }
214 |
215 | \newenvironment{libsyntab6}[2]
216 | {
217 | \begin{LibSynTab}{#1}{#2}{6}{llllll}
218 | }
219 | {
220 | \end{LibSynTab}
221 | }
222 |
223 | \newenvironment{libsyntabadd2}[2]
224 | {
225 | \begin{LibSynTabAdd}{#1}{#2}{2}{ll}
226 | }
227 | {
228 | \end{LibSynTabAdd}
229 | }
230 |
231 | \newenvironment{libsyntabadd3}[2]
232 | {
233 | \begin{LibSynTabAdd}{#1}{#2}{3}{lll}
234 | }
235 | {
236 | \end{LibSynTabAdd}
237 | }
238 |
239 | \newenvironment{libsyntabadd4}[2]
240 | {
241 | \begin{LibSynTabAdd}{#1}{#2}{4}{llll}
242 | }
243 | {
244 | \end{LibSynTabAdd}
245 | }
246 |
247 | \newenvironment{libsyntabadd5}[2]
248 | {
249 | \begin{LibSynTabAdd}{#1}{#2}{5}{lllll}
250 | }
251 | {
252 | \end{LibSynTabAdd}
253 | }
254 |
255 | \newenvironment{libsyntabadd6}[2]
256 | {
257 | \begin{LibSynTabAdd}{#1}{#2}{6}{llllll}
258 | }
259 | {
260 | \end{LibSynTabAdd}
261 | }
262 |
263 | % usage: \begin{libsyntabfN}{TITLE}{XREF}
264 | % produces a fixed width table with N columns for C library description tables
265 | \newenvironment{libsyntabf2}[2]
266 | {
267 | \begin{LibSynTab}{#1}{#2}{2}{p{1in}p{4in}}
268 | }
269 | {
270 | \end{LibSynTab}
271 | }
272 |
273 | \newenvironment{libsyntabf3}[2]
274 | {
275 | \begin{LibSynTab}{#1}{#2}{3}{p{1in}p{.9in}p{2.9in}}
276 | }
277 | {
278 | \end{LibSynTab}
279 | }
280 |
281 | \newenvironment{libsyntabf5}[2]
282 | {
283 | \begin{LibSynTab}{#1}{#2}{5}{p{.9in}p{.9in}p{.9in}p{.9in}p{.9in}}
284 | }
285 | {
286 | \end{LibSynTab}
287 | }
288 |
289 | \newenvironment{libsyntabf4}[2]
290 | {
291 | \begin{LibSynTab}{#1}{#2}{4}{p{1in}p{.9in}p{.9in}p{1.8in}}
292 | }
293 | {
294 | \end{LibSynTab}
295 | }
296 |
297 | % usage: \begin{concepttable}{TITLE}{TAG}{LAYOUT}
298 | % produces table at current location
299 | \newenvironment{concepttable}[3]
300 | {
301 | \begin{TableBase}
302 | \begin{table}[!htb]
303 | \caption[#1]{\label{tab:#2}\label{#2}#1 \textbf{[#2]}}
304 | \begin{center}
305 | \begin{tabular}{|#3|}
306 | }
307 | {
308 | \bottomline
309 | \end{tabular}
310 | \end{center}
311 | \end{table}
312 | \end{TableBase}
313 | }
314 |
315 | % usage: \begin{simpletypetable}{TITLE}{TAG}{LAYOUT}
316 | % produces table at current location
317 | \newenvironment{simpletypetable}[3]
318 | {
319 | \begin{TableBase}
320 | \begin{table}[!htb]
321 | \caption{#1}\label{#2}
322 | \begin{center}
323 | \begin{tabular}{|#3|}
324 | }
325 | {
326 | \bottomline
327 | \end{tabular}
328 | \end{center}
329 | \end{table}
330 | \end{TableBase}
331 | }
332 |
333 | % usage: \begin{LongTable}{TITLE}{XREF}{LAYOUT}
334 | % produces table that handles page breaks sensibly.
335 | \newenvironment{LongTable}[3]
336 | {
337 | \newcommand{\continuedcaption}{\caption[]{#1 (continued)}}
338 | \begin{TableBase}
339 | \begin{longtable}
340 | {|#3|}\caption{#1}\label{#2}
341 | }
342 | {
343 | \bottomline
344 | \end{longtable}
345 | \end{TableBase}
346 | }
347 |
348 | % usage: \begin{twocol}{TITLE}{XREF}
349 | % produces a two-column breakable table. Used in
350 | % "simple-type-specifiers and the types they specify" in the standard.
351 | \newenvironment{twocol}[2]
352 | {
353 | \begin{concepttable}
354 | {#1}{#2}
355 | {ll}
356 | }
357 | {
358 | \end{LongTable}
359 | }
360 |
361 | % usage: \begin{libreqtabN}{TITLE}{XREF}
362 | % produces an N-column breakable table. Used in
363 | % most of the library Clauses for requirements tables.
364 | % Example at "Position type requirements" in the standard.
365 |
366 | \newenvironment{libreqtab1}[2]
367 | {
368 | \begin{LongTable}
369 | {#1}{#2}
370 | {x{.55\hsize}}
371 | }
372 | {
373 | \end{LongTable}
374 | }
375 |
376 | \newenvironment{libreqtab2}[2]
377 | {
378 | \begin{LongTable}
379 | {#1}{#2}
380 | {lx{.55\hsize}}
381 | }
382 | {
383 | \end{LongTable}
384 | }
385 |
386 | \newenvironment{libreqtab2a}[2]
387 | {
388 | \begin{LongTable}
389 | {#1}{#2}
390 | {x{.30\hsize}x{.68\hsize}}
391 | }
392 | {
393 | \end{LongTable}
394 | }
395 |
396 | \newenvironment{libreqtab3}[2]
397 | {
398 | \begin{LongTable}
399 | {#1}{#2}
400 | {x{.28\hsize}x{.18\hsize}x{.43\hsize}}
401 | }
402 | {
403 | \end{LongTable}
404 | }
405 |
406 | \newenvironment{libreqtab3a}[2]
407 | {
408 | \begin{LongTable}
409 | {#1}{#2}
410 | {x{.28\hsize}x{.33\hsize}x{.29\hsize}}
411 | }
412 | {
413 | \end{LongTable}
414 | }
415 |
416 | \newenvironment{libreqtab3b}[2]
417 | {
418 | \begin{LongTable}
419 | {#1}{#2}
420 | {x{.40\hsize}x{.25\hsize}x{.25\hsize}}
421 | }
422 | {
423 | \end{LongTable}
424 | }
425 |
426 | \newenvironment{libreqtab3c}[2]
427 | {
428 | \begin{LongTable}
429 | {#1}{#2}
430 | {x{.30\hsize}x{.25\hsize}x{.35\hsize}}
431 | }
432 | {
433 | \end{LongTable}
434 | }
435 |
436 | \newenvironment{libreqtab3d}[2]
437 | {
438 | \begin{LongTable}
439 | {#1}{#2}
440 | {x{.32\hsize}x{.27\hsize}x{.36\hsize}}
441 | }
442 | {
443 | \end{LongTable}
444 | }
445 |
446 | \newenvironment{libreqtab3e}[2]
447 | {
448 | \begin{LongTable}
449 | {#1}{#2}
450 | {x{.38\hsize}x{.27\hsize}x{.25\hsize}}
451 | }
452 | {
453 | \end{LongTable}
454 | }
455 |
456 | \newenvironment{libreqtab3f}[2]
457 | {
458 | \begin{LongTable}
459 | {#1}{#2}
460 | {x{.40\hsize}x{.22\hsize}x{.31\hsize}}
461 | }
462 | {
463 | \end{LongTable}
464 | }
465 |
466 | \newenvironment{libreqtab4}[2]
467 | {
468 | \begin{LongTable}
469 | {#1}{#2}
470 | }
471 | {
472 | \end{LongTable}
473 | }
474 |
475 | \newenvironment{libreqtab4a}[2]
476 | {
477 | \begin{LongTable}
478 | {#1}{#2}
479 | {x{.14\hsize}x{.30\hsize}x{.30\hsize}x{.14\hsize}}
480 | }
481 | {
482 | \end{LongTable}
483 | }
484 |
485 | \newenvironment{libreqtab4b}[2]
486 | {
487 | \begin{LongTable}
488 | {#1}{#2}
489 | {x{.13\hsize}x{.15\hsize}x{.29\hsize}x{.27\hsize}}
490 | }
491 | {
492 | \end{LongTable}
493 | }
494 |
495 | \newenvironment{libreqtab4c}[2]
496 | {
497 | \begin{LongTable}
498 | {#1}{#2}
499 | {x{.16\hsize}x{.21\hsize}x{.21\hsize}x{.30\hsize}}
500 | }
501 | {
502 | \end{LongTable}
503 | }
504 |
505 | \newenvironment{libreqtab4d}[2]
506 | {
507 | \begin{LongTable}
508 | {#1}{#2}
509 | {x{.22\hsize}x{.22\hsize}x{.30\hsize}x{.15\hsize}}
510 | }
511 | {
512 | \end{LongTable}
513 | }
514 |
515 | \newenvironment{libreqtab5}[2]
516 | {
517 | \begin{LongTable}
518 | {#1}{#2}
519 | {x{.14\hsize}x{.14\hsize}x{.20\hsize}x{.20\hsize}x{.14\hsize}}
520 | }
521 | {
522 | \end{LongTable}
523 | }
524 |
525 | % usage: \begin{libtab2}{TITLE}{XREF}{LAYOUT}{HDR1}{HDR2}
526 | % produces two-column table with column headers HDR1 and HDR2.
527 | % Used in "seekoff positioning" in the standard.
528 | \newenvironment{libtab2}[5]
529 | {
530 | \begin{floattable}
531 | {#1}{#2}{#3}
532 | \topline
533 | \lhdr{#4} & \rhdr{#5} \\ \capsep
534 | }
535 | {
536 | \end{floattable}
537 | }
538 |
539 | % usage: \begin{longlibtab2}{TITLE}{XREF}{LAYOUT}{HDR1}{HDR2}
540 | % produces two-column table with column headers HDR1 and HDR2.
541 | \newenvironment{longlibtab2}[5]
542 | {
543 | \begin{LongTable}{#1}{#2}{#3}
544 | \\ \topline
545 | \lhdr{#4} & \rhdr{#5} \\ \capsep
546 | \endfirsthead
547 | \continuedcaption\\
548 | \topline
549 | \lhdr{#4} & \rhdr{#5} \\ \capsep
550 | \endhead
551 | }
552 | {
553 | \end{LongTable}
554 | }
555 |
556 | % usage: \begin{LibEffTab}{TITLE}{XREF}{HDR2}{WD2}
557 | % produces a two-column table with left column header "Element"
558 | % and right column header HDR2, right column word-wrapped with
559 | % width specified by WD2.
560 | \newenvironment{LibEffTab}[4]
561 | {
562 | \begin{libtab2}{#1}{#2}{lp{#4}}{Element}{#3}
563 | }
564 | {
565 | \end{libtab2}
566 | }
567 |
568 | % Same as LibEffTab except that it uses a long table.
569 | \newenvironment{longLibEffTab}[4]
570 | {
571 | \begin{longlibtab2}{#1}{#2}{lp{#4}}{Element}{#3}
572 | }
573 | {
574 | \end{longlibtab2}
575 | }
576 |
577 | % usage: \begin{libefftab}{TITLE}{XREF}
578 | % produces a two-column effects table with right column
579 | % header "Effect(s) if set", width 4.5 in. Used in "fmtflags effects"
580 | % table in standard.
581 | \newenvironment{libefftab}[2]
582 | {
583 | \begin{LibEffTab}{#1}{#2}{Effect(s) if set}{4.5in}
584 | }
585 | {
586 | \end{LibEffTab}
587 | }
588 |
589 | % Same as libefftab except that it uses a long table.
590 | \newenvironment{longlibefftab}[2]
591 | {
592 | \begin{longLibEffTab}{#1}{#2}{Effect(s) if set}{4.5in}
593 | }
594 | {
595 | \end{longLibEffTab}
596 | }
597 |
598 | % usage: \begin{libefftabmean}{TITLE}{XREF}
599 | % produces a two-column effects table with right column
600 | % header "Meaning", width 4.5 in. Used in "seekdir effects"
601 | % table in standard.
602 | \newenvironment{libefftabmean}[2]
603 | {
604 | \begin{LibEffTab}{#1}{#2}{Meaning}{4.5in}
605 | }
606 | {
607 | \end{LibEffTab}
608 | }
609 |
610 | % Same as libefftabmean except that it uses a long table.
611 | \newenvironment{longlibefftabmean}[2]
612 | {
613 | \begin{longLibEffTab}{#1}{#2}{Meaning}{4.5in}
614 | }
615 | {
616 | \end{longLibEffTab}
617 | }
618 |
619 | % usage: \begin{libefftabvalue}{TITLE}{XREF}
620 | % produces a two-column effects table with right column
621 | % header "Value", width 3 in. Used in "basic_ios::init() effects"
622 | % table in standard.
623 | \newenvironment{libefftabvalue}[2]
624 | {
625 | \begin{LibEffTab}{#1}{#2}{Value}{3in}
626 | }
627 | {
628 | \end{LibEffTab}
629 | }
630 |
631 | % Same as libefftabvalue except that it uses a long table and a
632 | % slightly wider column.
633 | \newenvironment{longlibefftabvalue}[2]
634 | {
635 | \begin{longLibEffTab}{#1}{#2}{Value}{3.5in}
636 | }
637 | {
638 | \end{longLibEffTab}
639 | }
640 |
641 | % usage: \begin{liberrtab}{TITLE}{XREF} produces a two-column table
642 | % with left column header ``Value'' and right header "Error
643 | % condition", width 4.5 in. Used in regex Clause in the TR.
644 |
645 | \newenvironment{liberrtab}[2]
646 | {
647 | \begin{libtab2}{#1}{#2}{lp{4.5in}}{Value}{Error condition}
648 | }
649 | {
650 | \end{libtab2}
651 | }
652 |
653 | % Like liberrtab except that it uses a long table.
654 | \newenvironment{longliberrtab}[2]
655 | {
656 | \begin{longlibtab2}{#1}{#2}{lp{4.5in}}{Value}{Error condition}
657 | }
658 | {
659 | \end{longlibtab2}
660 | }
661 |
--------------------------------------------------------------------------------
/Coroutines/threads.tex:
--------------------------------------------------------------------------------
1 | %\setcounter{chapter}{29}
2 | %\rSec0[thread]{Thread support library}
3 | %
4 | %\setcounter{section}{2}
5 | %\rSec1[thread.threads]{Threads}
6 | %
7 | %\setcounter{subsection}{1}
8 | %\rSec2[thread.thread.this]{Namespace \tcode{this_thread}}
9 | %
10 | %Rename \tcode{yield}
11 | %function to \tcode{yield_execution}.
12 | %
13 | %\begin{quote}
14 | %\begin{codeblock}
15 | %namespace std {
16 | % namespace this_thread {
17 | % thread::id get_id() noexcept;
18 | %
19 | % void yield@\added{_execution}@() noexcept;
20 | % template
21 | % void sleep_until(const chrono::time_point& abs_time);
22 | % template
23 | % void sleep_for(const chrono::duration& rel_time);
24 | % }
25 | %}
26 | %\end{codeblock}
27 | %
28 | %\indexlibrary{\idxcode{this_thread}!\idxcode{get_id}}%
29 | %\indexlibrary{\idxcode{get_id}!\idxcode{this_thread}}%
30 | %\begin{itemdecl}
31 | %thread::id this_thread::get_id() noexcept;
32 | %\end{itemdecl}
33 | %
34 | %\begin{itemdescr}
35 | %\pnum
36 | %\returns An object of type \tcode{thread::id} that uniquely identifies the current thread of
37 | %execution. No other thread of execution shall have this id and this thread of execution shall
38 | %always have this id. The object returned shall not compare equal to a default constructed
39 | %\tcode{thread::id}.
40 | %\end{itemdescr}
41 | %
42 | %\indexlibrary{\idxcode{this_thread}!\idxcode{yield\added{_execution}}}%
43 | %\indexlibrary{\idxcode{yield\added{_execution}}!\idxcode{this_thread}}%
44 | %\begin{itemdecl}
45 | %void this_thread::yield@\added{_execution}@() noexcept;
46 | %\end{itemdecl}
47 | %
48 | %\begin{itemdescr}
49 | %\pnum
50 | %\effects Offers the implementation the opportunity to reschedule.
51 | %
52 | %\pnum
53 | %\sync None.
54 | %\end{itemdescr}
55 | %\end{quote}
--------------------------------------------------------------------------------
/r4/r3.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GorNishanov/coroutines-ts/5bca637a6dd29f719c9ec2409251f3f89d4aacb1/r4/r3.docx
--------------------------------------------------------------------------------
/r4/r4.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GorNishanov/coroutines-ts/5bca637a6dd29f719c9ec2409251f3f89d4aacb1/r4/r4.docx
--------------------------------------------------------------------------------