<!DOCTYPE html>
<!-- Sources at https://github.com/jaredhoberock/DXXXX -->
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><!--[if lte IE 8]><script>document.createElement("nav");document.createElement("section");document.createElement("time");document.createElement("CXX-TOC");document.createElement("CXX-CLAUSE");document.createElement("CXX-SECTION");document.createElement("CXX-EXAMPLE");document.createElement("CXX-CODEBLOCK");document.createElement("CXX-NOTE");document.createElement("CXX-REF");document.createElement("CXX-FUNCTION");document.createElement("CXX-SIGNATURE");document.createElement("CXX-EFFECTS");document.createElement("CXX-REMARKS");document.createElement("CXX-RETURNS");document.createElement("CXX-REQUIRES");document.createElement("CXX-COMPLEXITY");document.createElement("CXX-NOTES");document.createElement("CXX-PUBLISH-BUTTON");</script><![endif]--><style>template {display: none !important;} /* injected by platform.js */</style><style>body {transition: opacity ease-in 0.2s; } 
body[unresolved] {opacity: 0; display: block; overflow: hidden; position: relative; } 
</style><style shim-shadowdom-css="">style { display: none !important; }
cxx-function {
	display: block; page-break-inside: avoid;
}

cxx-function:not(:last-child) {
	margin-bottom: 3ex;
}

cxx-function > dl {
	margin: 0px 0px 0px 2em;
}

cxx-function > pre {
	margin: 0px;
}cxx-signature {
	padding-left: 2em; display: block; text-indent: -2em;
}

cxx-signature.formatted {
	text-indent: 0px;
}cxx-attribute {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-attribute dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-attribute dd {
	margin-left: 0em;
}

cxx-attribute dd > ul, cxx-attribute dd > ol {
	clear: left;
}cxx-requires {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-requires dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-requires dd {
	margin-left: 0em;
}

cxx-requires dd > ul, cxx-requires dd > ol {
	clear: left;
}cxx-preconditions {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-preconditions dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-preconditions dd {
	margin-left: 0em;
}

cxx-preconditions dd > ul, cxx-preconditions dd > ol {
	clear: left;
}cxx-effects {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-effects dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-effects dd {
	margin-left: 0em;
}

cxx-effects dd > ul, cxx-effects dd > ol {
	clear: left;
}cxx-synchronization {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-synchronization dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-synchronization dd {
	margin-left: 0em;
}

cxx-synchronization dd > ul, cxx-synchronization dd > ol {
	clear: left;
}cxx-postconditions {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-postconditions dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-postconditions dd {
	margin-left: 0em;
}

cxx-postconditions dd > ul, cxx-postconditions dd > ol {
	clear: left;
}cxx-returns {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-returns dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-returns dd {
	margin-left: 0em;
}

cxx-returns dd > ul, cxx-returns dd > ol {
	clear: left;
}cxx-throws {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-throws dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-throws dd {
	margin-left: 0em;
}

cxx-throws dd > ul, cxx-throws dd > ol {
	clear: left;
}cxx-complexity {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-complexity dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-complexity dd {
	margin-left: 0em;
}

cxx-complexity dd > ul, cxx-complexity dd > ol {
	clear: left;
}cxx-exception-safety {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-exception-safety dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-exception-safety dd {
	margin-left: 0em;
}

cxx-exception-safety dd > ul, cxx-exception-safety dd > ol {
	clear: left;
}cxx-remarks {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-remarks dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-remarks dd {
	margin-left: 0em;
}

cxx-remarks dd > ul, cxx-remarks dd > ol {
	clear: left;
}cxx-error-conditions {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-error-conditions dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-error-conditions dd {
	margin-left: 0em;
}

cxx-error-conditions dd > ul, cxx-error-conditions dd > ol {
	clear: left;
}cxx-notes {
	display: block; margin-top: 0.5em; margin-bottom: 0.5em;
}

cxx-notes dt {
	float: left; font-style: italic; font-weight: normal; padding-right: 1ex;
}

cxx-notes dd {
	margin-left: 0em;
}

cxx-notes dd > ul, cxx-notes dd > ol {
	clear: left;
}cxx-section {
	display: block;
}

cxx-section:target {
	background-color: inherit;
}

cxx-section:target > section > h1 {
	background-color: rgb(255, 238, 221);
}

cxx-section header > h1 {
	display: inline; font-size: 100%;
}

cxx-section header {
	font-weight: bold; margin-top: 20px; margin-bottom: 20px; page-break-inside: avoid; page-break-after: avoid;
}

cxx-section header::after {
	clear: both; display: block; content: " "; height: 0px;
}cxx-clause {
	display: block;
}

cxx-clause:target {
	background-color: inherit;
}

cxx-clause:target > section > h1 {
	background-color: rgb(255, 238, 221);
}

cxx-clause header > h1 {
	display: inline; font-size: 100%;
}

cxx-clause header {
	font-weight: bold; margin-top: 20px; margin-bottom: 20px; page-break-inside: avoid; page-break-after: avoid;
}

cxx-clause header::after {
	clear: both; display: block; content: " "; height: 0px;
}[is=cxx-table] {
	margin-left: auto; margin-right: auto; border-collapse: collapse; border: thin solid black;
}

[is=cxx-table] caption {
	white-space: nowrap;
}

[is=cxx-table] caption caption {
	display: inline;
}

[is=cxx-table] th, [is=cxx-table] td {
	border-style: solid none; border-color: black; border-width: thin; padding: 0px 0.25em;
}

[is=cxx-table].column-rules th, [is=cxx-table].column-rules td {
	border-left-style: solid; border-right-style: solid;
}

[is=cxx-table] th {
	border-bottom: medium double;
}

[is=cxx-table].single-border th {
	border-bottom: thin solid;
}

[is=cxx-table].center td {
	text-align: center;
}

[is=cxx-table].list td {
	border: medium none; vertical-align: top;
}

[is=cxx-table].list ul {
	padding-left: 0px; margin: 0px;
}

[is=cxx-table].list ul li::before {
	content: "";
}cxx-figure {
	margin-left: auto; margin-right: auto;
}

cxx-figure figcaption {
	white-space: nowrap; text-align: center;
}

cxx-figure figcaption figcaption {
	display: inline;
}[is=cxx-definition-section] dt {
	font-weight: bold;
}

[is=cxx-definition-section] dd {
	margin-left: 0px;
}cxx-toc {
	display: block;
}

cxx-toc nav > ol {
	font-weight: bold;
}

cxx-toc ol {
	font-weight: normal; padding-left: 0px; margin-left: 0px;
}

cxx-toc li {
	list-style-type: none;
}

cxx-toc .marker {
	display: inline-block;
}

cxx-toc li .marker {
	width: 2em; text-align: left;
}

cxx-toc ol ol {
	margin-left: 2em;
}

cxx-toc li li .marker {
	width: 3em;
}

cxx-toc ol ol ol {
	margin-left: 3em;
}

cxx-toc li li li .marker {
	width: 3.5em;
}

cxx-toc ol ol ol ol {
	margin-left: 3.5em;
}

cxx-toc li li li li .marker {
	width: 4.5em;
}cxx-get-element-by-id {
	display: none;
}cxx-foreign-index {
	display: none;
}cxx-titlepage, cxx-titlepage .page {
	display: block; min-height: 100%;
}

cxx-titlepage .page {
	page-break-before: always; page-break-after: always; min-height: 100vh; margin-bottom: 2em;
}

@media print {
cxx-titlepage .page {
	height: 8.8in;
}


}

cxx-titlepage .page {
	position: relative;
}

cxx-titlepage table td, cxx-titlepage table th {
	border: medium none;
}

cxx-titlepagebody.cxx-draft .header, body.cxx-draft cxx-titlepage .header {
	position: absolute; right: 0px; top: 0px;
}

cxx-titlepagebody.cxx-draft h1, body.cxx-draft cxx-titlepage h1 {
	position: absolute; top: 40%; text-align: center;
}

cxx-titlepagebody.cxx-draft p.warning, body.cxx-draft cxx-titlepage p.warning {
	position: absolute; bottom: 5%;
}

cxx-titlepagebody.cxx-pdts .header, body.cxx-pdts cxx-titlepage .header, cxx-titlepagebody.cxx-dts .header, body.cxx-dts cxx-titlepage .header, cxx-titlepagebody.cxx-ts .header, body.cxx-ts cxx-titlepage .header {
	position: absolute; right: 0px; top: 0px; text-align: right;
}

cxx-titlepagebody.cxx-pdts .header cxx-docnum, body.cxx-pdts cxx-titlepage .header cxx-docnum, cxx-titlepagebody.cxx-dts .header cxx-docnum, body.cxx-dts cxx-titlepage .header cxx-docnum, cxx-titlepagebody.cxx-ts .header cxx-docnum, body.cxx-ts cxx-titlepage .header cxx-docnum {
	font-size: 150%;
}

cxx-titlepagebody.cxx-pdts .header cxx-docnum, body.cxx-pdts cxx-titlepage .header cxx-docnum, cxx-titlepagebody.cxx-dts .header cxx-docnum, body.cxx-dts cxx-titlepage .header cxx-docnum, cxx-titlepagebody.cxx-ts .header cxx-docnum, body.cxx-ts cxx-titlepage .header cxx-docnum {
	font-size: 150%;
}

cxx-titlepagebody.cxx-pdts hgroup, body.cxx-pdts cxx-titlepage hgroup, cxx-titlepagebody.cxx-dts hgroup, body.cxx-dts cxx-titlepage hgroup, cxx-titlepagebody.cxx-ts hgroup, body.cxx-ts cxx-titlepage hgroup {
	position: absolute; top: 30%;
}

cxx-titlepagebody.cxx-pdts hgroup *, body.cxx-pdts cxx-titlepage hgroup *, cxx-titlepagebody.cxx-dts hgroup *, body.cxx-dts cxx-titlepage hgroup *, cxx-titlepagebody.cxx-ts hgroup *, body.cxx-ts cxx-titlepage hgroup * {
	margin: 0px;
}

cxx-titlepagebody.cxx-pdts hgroup h1, body.cxx-pdts cxx-titlepage hgroup h1, cxx-titlepagebody.cxx-dts hgroup h1, body.cxx-dts cxx-titlepage hgroup h1, cxx-titlepagebody.cxx-ts hgroup h1, body.cxx-ts cxx-titlepage hgroup h1 {
	font-size: 150%; font-weight: bold;
}

cxx-titlepagebody.cxx-pdts hgroup h2, body.cxx-pdts cxx-titlepage hgroup h2, cxx-titlepagebody.cxx-dts hgroup h2, body.cxx-dts cxx-titlepage hgroup h2, cxx-titlepagebody.cxx-ts hgroup h2, body.cxx-ts cxx-titlepage hgroup h2 {
	font-size: 100%; font-weight: normal;
}

cxx-titlepagebody.cxx-pdts .footer, body.cxx-pdts cxx-titlepage .footer, cxx-titlepagebody.cxx-dts .footer, body.cxx-dts cxx-titlepage .footer, cxx-titlepagebody.cxx-ts .footer, body.cxx-ts cxx-titlepage .footer {
	position: absolute; left: 0px; bottom: 5%;
}

cxx-titlepagebody.cxx-pdts figure, body.cxx-pdts cxx-titlepage figure, cxx-titlepagebody.cxx-dts figure, body.cxx-dts cxx-titlepage figure, cxx-titlepagebody.cxx-ts figure, body.cxx-ts cxx-titlepage figure {
	border: 1px solid rgb(17, 17, 17); padding: 10px; margin-left: auto; margin-right: auto;
}

cxx-titlepagebody.cxx-pdts figcaption, body.cxx-pdts cxx-titlepage figcaption, cxx-titlepagebody.cxx-dts figcaption, body.cxx-dts cxx-titlepage figcaption, cxx-titlepagebody.cxx-ts figcaption, body.cxx-ts cxx-titlepage figcaption {
	text-align: center; font-weight: bold;
}

cxx-titlepagebody.cxx-pdts .warning, body.cxx-pdts cxx-titlepage .warning, cxx-titlepagebody.cxx-dts .warning, body.cxx-dts cxx-titlepage .warning, cxx-titlepagebody.cxx-ts .warning, body.cxx-ts cxx-titlepage .warning {
	position: absolute; bottom: 20%;
}

cxx-titlepagebody.cxx-pdts .copyright address, body.cxx-pdts cxx-titlepage .copyright address, cxx-titlepagebody.cxx-dts .copyright address, body.cxx-dts cxx-titlepage .copyright address, cxx-titlepagebody.cxx-ts .copyright address, body.cxx-ts cxx-titlepage .copyright address {
	font-style: normal; margin-left: 2em;
}

cxx-titlepagebody.cxx-pdts .copyright address a, body.cxx-pdts cxx-titlepage .copyright address a, cxx-titlepagebody.cxx-dts .copyright address a, body.cxx-dts cxx-titlepage .copyright address a, cxx-titlepagebody.cxx-ts .copyright address a, body.cxx-ts cxx-titlepage .copyright address a {
	color: inherit; text-decoration: inherit;
}

cxx-titlepage th {
	text-align: left; vertical-align: top;
}cxx-foreword {
	display: block; min-height: 100%;
}

cxx-foreword {
	page-break-before: always; page-break-after: always; min-height: 100vh; margin-bottom: 2em;
}

cxx-forewordbody.cxx-draft cxx-foreword -no-combinator, body.cxx-draft cxx-foreword cxx-foreword -no-combinator {
	display: none;
}cxx-ednote {
	display: none;
}

cxx-ednotebody.cxx-draft, body.cxx-draft cxx-ednote {
	display: block;
}

cxx-ednote aside {
	float: right; max-width: 40%; margin: 1ex; border: 1px dashed rgb(136, 136, 136); padding: 1ex; background-color: rgb(238, 238, 238);
}

cxx-ednote.para aside {
	float: none; max-width: none;
}cxx-note .nowrap {
	white-space: nowrap;
}cxx-footnote {
	font-family: serif; white-space: normal; text-indent: initial;textIndent: initial; text-indent: initial; 
}

@media screen {
cxx-footnote aside {
	float: right; max-width: 30%; margin-left: 1em;
}


}

@media print {
cxx-footnote sup, cxx-footnote .marker {
	display: none;
}

cxx-footnote aside {
	
}


}cxx-example {
	display: block;
}

cxx-example.inline {
	display: inline;
}

cxx-example .nowrap {
	white-space: nowrap;
}cxx-publish-button {
	display: block;
}cxx-codeblock {
	display: block;
}bnf-grammar {
	display: block; font-style: italic; margin-left: 0.35in;
}bnf-rule {
	display: block; margin-left: 0.6in;
}bnf-alt {
	display: block; margin-left: 1.2in;
}bnf-terminal {
	font-style: normal;
}w-br {
	white-space: normal;
}

w-br::after {
	content: "​";
}</style>
  <meta charset="utf-8">
  
  <style shim-shadowdom-css="">/* Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

@page {
    margin: 10%;
}
@page :left {
    @top-left { content: string(docname); font-weight: bold; font-size: 10pt; }
    @top-right { content: normal; }
    @bottom-left { content: counter(page); font-size: 10pt; }
    @bottom-right { content: "© ISO/IEC " string(pubyear) " — All rights reserved";
                    font-size: 10pt; }
}
@page :right {
    @top-left { content: normal; }
    @top-right { content: string(docname); font-weight: bold; font-size: 10pt; }
    @bottom-left { content: "© ISO/IEC " string(pubyear) " — All rights reserved";
                   font-size: 10pt; }
    @bottom-right { content: counter(page); font-size: 10pt; }
}
@page :first {
    @top-left { content: normal; }
    @top-right { content: normal; }
    @bottom-left { content: normal; }
    @bottom-right { content: normal; }
}

body { margin: 0; }

@media screen {
    body { max-width: 7in;
           /* Make room for paragraph numbers. */
           margin-left: 2em }
}

@media print {
    html { font-size: 10pt; }
    *   code { font-size: 80%; }
    /* Note that only Prince generates clickable links. */
    *   a[href] { text-decoration:none; }
}

@media screen {
    /* Needed to make the <cxx-titlepage>'s vertical spacing work.
       For print see the <cxx-titlepage> definition. */
    html, body {height: 100%}
}

*   .docname { string-set: docname content(); }
*   .pubyear { string-set: pubyear content(); }

cxx-clause, cxx-foreword { page-break-before: always; }
@media screen {
    cxx-clause, cxx-toc, cxx-foreword { margin-top: 3em; }
}

cxx-clause  header, cxx-foreword  h1 { font-size: 150%; }
cxx-toc  h1 { font-size: 150%; }
cxx-clause cxx-section  header { font-size: 117%; }
cxx-clause cxx-section cxx-section  header { font-size: 100%; }

[data-bookmark-label] { bookmark-label: attr(data-bookmark-label); }
h1 { bookmark-level: 1; }
cxx-toc  h1 { bookmark-level: 2; }
cxx-clause h1, cxx-foreword h1 { bookmark-level: 2; }
cxx-clause cxx-section h1 { bookmark-level: 3; }
cxx-clause cxx-section cxx-section h1 { bookmark-level: 4; }
/* The <h2> is a subtitle, which shouldn't get a PDF bookmark. */
cxx-titlepage  h2 { bookmark-level: none; }

*  .section-number { string-set: current-section "§ " content(); }

p {margin-top: .5em; margin-bottom: .5em}
p:first-child, ul, ol {margin-top: 0}

[para_num]::before { content: attr(para_num); float: left;
                     font-size: 70%; margin-left: -2.5em; width: 1.5em; text-align: right; }

del {text-decoration: line-through; color: #8B0040;}
ins {text-decoration: underline; color: #005100;}

pre {
    margin-left: 1em;
    margin-top: .5em;
    margin-bottom: .5em;
}

*   wbr::after {
    white-space: normal;
    content: '\200B';
}
*   code {
    /* Make inline code avoid line wraps unless we override it with <wbr>. */
    white-space: nowrap;
}
*   pre code {
    /* Keep block-code wrapping according to its context. */
    white-space: inherit;
}

*   table {
    border-collapse: collapse;
}
*   td, th {
    padding-left: .2em;
    padding-right: .2em;
    border: thin solid black;
}

/* Use an em-dash for the list bullet.
   'print' is a proxy for supporting ::marker. */
@media screen {
    ul {
        list-style: none;
        /* Relative positioning on the 'ul' lets the absolutely-positioned
           marker align relative to it.*/
        position: relative;
    }
    ul li:before {
        content: "\2014";
        position: absolute; left: 10px;
    }
}
@media print {
    ul li::marker {
        content: "\2014";
    }
    [is=cxx-table].list ul li::marker {
        content: none;
    }
}

/* This is here rather than inside elements/toc.html because browsers
   don't understand leader() or target-counter(), so they drop them
   inside the CSSOM. */
@media print {
    /* Generate page numbers in the table of contents. */
    cxx-toc  a[href]::after { content: leader(" . ") target-counter(attr(href), page); }

    cxx-footnote  aside { float: footnote; footnote-policy: line; }
}</style><style shim-shadowdom-css="">/*******************************
          Flex Layout
*******************************/

html   [layout][horizontal], html   [layout][vertical] {
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

html   [layout][horizontal][inline], html   [layout][vertical][inline] {
  display: -ms-inline-flexbox;
  display: -webkit-inline-flex;
  display: inline-flex;
}

html   [layout][horizontal] {
  -ms-flex-direction: row;
  -webkit-flex-direction: row;
  flex-direction: row;
}

html   [layout][horizontal][reverse] {
  -ms-flex-direction: row-reverse;
  -webkit-flex-direction: row-reverse;
  flex-direction: row-reverse;
}

html   [layout][vertical] {
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
}

html   [layout][vertical][reverse] {
  -ms-flex-direction: column-reverse;
  -webkit-flex-direction: column-reverse;
  flex-direction: column-reverse;
}

html   [layout][wrap] {
  -ms-flex-wrap: wrap;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
}

html   [layout][wrap-reverse] {
  -ms-flex-wrap: wrap-reverse;
  -webkit-flex-wrap: wrap-reverse;
  flex-wrap: wrap-reverse;
}

html   [flex] {
  -ms-flex: 1 1 0.000000001px;
  -webkit-flex: 1;
  flex: 1;
  -webkit-flex-basis: 0.000000001px;
  flex-basis: 0.000000001px;
}

html   [vertical][layout] > [flex][auto-vertical], html   [vertical][layout]  [flex][auto-vertical] {
  -ms-flex: 1 1 auto;
  -webkit-flex-basis: auto;
  flex-basis: auto;
}

html   [flex][auto] {
  -ms-flex: 1 1 auto;
  -webkit-flex-basis: auto;
  flex-basis: auto;
}

html   [flex][none] {
  -ms-flex: none;
  -webkit-flex: none;
  flex: none;
}

html   [flex][one] {
  -ms-flex: 1;
  -webkit-flex: 1;
  flex: 1;
}

html   [flex][two] {
  -ms-flex: 2;
  -webkit-flex: 2;
  flex: 2;
}

html   [flex][three] {
  -ms-flex: 3;
  -webkit-flex: 3;
  flex: 3;
}

html   [flex][four] {
  -ms-flex: 4;
  -webkit-flex: 4;
  flex: 4;
}

html   [flex][five] {
  -ms-flex: 5;
  -webkit-flex: 5;
  flex: 5;
}

html   [flex][six] {
  -ms-flex: 6;
  -webkit-flex: 6;
  flex: 6;
}

html   [flex][seven] {
  -ms-flex: 7;
  -webkit-flex: 7;
  flex: 7;
}

html   [flex][eight] {
  -ms-flex: 8;
  -webkit-flex: 8;
  flex: 8;
}

html   [flex][nine] {
  -ms-flex: 9;
  -webkit-flex: 9;
  flex: 9;
}

html   [flex][ten] {
  -ms-flex: 10;
  -webkit-flex: 10;
  flex: 10;
}

html   [flex][eleven] {
  -ms-flex: 11;
  -webkit-flex: 11;
  flex: 11;
}

html   [flex][twelve] {
  -ms-flex: 12;
  -webkit-flex: 12;
  flex: 12;
}

/* alignment in cross axis */

html   [layout][start] {
  -ms-flex-align: start;
  -webkit-align-items: flex-start;
  align-items: flex-start;
}

html   [layout][center], html   [layout][center-center] {
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
}

html   [layout][end] {
  -ms-flex-align: end;
  -webkit-align-items: flex-end;
  align-items: flex-end;
}

/* alignment in main axis */

html   [layout][start-justified] {
  -ms-flex-pack: start;
  -webkit-justify-content: flex-start;
  justify-content: flex-start;
}

html   [layout][center-justified], html   [layout][center-center] {
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

html   [layout][end-justified] {
  -ms-flex-pack: end;
  -webkit-justify-content: flex-end;
  justify-content: flex-end;
}

html   [layout][around-justified] {
  -ms-flex-pack: distribute;
  -webkit-justify-content: space-around;
  justify-content: space-around;
}

html   [layout][justified] {
  -ms-flex-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
}

/* self alignment */

html   [self-start] {
  -ms-align-self: flex-start;
  -webkit-align-self: flex-start;
  align-self: flex-start;
}

html   [self-center] {
  -ms-align-self: center;
  -webkit-align-self: center;
  align-self: center;
}

html   [self-end] {
  -ms-align-self: flex-end;
  -webkit-align-self: flex-end;
  align-self: flex-end;
}

html   [self-stretch] {
  -ms-align-self: stretch;
  -webkit-align-self: stretch;
  align-self: stretch;
}

/*******************************
          Other Layout
*******************************/

html   [block] {
  display: block;
}

/* ie support for hidden */
html   [hidden] {
  display: none !important;
}

html   [relative] {
  position: relative;
}

html   [fit] {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

body[fullbleed] {
  margin: 0;
  height: 100vh;
}

/*******************************
            Other
*******************************/

html   [segment], html   segment {
  display: block;
  position: relative;
  -webkit-box-sizing: border-box;
  -ms-box-sizing: border-box;
  box-sizing: border-box;
  margin: 1em 0.5em;
  padding: 1em;
  background-color: white;
  -webkit-box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.1);
  box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.1);
  border-radius: 5px 5px 5px 5px;
}</style>
</head>
<body>


<table>
<tbody><tr>
  <td align="left">Doc. no.</td>
  <td align="left">P0024</td>
</tr>
<tr>
  <td align="left">Date:</td>
  <td align="left">2015-09-25</td>
</tr>
<tr>
  <td align="left">Project:</td>
  <td align="left">Programming Language C++</td>
</tr>
<tr>
  <td align="left">Reply to:</td>
  <td align="left">Jared Hoberock &lt;<a href="mailto:jhoberock@nvidia.com">jhoberock@nvidia.com</a>&gt;</td>
</tr>
</tbody></table>

<h1>The Parallelism TS Should be Standardized</h1>

<section>
  <h1>Abstract</h1>

  <p>We survey implementation experience with the recently published C++ Technical
  Specification for Extensions for Parallelism and conclude that ample
  experience with its functionality exists to justify standardization in C++17.
  This paper describes various existing and pre-existing implementations of the
  TS's content and describes the additions to be made to the current C++
  working paper (N4527) to integrate execution policies and parallel algorithms into
  the C++ Standard Library.</p>
</section>

<section>
  <h1>Implementation Experience</h1>

  Although the first version of the Parallelism TS has been published only
  recently (N4354), we believe practioners have suitable experience with both existing
  and pre-existing implementations of its functionality to allow prompt
  standardization. Both implementors and users are ready for parallel
  algorithms in C++.

  <section>
    <h1>Development History</h1>

    <p>The technical content of the Parallelism TS was developed by domain
    experts in parallelism over the course of a few years. In 2012,
    representatives from NVIDIA (N3408) as well as representiatives from
    Microsoft and Intel (N3429) independently proposed library approaches to
    parallelism within the C++ Standard Library. At the suggestion of SG1 the
    authors of these proposals submitted a design in a joint proposal (N3554)
    to parallelize the existing standard algorithms library. This proposal was
    refined into the Parallelism TS over the course of two years. During that
    refinement process, the authors of the Parallelism TS incorporated feedback
    from experimental implementations into the final design which was published
    in 2015. In total, the C++ Standardization Committee has three years
    of experience with the TS's design.</p>

  </section>

  <section>
    <h1>Existing implementations</h1>

    <p>Several different implementations of the Parallelism TS emerged during its preparation.
    We are aware of the following publically documented implementations.</p>

    <ul>
      <li>
        Microsoft: <a href="http://parallelstl.codeplex.com/">http://parallelstl.codeplex.com</a>
      </li>

      <li>
        HPX: <a href="http://stellar-group.github.io/hpx/docs/html/hpx/manual/parallel.html">http://stellar-group.github.io/hpx/docs/html/hpx/manual/parallel.html</a>
      </li>

      <li>
        Codeplay: <a href="http://github.com/KhronosGroup/SyclParallelSTL">http://github.com/KhronosGroup/SyclParallelSTL</a>
      </li>

      <li>
        HSA: <a href="http://www.hsafoundation.com/hsa-for-math-science">http://www.hsafoundation.com/hsa-for-math-science</a>
      </li>

      <li>
        Thibaut Lutz: <a href="http://github.com/t-lutz/ParallelSTL">http://github.com/t-lutz/ParallelSTL</a>
      </li>

      <li>
        NVIDIA: <a href="http://github.com/n3554/n3554">http://github.com/n3554/n3554</a>
      </li>
    </ul>
  </section>

  <p>These implementations implement the functionality of the Parallelism TS to
  varying degrees and in different ways. For example, Microsoft's
  implementation appears complete and is implemented via Windows-specific
  tasking facilities. Thibaut Lutz' version also appears complete and is
  implemented by manipulating <code>std::thread</code> in a standard way.
  NVIDIA's implementation is partial and is implemented as a thin wrapper
  around Thrust, a pre-existing library similar in content to the Parallelism
  TS. This variety of implementation approaches exists by design: the
  abstractions of the Parallelism TS are intended to maximize flexibility of
  implementation.</p>

  <section>
    <h1>Pre-existing implementations</h1>

    <p>
      The design of the Parallelism TS's functionality was inspired by
      several pre-existing libraries. Each of the following parallel algorithms
      libraries expose an iterator-based algorithm interface based on the
      conventions of the original Standard Template Library. We believe these
      libraries are a reasonable proxy for the content of the Parallelism TS.
    </p>

    <ul>
      <li>
        Thrust: <a href="http://thrust.github.io/">http://thrust.github.io</a>
      </li>

      <li>
        Boost.Compute: <a href="http://github.com/boostorg/compute">http://github.com/boostorg/compute</a>
      </li>

      <li>
        Bolt: <a href="http://github.com/HSA-Libraries/Bolt">http://github.com/HSA-Libraries/Bolt</a>
      </li>

      <li>
        libstdc++ Parallel Mode: <a href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/parallel_mode.html">http://gcc.gnu.org/onlinedocs/libstdc++/manual/parallel_mode.html</a>
      </li>

      <li>
        AMP Algorithms Library: <a href="http://ampalgorithms.codeplex.com/">http://ampalgorithms.codeplex.com</a>
      </li>
    </ul>
  </section>

  <p>These libraries have existed for several years, and some are widely
  deployed in production. Accordingly, we believe the features of the
  Parallelism TS are proven abstractions that represent standard practice and
  solve real challenges faced by real C++ programmers. These challenges exist
  because parallel architectures are so pervasive, and programming them
  correctly with existing low-level standard components is difficult. As a
  remedy, we believe that the high-level abstractions of the Parallelism TS
  must be standardized as soon as possible. C++ programmers should not have to
  wait beyond 2017 for standard parallel algorithms.</p><p>

  </p><section>
    <h1>Future Support</h1>

    <p>
      The parallel algorithms and execution policies of the Parallelism TS are
      only a starting point. Already we anticipate opportunities for extending the
      Parallelism TS's functionality to increase programmer flexibility and
      expressivity. A fully-realized executors feature (N4414, N4406) will yield new, flexible ways of
      creating execution, including the execution of parallel algorithms. For
      example, executors will provide a programmatic means of specifying <em>where</em>
      execution is allowed to occur during parallel algorithm execution and will
      open the door for user-defined execution policies in addition to the Parallelism TS's closed
      set of standard policies. If the first version of the Parallelism TS is
      standardized in 2017, such additional features for parallelism will be well-positioned for
      2020.
    </p>
  </section>
</section>

<section>
  <h1>Summary of proposed changes</h1>

  <p>
    We propose to standardize the functionality of the Parallelism TS as specified. In summary:

    </p><ul>
      <li>Add <code>exception_list</code> as a new subclause to Clause 19.</li>
      <li>Add execution policies as a new subclause to Clause 20.</li>
      <li>Introduce general wording for parallel algorithms as a new subclause to Clause 25.</li>
      <li>Add the new algorithms introduced by the Parallelism TS to Clauses 20, 25, and 26.</li>
    </ul>

    The locations of these changes merely represent our best guess and 
we expect them to change at the Library Working Group's discretion.
  <p></p>
</section>

<section>
  <h1>References</h1>

  <ol>
    <li>N4308 - <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3408.pdf">Parallelizing the Standard Algorithms Library</a>, J. Hoberock, M. Garland, O. Giroux, V. Grover, U. Kapasi, and J. Marathe. 2012.</li>
    <li>N4329 - <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3429.pdf">A Library Solution to Parallelism</a>, A. Laksberg, H. Sutter, A. Robison, and S. Mithani. 2012.</li>
    <li>N3554 - <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3554.pdf">A Parallel Algorithms Library</a>, J. Hoberock, J. Marathe, M. Garland, O. Giroux, V. Grover, A. Laksberg, H. Sutter, and A. Robison. 2013.</li>
    <li>N4354 - <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4354.pdf">Programming Languages - Technical Specification for C++ Extensions for Parallelism</a>, International Standards Organization. 2015.</li>
    <li>N4414 - <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4414.pdf">Executors and schedulers, revision 5</a>, C. Mysen. 2015.</li>
    <li>N4406 - <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4406.pdf">Parallel Algorithms Need Executors</a>, J. Hoberock et al. 2015.</li>
  </ol>
</section>



<cxx-toc>
    
    <nav>
      <h1>Contents</h1>
      
        
          <ol>
            
              <li><span class="marker">20</span><a href="#utilities">General utilities library</a>
        
          <ol>
            
              <li><span class="marker">20.15</span><a href="#execpol">Execution policies</a>
        
          <ol>
            
              <li><span class="marker">20.15.1</span><a href="#execpol.general">In general</a>
        
      </li>
            
              <li><span class="marker">20.15.2</span><a href="#execpol.synopsis">Header &lt;execution_policy&gt; synopsis</a>
        
      </li>
            
              <li><span class="marker">20.15.3</span><a href="#execpol.type">Execution policy type trait</a>
        
      </li>
            
              <li><span class="marker">20.15.4</span><a href="#execpol.seq">Sequential execution policy</a>
        
      </li>
            
              <li><span class="marker">20.15.5</span><a href="#execpol.par">Parallel execution policy</a>
        
      </li>
            
              <li><span class="marker">20.15.6</span><a href="#execpol.vec">Parallel+Vector execution policy</a>
        
      </li>
            
              <li><span class="marker">20.15.7</span><a href="#execpol.dynamic">Dynamic execution policy</a>
        
          <ol>
            
              <li><span class="marker">20.15.7.1</span><a href="#parallel.execpol.con">execution_policy construct/assign</a>
        
      </li>
            
              <li><span class="marker">20.15.7.2</span><a href="#parallel.execpol.access">execution_policy object access</a>
        
      </li>
            
          </ol>
        
      </li>
            
              <li><span class="marker">20.15.8</span><a href="#parallel.execpol.objects">Execution policy objects</a>
        
      </li>
            
          </ol>
        
      </li>
            
          </ol>
        
      </li>
            
              <li><span class="marker">19</span><a href="#diagnostics">Diagnostics library</a>
        
          <ol>
            
              <li><span class="marker">19.6</span><a href="#exception.list">Class exception_list</a>
        
      </li>
            
          </ol>
        
      </li>
            
              <li><span class="marker">20</span><a href="#algorithms">Algorithms library</a>
        
          <ol>
            
              <li><span class="marker">20.2</span><a href="#algorithms.parallel">Parallel algorithms</a>
        
          <ol>
            
              <li><span class="marker">20.2.1</span><a href="#algorithms.parallel.defns">Terms and definitions</a>
        
      </li>
            
          </ol>
        
      </li>
            
              <li><span class="marker">20.3</span><a href="#algorithms.parallel.user">Requirements on user-provided function objects</a>
        
      </li>
            
              <li><span class="marker">20.4</span><a href="#algorithms.parallel.exec">Effect of execution policies on algorithm execution</a>
        
      </li>
            
              <li><span class="marker">20.5</span><a href="#algorithms.parallel.exceptions">Parallel algorithm exceptions</a>
        
      </li>
            
              <li><span class="marker">20.6</span><a href="#algorithms.parallel.overloads">ExecutionPolicy algorithm overloads</a>
        
      </li>
            
          </ol>
        
      </li>
            
              <li><span class="marker">25</span><a href="#algorithms">Algorithms library</a>
        
          <ol>
            
              <li><span class="marker">25.2</span><a href="#alg.nonmodifying">Non-modifying sequence operations</a>
        
          <ol>
            
              <li><span class="marker">25.2.4</span><a href="#alg.foreach">For each</a>
        
      </li>
            
          </ol>
        
      </li>
            
          </ol>
        
      </li>
            
              <li><span class="marker">26</span><a href="#numerics">Numerics library</a>
        
          <ol>
            
              <li><span class="marker">26.2</span><a href="#numerics.defns">Definitions</a>
        
      </li>
            
          </ol>
        
      </li>
            
              <li><span class="marker">26</span><a href="#numerics">Numerics library</a>
        
          <ol>
            
              <li><span class="marker">26.7</span><a href="#numerics.ops">Generalized numeric operations</a>
        
          <ol>
            
              <li><span class="marker">26.7.NaN</span><a href="#reduce">Reduce</a>
        
      </li>
            
              <li><span class="marker">26.7.NaN</span><a href="#exclusive.scan">Exclusive scan</a>
        
      </li>
            
              <li><span class="marker">26.7.NaN</span><a href="#inclusive.scan">Inclusive scan</a>
        
      </li>
            
              <li><span class="marker">26.7.NaN</span><a href="#transform.reduce">Transform reduce</a>
        
      </li>
            
              <li><span class="marker">26.7.NaN</span><a href="#transform.exclusive.scan">Transform exclusive scan</a>
        
      </li>
            
              <li><span class="marker">26.7.NaN</span><a href="#transform.inclusive.scan">Transform inclusive scan</a>
        
      </li>
            
          </ol>
        
      </li>
            
          </ol>
        
      </li>
            
          </ol>
        
      
    </nav>
  </cxx-toc>

<h1>Introducing Execution Policies</h1>
<p>Add the following entry to Table 44:</p>

<ins>
<table>
  <tbody><tr><td>20.15</td><td>Execution policies</td><td><code>&lt;execution_policy&gt;</code></td></tr>
</tbody></table>
</ins>
  
<p>Add a new subclause to Clause 20:</p>

<ins>
<cxx-clause id="utilities" number="20">
    

    <section>
      <header><span class="section-number">20</span> <h1 data-bookmark-label="20 General utilities library">General utilities library</h1> <span style="float:right"><a href="#utilities">[utilities]</a></span></header>
      
  
  <cxx-section id="execpol" number="15">
    

    <section>
      <header><span class="section-number">20.15</span> <h1 data-bookmark-label="20.15 Execution policies">Execution policies</h1> <span style="float:right"><a href="#execpol">[execpol]</a></span></header>
      
    
    <cxx-section id="execpol.general">
    

    <section>
      <header><span class="section-number">20.15.1</span> <h1 data-bookmark-label="20.15.1 In general">In general</h1> <span style="float:right"><a href="#execpol.general">[execpol.general]</a></span></header>
      
      
        <p para_num="1" id="execpol.general.1">
          This subclause describes classes that are <dfn>execution policy</dfn> types. An object
          of an execution policy type indicates the kinds of parallelism allowed in the execution
          of an algorithm and expresses the consequent requirements on the element
          access functions.
        </p>

        <cxx-example>
    
    <span class="nowrap">[ <em>Example:</em></span>
    
          <cxx-codeblock>
    
    <pre><code>std::vector&lt;int&gt; v = ...

// standard sequential sort
std::sort(v.begin(), v.end());

using namespace std::experimental::parallel;

// explicitly sequential sort
sort(seq, v.begin(), v.end());

// permitting parallel execution
sort(par, v.begin(), v.end());

// permitting vectorization as well
sort(par_vec, v.begin(), v.end());

// sort with dynamically-selected execution
size_t threshold = ...
execution_policy exec = seq;
if (v.size() &gt; threshold)
{
  exec = par;
}

sort(exec, v.begin(), v.end());</code></pre>
  </cxx-codeblock>
        
    <span class="nowrap">— <em>end example</em> ]</span>
  </cxx-example><pre></pre>

      <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
        Because different parallel architectures may require idiosyncratic
        parameters for efficient execution, implementations of the Standard Library 
        may provide additional execution policies to those described in this
        standard as extensions.
      
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
    
    </section>
  </cxx-section>

    <cxx-section id="execpol.synopsis">
    

    <section>
      <header><span class="section-number">20.15.2</span> <h1 data-bookmark-label="20.15.2 Header &lt;execution_policy&gt; synopsis">Header <code>&lt;execution_policy&gt;</code> synopsis</h1> <span style="float:right"><a href="#execpol.synopsis">[execpol.synopsis]</a></span></header>
      
      
        <cxx-codeblock>
    
    <pre><code>namespace std {
  <cxx-ref insynopsis="" to="execpol.type">// <i><a title="execpol.type" href="#execpol.type">20.15.3</a>, Execution policy type trait</i></cxx-ref>
  template&lt;class T&gt; struct is_execution_policy;
  template&lt;class T&gt; constexpr bool is_execution_policy_v = is_execution_policy&lt;T&gt;::value;

  <cxx-ref insynopsis="" to="execpol.seq">// <i><a title="execpol.seq" href="#execpol.seq">20.15.4</a>, Sequential execution policy</i></cxx-ref>
  class sequential_execution_policy;

  <cxx-ref insynopsis="" to="execpol.par">// <i><a title="execpol.par" href="#execpol.par">20.15.5</a>, Parallel execution policy</i></cxx-ref>
  class parallel_execution_policy;

  <cxx-ref insynopsis="" to="execpol.vec">// <i><a title="execpol.vec" href="#execpol.vec">20.15.6</a>, Parallel+Vector execution policy</i></cxx-ref>
  class parallel_vector_execution_policy;

  <cxx-ref insynopsis="" to="execpol.dynamic">// <i><a title="execpol.dynamic" href="#execpol.dynamic">20.15.7</a>, Dynamic execution policy</i></cxx-ref>
  class execution_policy;
}</code></pre>
  </cxx-codeblock>
    
    </section>
  </cxx-section>

    <cxx-section id="execpol.type">
    

    <section>
      <header><span class="section-number">20.15.3</span> <h1 data-bookmark-label="20.15.3 Execution policy type trait">Execution policy type trait</h1> <span style="float:right"><a href="#execpol.type">[execpol.type]</a></span></header>
      
      
<pre>template&lt;class T&gt; struct is_execution_policy { <em>see below</em> };
</pre>

    <p para_num="1" id="execpol.type.1"><code>is_execution_policy</code>
 can be used to detect parallel execution policies for the purpose of 
excluding function signatures from otherwise ambiguous overload 
resolution participation.</p>
    
    <p para_num="2" id="execpol.type.2"><code>is_execution_policy&lt;T&gt;</code> shall be a UnaryTypeTrait with a BaseCharacteristic of <code>true_type</code> if <code>T</code> is the type of a standard or implementation-defined execution policy, otherwise <code>false_type</code>.

    </p><pre></pre>

    <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
      This provision reserves the privilege of creating non-standard execution policies to the library implementation.
    
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
    
    <p para_num="3" id="execpol.type.3">The behavior of a program that adds specializations for <code>is_execution_policy</code> is undefined.</p>
    
    </section>
  </cxx-section>

    <cxx-section id="execpol.seq">
    

    <section>
      <header><span class="section-number">20.15.4</span> <h1 data-bookmark-label="20.15.4 Sequential execution policy">Sequential execution policy</h1> <span style="float:right"><a href="#execpol.seq">[execpol.seq]</a></span></header>
      
      

    <pre>class sequential_execution_policy{ <i>unspecified</i> };
</pre>

      <p para_num="1" id="execpol.seq.1">The class <code>sequential_execution_policy</code>
 is an execution policy type used as a unique type to disambiguate 
parallel algorithm overloading and require that a parallel algorithm's 
execution may not be parallelized.</p>
    
    </section>
  </cxx-section>

    <cxx-section id="execpol.par">
    

    <section>
      <header><span class="section-number">20.15.5</span> <h1 data-bookmark-label="20.15.5 Parallel execution policy">Parallel execution policy</h1> <span style="float:right"><a href="#execpol.par">[execpol.par]</a></span></header>
      
      
  
<pre>class parallel_execution_policy{ <i>unspecified</i> };
</pre>

      <p para_num="1" id="execpol.par.1">The class <code>parallel_execution_policy</code>
 is an execution policy type used as a unique type to disambiguate 
parallel algorithm overloading and indicate that a parallel algorithm's 
execution may be parallelized.</p>
    
    </section>
  </cxx-section>

    <cxx-section id="execpol.vec">
    

    <section>
      <header><span class="section-number">20.15.6</span> <h1 data-bookmark-label="20.15.6 Parallel+Vector execution policy">Parallel+Vector execution policy</h1> <span style="float:right"><a href="#execpol.vec">[execpol.vec]</a></span></header>
      
      

<pre>class parallel_vector_execution_policy{ <i>unspecified</i> };
</pre>

      <p para_num="1" id="execpol.vec.1">The class <code>class parallel_vector_execution_policy</code>
 is an execution policy type used as a unique type to disambiguate 
parallel algorithm overloading and indicate that a parallel algorithm's 
execution may be vectorized and parallelized.</p>
    
    </section>
  </cxx-section>

    <cxx-section id="execpol.dynamic">
    

    <section>
      <header><span class="section-number">20.15.7</span> <h1 data-bookmark-label="20.15.7 Dynamic execution policy">Dynamic execution policy</h1> <span style="float:right"><a href="#execpol.dynamic">[execpol.dynamic]</a></span></header>
      
      

<pre>class execution_policy
{
  public:
    <cxx-ref insynopsis="" to="parallel.execpol.con">// <i><a title="parallel.execpol.con" href="#parallel.execpol.con">20.15.7.1</a>, execution_policy construct/assign</i></cxx-ref>
    template&lt;class T&gt; execution_policy(const T&amp; exec);
    template&lt;class T&gt; execution_policy&amp; operator=(const T&amp; exec);

    <cxx-ref insynopsis="" to="parallel.execpol.access">// <i><a title="parallel.execpol.access" href="#parallel.execpol.access">20.15.7.2</a>, execution_policy object access</i></cxx-ref>
    const type_info&amp; type() const noexcept;
    template&lt;class T&gt; T* get() noexcept;
    template&lt;class T&gt; const T* get() const noexcept;
};
</pre>

      <p para_num="1" id="execpol.dynamic.1">The class <code>execution_policy</code> is a container for execution policy objects.
      <code>execution_policy</code> allows dynamic control over standard algorithm execution.</p>

      <cxx-example>
    
    <span class="nowrap">[ <em>Example:</em></span>
    
        <pre>std::vector&lt;float&gt; sort_me = ...
        
using namespace std::experimental::parallel;
execution_policy exec = seq;

if(sort_me.size() &gt; threshold)
{
  exec = std::par;
}
 
std::sort(exec, std::begin(sort_me), std::end(sort_me));</pre>
      
    <span class="nowrap">— <em>end example</em> ]</span>
  </cxx-example>

      <p para_num="2" id="execpol.dynamic.2">Objects of type <code>execution_policy</code> shall be constructible and assignable from objects of
      type <code>T</code> for which <code>is_execution_policy&lt;T&gt;::value</code> is <code>true</code>.</p>

      <cxx-section id="parallel.execpol.con">
    

    <section>
      <header><span class="section-number">20.15.7.1</span> <h1 data-bookmark-label="20.15.7.1 execution_policy construct/assign"><code>execution_policy</code> construct/assign</h1> <span style="float:right"><a href="#parallel.execpol.con">[parallel.execpol.con]</a></span></header>
      
        

        <cxx-function para_num="1" id="parallel.execpol.con.1">
    
    <pre><code><cxx-signature>template&lt;class T&gt; execution_policy(const T&amp; exec);</cxx-signature></code></pre>

    <dl>
      
          

          <cxx-effects para_num="2" id="parallel.execpol.con.2">
    
    <dt>Effects:</dt><dd>Constructs an <code>execution_policy</code> object with a copy of <code>exec</code>'s state.</dd>
  </cxx-effects>

          <cxx-remarks para_num="3" id="parallel.execpol.con.3">
    
    <dt>Remarks:</dt><dd>
            This constructor shall not participate in overload resolution unless
            <code>is_execution_policy&lt;T&gt;::value</code> is <code>true</code>.
          </dd>
  </cxx-remarks>
        
    </dl>
  </cxx-function>

        <cxx-function para_num="4" id="parallel.execpol.con.4">
    
    <pre><code><cxx-signature>template&lt;class T&gt; execution_policy&amp; operator=(const T&amp; exec);</cxx-signature></code></pre>

    <dl>
      
          

          <cxx-effects para_num="5" id="parallel.execpol.con.5">
    
    <dt>Effects:</dt><dd>Assigns a copy of <code>exec</code>'s state to <code>*this</code>.</dd>
  </cxx-effects>

          <cxx-returns para_num="6" id="parallel.execpol.con.6">
    
    <dt>Returns:</dt><dd><code>*this</code>.
        </dd>
  </cxx-returns>
    </dl>
  </cxx-function>
      
    </section>
  </cxx-section>

      <cxx-section id="parallel.execpol.access">
    

    <section>
      <header><span class="section-number">20.15.7.2</span> <h1 data-bookmark-label="20.15.7.2 execution_policy object access"><code>execution_policy</code> object access</h1> <span style="float:right"><a href="#parallel.execpol.access">[parallel.execpol.access]</a></span></header>
      
        

        <cxx-function para_num="1" id="parallel.execpol.access.1">
    
    <pre><code><cxx-signature>const type_info&amp; type() const noexcept;</cxx-signature></code></pre>

    <dl>
      
          

          <cxx-returns para_num="2" id="parallel.execpol.access.2">
    
    <dt>Returns:</dt><dd><code>typeid(T)</code>, such that <code>T</code> is the type of the execution policy object contained by <code>*this</code>.</dd>
  </cxx-returns>
        
    </dl>
  </cxx-function>

        <cxx-function para_num="3" id="parallel.execpol.access.3">
    
    <pre><code><cxx-signature>template&lt;class T&gt; T* get() noexcept;</cxx-signature><cxx-signature>template&lt;class T&gt; const T* get() const noexcept;</cxx-signature></code></pre>

    <dl>
      
        
        

          <cxx-returns para_num="4" id="parallel.execpol.access.4">
    
    <dt>Returns:</dt><dd>If <code>target_type() == typeid(T)</code>, a pointer to the stored execution policy object; otherwise a null pointer.</dd>
  </cxx-returns>

          <cxx-requires para_num="5" id="parallel.execpol.access.5">
    
    <dt>Requires:</dt><dd>
            <code>is_execution_policy&lt;T&gt;::value</code> is <code>true</code>.
          </dd>
  </cxx-requires>
        
    </dl>
  </cxx-function>
      
    </section>
  </cxx-section>
    
    </section>
  </cxx-section>

    <cxx-section id="parallel.execpol.objects">
    

    <section>
      <header><span class="section-number">20.15.8</span> <h1 data-bookmark-label="20.15.8 Execution policy objects">Execution policy objects</h1> <span style="float:right"><a href="#parallel.execpol.objects">[parallel.execpol.objects]</a></span></header>
      
      
  
<pre>constexpr sequential_execution_policy      seq{};
constexpr parallel_execution_policy        par{};
constexpr parallel_vector_execution_policy par_vec{};
</pre>

      <p para_num="1" id="parallel.execpol.objects.1">The header <code>&lt;experimental/execution_policy&gt;</code> declares a global object associated with each type of execution policy defined by this Technical Specification.</p>
    
    </section>
  </cxx-section>

  
    </section>
  </cxx-section>


    </section>
  </cxx-clause>
</ins>



<h1>Introducing <code>exception_list</code></h1>

<p>Add the following entry to Table 41:</p>

<ins>
<table>
  <tbody><tr><td>19.6</td><td>Exception list</td><td><code>&lt;exception_list&gt;</code></td></tr>
</tbody></table>
</ins>

<p>Add a new subclause to Clause 19:</p>

<ins>
<cxx-clause id="diagnostics" number="19">
    

    <section>
      <header><span class="section-number">19</span> <h1 data-bookmark-label="19 Diagnostics library">Diagnostics library</h1> <span style="float:right"><a href="#diagnostics">[diagnostics]</a></span></header>
      
  
  <cxx-section id="exception.list" number="6">
    

    <section>
      <header><span class="section-number">19.6</span> <h1 data-bookmark-label="19.6 Class exception_list">Class <code>exception_list</code></h1> <span style="float:right"><a href="#exception.list">[exception.list]</a></span></header>
      
    
    <pre>namespace std {
namespace experimental {
namespace parallel {
inline namespace v1 {

  class exception_list : public exception
  {
    public:
      typedef <em>unspecified</em> iterator;
  
      size_t size() const noexcept;
      iterator begin() const noexcept;
      iterator end() const noexcept;

      const char* what() const noexcept override;
  };
}
}
}
}
    </pre>
    <p para_num="1" id="exception.list.1">
      The class <code>exception_list</code> owns a sequence of <code>exception_ptr</code> objects. The parallel
      algorithms may use the <code>exception_list</code> to communicate uncaught exceptions encountered during parallel execution to the
      caller of the algorithm.
    </p>

    <p para_num="2" id="exception.list.2">
      The type <code>exception_list::iterator</code> shall fulfill the requirements of
      <code>ForwardIterator</code>.
    </p>

    <cxx-function para_num="3" id="exception.list.3">
    
    <pre><code><cxx-signature>size_t size() const noexcept;</cxx-signature></code></pre>

    <dl>
      
      

      <cxx-returns para_num="4" id="exception.list.4">
    
    <dt>Returns:</dt><dd>
        The number of <code>exception_ptr</code> objects contained within the <code>exception_list</code>.
      </dd>
  </cxx-returns>

      <cxx-complexity para_num="5" id="exception.list.5">
    
    <dt>Complexity:</dt><dd>
        Constant time.
      </dd>
  </cxx-complexity>
    
    </dl>
  </cxx-function>

    <cxx-function para_num="6" id="exception.list.6">
    
    <pre><code><cxx-signature>iterator begin() const noexcept;</cxx-signature></code></pre>

    <dl>
      
      

      <cxx-returns para_num="7" id="exception.list.7">
    
    <dt>Returns:</dt><dd>
        An iterator referring to the first <code>exception_ptr</code> object contained within the <code>exception_list</code>.
      </dd>
  </cxx-returns>
    
    </dl>
  </cxx-function>

    <cxx-function para_num="8" id="exception.list.8">
    
    <pre><code><cxx-signature>iterator end() const noexcept;</cxx-signature></code></pre>

    <dl>
      
      

      <cxx-returns para_num="9" id="exception.list.9">
    
    <dt>Returns:</dt><dd>
        An iterator that is past the end of the owned sequence.
      </dd>
  </cxx-returns>
    
    </dl>
  </cxx-function>

    <cxx-function para_num="10" id="exception.list.10">
    
    <pre><code><cxx-signature>const char* what() const noexcept override;</cxx-signature></code></pre>

    <dl>
      
      

      <cxx-returns para_num="11" id="exception.list.11">
    
    <dt>Returns:</dt><dd>
        An implementation-defined NTBS.
      </dd>
  </cxx-returns>
    
    </dl>
  </cxx-function>
  
    </section>
  </cxx-section>

    </section>
  </cxx-clause>
</ins>


<h1>Introducing general parallel algorithms content</h1>
<p>Add the following subclause to Clause 25:</p>

<ins>
<cxx-clause id="algorithms">
    

    <section>
      <header><span class="section-number">20</span> <h1 data-bookmark-label="20 Algorithms library">Algorithms library</h1> <span style="float:right"><a href="#algorithms">[algorithms]</a></span></header>
      
  

  <cxx-section id="algorithms.parallel" number="2">
    

    <section>
      <header><span class="section-number">20.2</span> <h1 data-bookmark-label="20.2 Parallel algorithms">Parallel algorithms</h1> <span style="float:right"><a href="#algorithms.parallel">[algorithms.parallel]</a></span></header>
      
    

    This clause describes components that C++ programs may use to perform operations on containers
    and other sequences in parallel.

    <cxx-section id="algorithms.parallel.defns">
    

    <section>
      <header><span class="section-number">20.2.1</span> <h1 data-bookmark-label="20.2.1 Terms and definitions">Terms and definitions</h1> <span style="float:right"><a href="#algorithms.parallel.defns">[algorithms.parallel.defns]</a></span></header>
      
      
        <p para_num="1" id="algorithms.parallel.defns.1">A <dfn>parallel algorithm</dfn> is a function template described by this Technical Specification declared in namespace <code>std::experimental::parallel::v1</code> with a formal template parameter named <code>ExecutionPolicy</code>.</p>

        <p para_num="2" id="algorithms.parallel.defns.2">
          Parallel algorithms access objects indirectly accessible via their arguments by invoking the following functions:
  
          </p><ul>
            <li>
              All operations of the categories of the iterators that the algorithm is instantiated with.
            </li>
  
            <li>
              Functions on those sequence elements that are required by its specification.
            </li>
  
            <li>
              User-provided function objects to be applied during the 
execution of the algorithm, if required by the specification.
            </li>

            <li>
              Operations on those function objects required by the specification.

              <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
                See clause 25.1 of <em>C++ Standard Algorithms Library</em>.
              
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
            </li>
          </ul>
  
          These functions are herein called <em>element access functions</em>.
  
          <cxx-example>
    
    <span class="nowrap">[ <em>Example:</em></span>
    
            The <code>sort</code> function may invoke the following element access functions:
  
            <ul>
              <li>
                Methods of the random-access iterator of the actual 
template argument, as per 24.2.7, as implied by the name of the
                template parameters <code>RandomAccessIterator</code>.
              </li>
  
              <li>
                The <code>swap</code> function on the elements of the sequence (as per 25.4.1.1 [sort]/2).
              </li>
  
              <li>
                The user-provided <code>Compare</code> function object.
              </li>
            </ul>
          
    <span class="nowrap">— <em>end example</em> ]</span>
  </cxx-example>
      
    </section>
  </cxx-section>
    
    </section>
  </cxx-section>

    <cxx-section id="algorithms.parallel.user">
    

    <section>
      <header><span class="section-number">20.3</span> <h1 data-bookmark-label="20.3 Requirements on user-provided function objects">Requirements on user-provided function objects</h1> <span style="float:right"><a href="#algorithms.parallel.user">[algorithms.parallel.user]</a></span></header>
      
      

      <p para_num="1" id="algorithms.parallel.user.1">
        Function objects passed into parallel algorithms as objects of type <code>BinaryPredicate</code>,
        <code>Compare</code>, and <code>BinaryOperation</code> shall not directly or indirectly modify
        objects via their arguments.
      </p>
    
    </section>
  </cxx-section>

    <cxx-section id="algorithms.parallel.exec">
    

    <section>
      <header><span class="section-number">20.4</span> <h1 data-bookmark-label="20.4 Effect of execution policies on algorithm execution">Effect of execution policies on algorithm execution</h1> <span style="float:right"><a href="#algorithms.parallel.exec">[algorithms.parallel.exec]</a></span></header>
      
      
      <p para_num="1" id="algorithms.parallel.exec.1">
        Parallel algorithms have template parameters named <code>ExecutionPolicy</code> which describe
        the manner in which the execution of these algorithms may be parallelized and the manner in
        which they apply the element access functions.
      </p>

      <p para_num="2" id="algorithms.parallel.exec.2">
        The invocations of element access functions in parallel algorithms invoked with an execution
        policy object of type <code>sequential_execution_policy</code> execute in sequential order in
        the calling thread.
      </p>

      <p para_num="3" id="algorithms.parallel.exec.3">
        The invocations of element access functions in parallel algorithms invoked with an execution
        policy object of type <code>parallel_execution_policy</code> are permitted to execute in an
        unordered fashion in either the invoking thread or in a thread implicitly created by the library
        to support parallel algorithm execution. Any such invocations executing in the same thread are
        indeterminately sequenced with respect to each other. 

        <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
          It is the caller's responsibility to ensure correctness, for example that the invocation does
          not introduce data races or deadlocks.
        
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
      </p>

      <cxx-example>
    
    <span class="nowrap">[ <em>Example:</em></span>
    <pre>using namespace std::experimental::parallel;
int a[] = {0,1};
std::vector&lt;int&gt; v;
for_each(par, std::begin(a), std::end(a), [&amp;](int i) {
  v.push_back(i*2+1);
});
</pre>

        The program above has a data race because of the unsynchronized access to the container
        <code>v</code>.
      
    <span class="nowrap">— <em>end example</em> ]</span>
  </cxx-example><pre></pre>

      <cxx-example>
    
    <span class="nowrap">[ <em>Example:</em></span>
    <pre>using namespace std::experimental::parallel;
std::atomic&lt;int&gt; x = 0;
int a[] = {1,2};
for_each(par, std::begin(a), std::end(a), [&amp;](int n) {
  x.fetch_add(1, std::memory_order_relaxed);
  // spin wait for another iteration to change the value of x
  while (x.load(std::memory_order_relaxed) == 1) { }
});</pre>

        The above example depends on the order of execution of the iterations, and is therefore
        undefined (may deadlock).
      
    <span class="nowrap">— <em>end example</em> ]</span>
  </cxx-example><pre></pre>

      <cxx-example>
    
    <span class="nowrap">[ <em>Example:</em></span>
    <pre>using namespace std::experimental::parallel;
int x=0;
std::mutex m;
int a[] = {1,2};
for_each(par, std::begin(a), std::end(a), [&amp;](int) {
  m.lock();
  ++x;
  m.unlock();
});</pre>

        The above example synchronizes access to object <code>x</code> ensuring that it is
        incremented correctly.
      
    <span class="nowrap">— <em>end example</em> ]</span>
  </cxx-example>

      <p para_num="4" id="algorithms.parallel.exec.4">
        The invocations of element access functions in parallel algorithms invoked with an execution
        policy of type <code>parallel_vector_execution_policy</code>
        are permitted to execute in an unordered fashion in unspecified threads, and unsequenced
        with respect to one another within each thread.
        <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
          This means that multiple function object invocations may be interleaved on a single thread.
        
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
      </p><pre></pre>

        <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
          This overrides the usual guarantee from the C++ standard, Section 1.9 [intro.execution] that
          function executions do not interleave with one another.
        
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
      <pre></pre>

        Since <code>parallel_vector_execution_policy</code> allows the execution of element access functions to be
        interleaved on a single thread, synchronization, including the use of mutexes, risks deadlock. Thus the
        synchronization with <code>parallel_vector_execution_policy</code> is restricted as follows:<pre></pre>

        A standard library function is <em>vectorization-unsafe</em> if it is specified to synchronize with
        another function invocation, or another function invocation is specified to synchronize with it, and if
        it is not a memory allocation or deallocation function. Vectorization-unsafe standard library functions
        may not be invoked by user code called from <code>parallel_vector_execution_policy</code> algorithms.<pre></pre>

        <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
          Implementations must ensure that internal synchronization inside standard library routines does not
          induce deadlock.
        
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
      <p para_num="5" id="algorithms.parallel.exec.5"></p>

      <cxx-example>
    
    <span class="nowrap">[ <em>Example:</em></span>
    <pre>using namespace std::experimental::parallel;
int x=0;
std::mutex m;
int a[] = {1,2};
for_each(par_vec, std::begin(a), std::end(a), [&amp;](int) {
  m.lock();
  ++x;
  m.unlock();
});</pre>

        The above program is invalid because the applications of the function object are not
        guaranteed to run on different threads.
      
    <span class="nowrap">— <em>end example</em> ]</span>
  </cxx-example><pre></pre>

      <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
        The application of the function object may result in two consecutive calls to
        <code>m.lock</code> on the same thread, which may deadlock.
      
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note><pre></pre>

      <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
        The semantics of the <code>parallel_execution_policy</code> or the
        <code>parallel_vector_execution_policy</code> invocation allow the implementation to fall back to
        sequential execution if the system cannot parallelize an algorithm invocation due to lack of
        resources.
      
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>

      <p para_num="6" id="algorithms.parallel.exec.6">
        Algorithms invoked with an execution policy object of type <code>execution_policy</code>
        execute internally as if invoked with the contained execution policy object.
      </p>

      <p para_num="7" id="algorithms.parallel.exec.7">
        The semantics of parallel algorithms invoked with an execution policy object of
        implementation-defined type are implementation-defined.
      </p>
    
    </section>
  </cxx-section>

    <cxx-section id="algorithms.parallel.exceptions">
    

    <section>
      <header><span class="section-number">20.5</span> <h1 data-bookmark-label="20.5 Parallel algorithm exceptions">Parallel algorithm exceptions</h1> <span style="float:right"><a href="#algorithms.parallel.exceptions">[algorithms.parallel.exceptions]</a></span></header>
      
      
      <p para_num="1" id="algorithms.parallel.exceptions.1">
        During the execution of a standard parallel algorithm, 
        if temporary memory resources are required and none are available,
        the algorithm throws a <code>std::bad_alloc</code> exception.
      </p>

      <p para_num="2" id="algorithms.parallel.exceptions.2">
        During the execution of a standard parallel algorithm, if the invocation of an element access function
        exits via an uncaught exception, the behavior of the program is determined by the type of
        execution policy used to invoke the algorithm:

        </p><ul>
          <li>
            If the execution policy object is of type <code>class parallel_vector_execution_policy</code>,
            <code>std::terminate</code> shall be called.
          </li>

          <li>
            If the execution policy object is of type <code>sequential_execution_policy</code> or
            <code>parallel_execution_policy</code>, the execution of the algorithm exits via an exception. The
            exception shall be an <code>exception_list</code> containing all uncaught exceptions thrown during
            the invocations of element access functions, or optionally the uncaught exception if there was only one.

            <p>
              <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    For example, when <code>for_each</code> is executed sequentially, if an invocation of the user-provided
              function object throws an exception, <code>for_each</code> can exit via the uncaught exception, or throw an
              <code>exception_list</code> containing the original exception.
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
            </p>

            <p>
              <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    These guarantees imply that, unless the algorithm has failed to allocate memory and exits via
              <code>std::bad_alloc</code>, all exceptions thrown during the execution of the algorithm are communicated to the
              caller. It is unspecified whether an algorithm implementation will "forge ahead" after encountering and capturing
              a user exception.
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
            </p>

            <p>
              <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    The algorithm may exit via the <code>std::bad_alloc</code> exception
 even if one or more user-provided
              function objects have exited via an exception. For 
example, this can happen when an algorithm fails to allocate memory 
while
              creating or adding elements to the <code>exception_list</code> object.
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
            </p>
          </li>

          <li>
            If the execution policy object is of any other type, the behavior is implementation-defined.
          </li>
        </ul>
      <p para_num="3" id="algorithms.parallel.exceptions.3"></p>
    
    </section>
  </cxx-section>

    <cxx-section id="algorithms.parallel.overloads">
    

    <section>
      <header><span class="section-number">20.6</span> <h1 data-bookmark-label="20.6 ExecutionPolicy algorithm overloads"><code>ExecutionPolicy</code> algorithm overloads</h1> <span style="float:right"><a href="#algorithms.parallel.overloads">[algorithms.parallel.overloads]</a></span></header>
      
      

      <p para_num="1" id="algorithms.parallel.overloads.1">
        The Parallel Algorithms Library provides overloads for each of the algorithms named in
        Table 1, corresponding to the algorithms with the same name in the C++ Standard Algorithms Library.
        
        For each algorithm in <cxx-ref to="tab.parallel.algorithms"><a title="tab.parallel.algorithms" href="#tab.parallel.algorithms">Table 1</a></cxx-ref>, if there are overloads for
        corresponding algorithms with the same name
        in the C++ Standard Algorithms Library,
        the overloads shall have an additional template type parameter named
        <code>ExecutionPolicy</code>, which shall be the first template parameter.
        
        In addition, each such overload shall have the new function parameter as the
        first function parameter of type <code>ExecutionPolicy&amp;&amp;</code>.
      </p>

      <p para_num="2" id="algorithms.parallel.overloads.2">
        Unless otherwise specified, the semantics of <code>ExecutionPolicy</code> algorithm overloads
        are identical to their overloads without.
      </p>

      <p para_num="3" id="algorithms.parallel.overloads.3">
        Parallel algorithms shall not participate in overload resolution unless
        <code>is_execution_policy&lt;decay_t&lt;ExecutionPolicy&gt;&gt;::value</code> is <code>true</code>.
      </p>

      <table role="presentation" is="cxx-table" id="tab.parallel.algorithms" class="list">
    

    <caption>Table 1 — <wbr><span>Table of parallel algorithms</span></caption>
    
        
          <tbody><tr>
            <td><code>adjacent_difference</code></td>
            <td><code>adjacent_find</code></td>
            <td><code>all_of</code></td>
            <td><code>any_of</code></td>
          </tr>
          <tr>
            <td><code>copy</code></td>
            <td><code>copy_if</code></td>
            <td><code>copy_n</code></td>
            <td><code>count</code></td>
          </tr>
          <tr>
            <td><code>count_if</code></td>
            <td><code>equal</code></td>
            <td><code>exclusive_scan</code></td>
            <td><code>fill</code></td>
          </tr>
          <tr>
            <td><code>fill_n</code></td>
            <td><code>find</code></td>
            <td><code>find_end</code></td>
            <td><code>find_first_of</code></td>
          </tr>
          <tr>
            <td><code>find_if</code></td>
            <td><code>find_if_not</code></td>
            <td><code>for_each</code></td>
            <td><code>for_each_n</code></td>
          </tr>
          <tr>
            <td><code>generate</code></td>
            <td><code>generate_n</code></td>
            <td><code>includes</code></td>
            <td><code>inclusive_scan</code></td>
          </tr>
          <tr>
            <td><code>inner_product</code></td>
            <td><code>inplace_merge</code></td>
            <td><code>is_heap</code></td>
            <td><code>is_heap_until</code></td>
          </tr>
          <tr>
            <td><code>is_partitioned</code></td>
            <td><code>is_sorted</code></td>
            <td><code>is_sorted_until</code></td>
            <td><code>lexicographical_compare</code></td>
          </tr>
          <tr>
            <td><code>max_element</code></td>
            <td><code>merge</code></td>
            <td><code>min_element</code></td>
            <td><code>minmax_element</code></td>
          </tr>
          <tr>
            <td><code>mismatch</code></td>
            <td><code>move</code></td>
            <td><code>none_of</code></td>
            <td><code>nth_element</code></td>
          </tr>
          <tr>
            <td><code>partial_sort</code></td>
            <td><code>partial_sort_copy</code></td>
            <td><code>partition</code></td>
            <td><code>partition_copy</code></td>
          </tr>
          <tr>
            <td><code>reduce</code></td>
            <td><code>remove</code></td>
            <td><code>remove_copy</code></td>
            <td><code>remove_copy_if</code></td>
          </tr>
          <tr>
            <td><code>remove_if</code></td>
            <td><code>replace</code></td>
            <td><code>replace_copy</code></td>
            <td><code>replace_copy_if</code></td>
          </tr>
          <tr>
            <td><code>replace_if</code></td>
            <td><code>reverse</code></td>
            <td><code>reverse_copy</code></td>
            <td><code>rotate</code></td>
          </tr>
          <tr>
            <td><code>rotate_copy</code></td>
            <td><code>search</code></td>
            <td><code>search_n</code></td>
            <td><code>set_difference</code></td>
          </tr>
          <tr>
            <td><code>set_intersection</code></td>
            <td><code>set_symmetric_difference</code></td>
            <td><code>set_union</code></td>
            <td><code>sort</code></td>
          </tr>
          <tr>
            <td><code>stable_partition</code></td>
            <td><code>stable_sort</code></td>
            <td><code>swap_ranges</code></td>
            <td><code>transform</code></td>
          </tr>
          <tr>
            <td><code>transform_exclusive_scan</code></td>
            <td><code>transform_inclusive_scan</code></td>
            <td><code>transform_reduce</code></td>
            <td><code>uninitialized_copy</code></td>
          </tr>
          <tr>
            <td><code>uninitialized_copy_n</code></td>
            <td><code>uninitialized_fill</code></td>
            <td><code>uninitialized_fill_n</code></td>
            <td><code>unique</code></td>
          </tr>
          <tr>
            <td><code>unique_copy</code></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
      </tbody>
  </table>

      <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
        Not all algorithms in the Standard Library have counterparts in <cxx-ref to="tab.parallel.algorithms"><a title="tab.parallel.algorithms" href="#tab.parallel.algorithms">Table 1</a></cxx-ref>.
      
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
    
    </section>
  </cxx-section>
  

    </section>
  </cxx-clause>
</ins>

<h1>Modifications to header synopses</h1>
For each algorithm listed in <cxx-ref to="tab.parallel.algorithms"><a title="tab.parallel.algorithms" href="#tab.parallel.algorithms">Table 1</a></cxx-ref>, add the signature of a parallel algorithm overload to the corresponding synopsis in Clause 20, Clause 25, or Clause 26.

<h1>Specify new algorithms</h1>

Add <code>for_each</code> with <code>ExecutionPolicy</code>, sequential <code>for_each_n</code>, and <code>for_each_n</code> with <code>ExecutionPolicy</code> to subclause 4.3.2:

<ins>
<cxx-clause id="algorithms" number="25">
    

    <section>
      <header><span class="section-number">25</span> <h1 data-bookmark-label="25 Algorithms library">Algorithms library</h1> <span style="float:right"><a href="#algorithms">[algorithms]</a></span></header>
      
  

  <cxx-section id="alg.nonmodifying" number="2">
    

    <section>
      <header><span class="section-number">25.2</span> <h1 data-bookmark-label="25.2 Non-modifying sequence operations">Non-modifying sequence operations</h1> <span style="float:right"><a href="#alg.nonmodifying">[alg.nonmodifying]</a></span></header>
      
    

    <cxx-section id="alg.foreach" number="4">
    

    <section>
      <header><span class="section-number">25.2.4</span> <h1 data-bookmark-label="25.2.4 For each">For each</h1> <span style="float:right"><a href="#alg.foreach">[alg.foreach]</a></span></header>
      
      

      <cxx-function para_num="1" id="alg.foreach.1">
    
    <pre><code><cxx-signature>template&lt;class ExecutionPolicy,
      class InputIterator, class Function&gt;
void for_each(ExecutionPolicy&amp;&amp; exec,
              InputIterator first, InputIterator last,
              Function f);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-effects para_num="2" id="alg.foreach.2">
    
    <dt>Effects:</dt><dd>
          Applies <code>f</code> to the result of dereferencing every iterator in the range <code>[first,last)</code>.

          <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
            If the type of <code>first</code> satisfies the requirements of a mutable iterator, <code>f</code> may
            apply nonconstant functions through the dereferenced iterator.
          
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
        </dd>
  </cxx-effects>

        <cxx-complexity para_num="3" id="alg.foreach.3">
    
    <dt>Complexity:</dt><dd>
          Applies <code>f</code> exactly <code>last - first</code> times.
        </dd>
  </cxx-complexity>
        
        <cxx-remarks para_num="4" id="alg.foreach.4">
    
    <dt>Remarks:</dt><dd>
          If <code>f</code> returns a result, the result is ignored.
        </dd>
  </cxx-remarks>

        <cxx-notes para_num="5" id="alg.foreach.5">
    
    <dt>Notes:</dt><dd>
          Unlike its sequential form, the parallel overload of <code>for_each</code> does not return a copy of
          its <code>Function</code> parameter, since parallelization may not permit efficient state
          accumulation.
        </dd>
  </cxx-notes>
        <cxx-requires para_num="6" id="alg.foreach.6">
    
    <dt>Requires:</dt><dd>
          Unlike its sequential form, the parallel overload of <code>for_each</code> requires
          <code>Function</code> to meet the requirements of <code>CopyConstructible</code>.
        </dd>
  </cxx-requires>
      
    </dl>
  </cxx-function>

      <cxx-function para_num="7" id="alg.foreach.7">
    
    <pre><code><cxx-signature>template&lt;class InputIterator, class Size, class Function&gt;
InputIterator for_each_n(InputIterator first, Size n,
                         Function f);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-requires para_num="8" id="alg.foreach.8">
    
    <dt>Requires:</dt><dd>
          <code>Function</code> shall meet the requirements of <code>MoveConstructible</code>
          
          <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
            <code>Function</code> need not meet the requirements of <code>CopyConstructible</code>.
          
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
        </dd>
  </cxx-requires>

        <cxx-effects para_num="9" id="alg.foreach.9">
    
    <dt>Effects:</dt><dd>
          Applies <code>f</code> to the result of dereferencing every iterator in the range
          <code>[first,first + n)</code>, starting from <code>first</code> and proceeding to <code>first + n - 1</code>.

          <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
            If the type of <code>first</code> satisfies the requirements of a mutable iterator,
            <code>f</code> may apply nonconstant functions through the dereferenced iterator.
          
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
        </dd>
  </cxx-effects>

        <cxx-returns para_num="10" id="alg.foreach.10">
    
    <dt>Returns:</dt><dd>
          <code>first + n</code> for non-negative values of <code>n</code> and <code>first</code> for negative values.
        </dd>
  </cxx-returns>

        <cxx-remarks para_num="11" id="alg.foreach.11">
    
    <dt>Remarks:</dt><dd>
          If <code>f</code> returns a result, the result is ignored.
        </dd>
  </cxx-remarks>
      
    </dl>
  </cxx-function>

      <cxx-function para_num="12" id="alg.foreach.12">
    
    <pre><code><cxx-signature>template&lt;class ExecutionPolicy,
      class InputIterator, class Size, class Function&gt;
InputIterator for_each_n(ExecutionPolicy &amp;&amp; exec,
                         InputIterator first, Size n,
                         Function f);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-effects para_num="13" id="alg.foreach.13">
    
    <dt>Effects:</dt><dd>
          Applies <code>f</code> to the result of dereferencing every iterator in the range
          <code>[first,first + n)</code>, starting from <code>first</code> and proceeding to <code>first + n - 1</code>.

          <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
            If the type of <code>first</code> satisfies the requirements of a mutable iterator,
            <code>f</code> may apply nonconstant functions through the dereferenced iterator.
          
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
        </dd>
  </cxx-effects>

        <cxx-returns para_num="14" id="alg.foreach.14">
    
    <dt>Returns:</dt><dd>
        <code>first + n</code> for non-negative values of <code>n</code> and <code>first</code> for negative values.
        </dd>
  </cxx-returns>

        <cxx-remarks para_num="15" id="alg.foreach.15">
    
    <dt>Remarks:</dt><dd>
          If <code>f</code> returns a result, the result is ignored.
        </dd>
  </cxx-remarks>

        <cxx-notes para_num="16" id="alg.foreach.16">
    
    <dt>Notes:</dt><dd>
          Unlike its sequential form, the parallel overload of <code>for_each_n</code> requires
          <code>Function</code> to meet the requirements of <code>CopyConstructible</code>.
        </dd>
  </cxx-notes>
      
    </dl>
  </cxx-function>
    
    </section>
  </cxx-section>
  
    </section>
  </cxx-section>

    </section>
  </cxx-clause>
</ins>

<h1>Introducing numeric parallel algorithms definitions</h1>
<p>Insert the following entry to Table 113:</p>

<ins>
<table>
  <tbody><tr><td>26.2</td><td>Definitions</td><td></td></tr>
</tbody></table>
</ins>

<p>Insert the following subclause to Clause 26:</p>

<ins>
<cxx-clause id="numerics" number="26">
    

    <section>
      <header><span class="section-number">26</span> <h1 data-bookmark-label="26 Numerics library">Numerics library</h1> <span style="float:right"><a href="#numerics">[numerics]</a></span></header>
      
  

  <cxx-section id="numerics.defns" number="2">
    

    <section>
      <header><span class="section-number">26.2</span> <h1 data-bookmark-label="26.2 Definitions">Definitions</h1> <span style="float:right"><a href="#numerics.defns">[numerics.defns]</a></span></header>
      
    

    <p para_num="1" id="numerics.defns.1">
      Define <code><em>GENERALIZED_SUM</em>(op, a1, ..., aN)</code> as follows:

      </p><ul>
        <li><code>a1</code> when <code>N</code> is <code>1</code></li>
      
        <li>
          <code>op(<em>GENERALIZED_SUM</em>(op, b1, ..., bK)</code>, <code><em>GENERALIZED_SUM</em>(op, bM, ..., bN))</code> where
           
          <ul>
            <li><code>b1, ..., bN</code> may be any permutation of <code>a1, ..., aN</code> and</li>

            <li><code>1 &lt; K+1 = M ≤ N</code>.</li>
          </ul>
        </li>
      </ul>
    <p para_num="2" id="numerics.defns.2"></p>

    <p para_num="3" id="numerics.defns.3">
      Define <code><em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(op, a1, ..., aN)</code> as follows:

      </p><ul>
        <li><code>a1</code> when <code>N</code> is <code>1</code></li>

        <li>
          <code>op(<em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(op, a1, ..., aK), <em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(op, aM, </code><br>
          <code>..., aN)</code> where <code>1 &lt; K+1 = M ≤ N</code>.
        </li>
      </ul>
    <p para_num="4" id="numerics.defns.4"></p>
  
    </section>
  </cxx-section>

    </section>
  </cxx-clause>
</ins>

<h1>Specify new numeric algorithms</h1>

Add <code>reduce</code>, <code>exclusive_scan</code>, <code>inclusive_scan</code>, <code>transform_reduce</code>, <code>transform_exclusive_scan</code>, and <code>transform_inclusive_scan</code> to Clause 26.7.

The innermost section number is given as NaN to allow editorial discretion.

<ins>
<cxx-clause id="numerics" number="26">
    

    <section>
      <header><span class="section-number">26</span> <h1 data-bookmark-label="26 Numerics library">Numerics library</h1> <span style="float:right"><a href="#numerics">[numerics]</a></span></header>
      
  

  <cxx-section id="numerics.ops" number="7">
    

    <section>
      <header><span class="section-number">26.7</span> <h1 data-bookmark-label="26.7 Generalized numeric operations">Generalized numeric operations</h1> <span style="float:right"><a href="#numerics.ops">[numerics.ops]</a></span></header>
      
    

    <cxx-section id="reduce" number="?">
    

    <section>
      <header><span class="section-number">26.7.NaN</span> <h1 data-bookmark-label="26.7.NaN Reduce">Reduce</h1> <span style="float:right"><a href="#reduce">[reduce]</a></span></header>
      
      

      <cxx-function para_num="1" id="reduce.1">
    
    <pre><code><cxx-signature>template&lt;class InputIterator&gt;
typename iterator_traits&lt;InputIterator&gt;::value_type
    reduce(InputIterator first, InputIterator last);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-effects para_num="2" id="reduce.2">
    
    <dt>Effects:</dt><dd>
          Same as <code>reduce(first, last, typename iterator_traits&lt;InputIterator&gt;::value_type{})</code>.
        </dd>
  </cxx-effects>
      
    </dl>
  </cxx-function>

      <cxx-function para_num="3" id="reduce.3">
    
    <pre><code><cxx-signature>template&lt;class InputIterator, class T&gt;
T reduce(InputIterator first, InputIterator last, T init);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-effects para_num="4" id="reduce.4">
    
    <dt>Effects:</dt><dd>
          Same as <code>reduce(first, last, init, plus&lt;&gt;())</code>.
        </dd>
  </cxx-effects>
      
    </dl>
  </cxx-function>

      <cxx-function para_num="5" id="reduce.5">
    
    <pre><code><cxx-signature>template&lt;class InputIterator, class T, class BinaryOperation&gt;
T reduce(InputIterator first, InputIterator last, T init,
         BinaryOperation binary_op);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-returns para_num="6" id="reduce.6">
    
    <dt>Returns:</dt><dd>
          <code><em>GENERALIZED_SUM</em>(binary_op, init, *first, ..., *(first + (last - first) - 1))</code>.
        </dd>
  </cxx-returns>

        <cxx-requires para_num="7" id="reduce.7">
    
    <dt>Requires:</dt><dd>
          <code>binary_op</code> shall not invalidate iterators or subranges, nor modify elements in the
          range <code>[first,last)</code>.
        </dd>
  </cxx-requires>

        <cxx-complexity para_num="8" id="reduce.8">
    
    <dt>Complexity:</dt><dd>
          O(<code>last - first</code>) applications of <code>binary_op</code>.
        </dd>
  </cxx-complexity>

        <cxx-notes para_num="9" id="reduce.9">
    
    <dt>Notes:</dt><dd>
          The primary difference between <code>reduce</code> and <code>accumulate</code> is that the behavior
          of <code>reduce</code> may be non-deterministic for non-associative or non-commutative <code>binary_op</code>.
        </dd>
  </cxx-notes>
      
    </dl>
  </cxx-function>
    
    </section>
  </cxx-section>

    <cxx-section id="exclusive.scan">
    

    <section>
      <header><span class="section-number">26.7.NaN</span> <h1 data-bookmark-label="26.7.NaN Exclusive scan">Exclusive scan</h1> <span style="float:right"><a href="#exclusive.scan">[exclusive.scan]</a></span></header>
      
      

      <cxx-function para_num="1" id="exclusive.scan.1">
    
    <pre><code><cxx-signature>template&lt;class InputIterator, class OutputIterator, class T&gt;
OutputIterator exclusive_scan(InputIterator first, InputIterator last,
                              OutputIterator result,
                              T init);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-effects para_num="2" id="exclusive.scan.2">
    
    <dt>Effects:</dt><dd>
          Same as <code>exclusive_scan(first, last, result, init, plus&lt;&gt;())</code>.
        </dd>
  </cxx-effects>
      
    </dl>
  </cxx-function>

      <cxx-function para_num="3" id="exclusive.scan.3">
    
    <pre><code><cxx-signature>template&lt;class InputIterator, class OutputIterator, class T, class BinaryOperation&gt;
OutputIterator exclusive_scan(InputIterator first, InputIterator last,
                              OutputIterator result,
                              T init, BinaryOperation binary_op);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-effects para_num="4" id="exclusive.scan.4">
    
    <dt>Effects:</dt><dd>
          Assigns through each iterator <code>i</code> in <code>[result,result + (last - first))</code> the
          value of <code><em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(binary_op, init, *first, ..., *(first + (i - result) - 1))</code>.
        </dd>
  </cxx-effects>

        <cxx-returns para_num="5" id="exclusive.scan.5">
    
    <dt>Returns:</dt><dd>
          The end of the resulting range beginning at <code>result</code>.
        </dd>
  </cxx-returns>

        <cxx-requires para_num="6" id="exclusive.scan.6">
    
    <dt>Requires:</dt><dd>
          <code>binary_op</code> shall not invalidate iterators or subranges, nor modify elements in the
          ranges <code>[first,last)</code> or <code>[result,result + (last - first))</code>.
        </dd>
  </cxx-requires>

        <cxx-complexity para_num="7" id="exclusive.scan.7">
    
    <dt>Complexity:</dt><dd>
          O(<code>last - first</code>) applications of <code>binary_op</code>.
        </dd>
  </cxx-complexity>

        <cxx-notes para_num="8" id="exclusive.scan.8">
    
    <dt>Notes:</dt><dd>
          The difference between <code>exclusive_scan</code> and <code>inclusive_scan</code> is that
          <code>exclusive_scan</code> excludes the <code>i</code>th input element from the <code>i</code>th
          sum. If <code>binary_op</code> is not mathematically associative, the behavior of
          <code>exclusive_scan</code> may be non-deterministic.
        </dd>
  </cxx-notes>
      
    </dl>
  </cxx-function>
    
    </section>
  </cxx-section>

    <cxx-section id="inclusive.scan">
    

    <section>
      <header><span class="section-number">26.7.NaN</span> <h1 data-bookmark-label="26.7.NaN Inclusive scan">Inclusive scan</h1> <span style="float:right"><a href="#inclusive.scan">[inclusive.scan]</a></span></header>
      
      

      <cxx-function para_num="1" id="inclusive.scan.1">
    
    <pre><code><cxx-signature>template&lt;class InputIterator, class OutputIterator&gt;
OutputIterator inclusive_scan(InputIterator first, InputIterator last,
                              OutputIterator result);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-effects para_num="2" id="inclusive.scan.2">
    
    <dt>Effects:</dt><dd>
          Same as <code>inclusive_scan(first, last, result, plus&lt;&gt;())</code>.
        </dd>
  </cxx-effects>
      
    </dl>
  </cxx-function>

      <cxx-function para_num="3" id="inclusive.scan.3">
    
    <pre><code><cxx-signature>template&lt;class InputIterator, class OutputIterator, class BinaryOperation&gt;
OutputIterator inclusive_scan(InputIterator first, InputIterator last,
                              OutputIterator result,
                              BinaryOperation binary_op);</cxx-signature><cxx-signature>template&lt;class InputIterator, class OutputIterator, class BinaryOperation&gt;
OutputIterator inclusive_scan(InputIterator first, InputIterator last,
                              OutputIterator result,
                              BinaryOperation binary_op, T init);</cxx-signature></code></pre>

    <dl>
      
        
        

        <cxx-effects para_num="4" id="inclusive.scan.4">
    
    <dt>Effects:</dt><dd>
          Assigns through each iterator <code>i</code> in <code>[result,result + (last - first))</code> the value of
          <code><em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(binary_op, *first, ..., *(first + (i - result)))</code> or
          <code><em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(binary_op, init, *first, ..., *(first + (i - result)))</code>
          if <code>init</code> is provided.
        </dd>
  </cxx-effects>

        <cxx-returns para_num="5" id="inclusive.scan.5">
    
    <dt>Returns:</dt><dd>
          The end of the resulting range beginning at <code>result</code>.
        </dd>
  </cxx-returns>

        <cxx-requires para_num="6" id="inclusive.scan.6">
    
    <dt>Requires:</dt><dd>
          <code>binary_op</code> shall not invalidate iterators or subranges, nor modify elements in the 
          ranges <code>[first,last)</code> or <code>[result,result + (last - first))</code>.
        </dd>
  </cxx-requires>

        <cxx-complexity para_num="7" id="inclusive.scan.7">
    
    <dt>Complexity:</dt><dd>
          O(<code>last - first</code>) applications of <code>binary_op</code>.
        </dd>
  </cxx-complexity>

        <cxx-notes para_num="8" id="inclusive.scan.8">
    
    <dt>Notes:</dt><dd>
          The difference between <code>exclusive_scan</code> and <code>inclusive_scan</code> is that
          <code>inclusive_scan</code> includes the <code>i</code>th input element in the <code>i</code>th sum.
          If <code>binary_op</code> is not mathematically associative, the behavior of
          <code>inclusive_scan</code> may be non-deterministic.
        </dd>
  </cxx-notes>
      
    </dl>
  </cxx-function>
    
    </section>
  </cxx-section>

    <cxx-section id="transform.reduce">
    

    <section>
      <header><span class="section-number">26.7.NaN</span> <h1 data-bookmark-label="26.7.NaN Transform reduce">Transform reduce</h1> <span style="float:right"><a href="#transform.reduce">[transform.reduce]</a></span></header>
      
      

      <cxx-function para_num="1" id="transform.reduce.1">
    
    <pre><code><cxx-signature>template&lt;class InputIterator, class UnaryFunction, class T, class BinaryOperation&gt;
T transform_reduce(InputIterator first, InputIterator last,
                   UnaryOperation unary_op, T init, BinaryOperation binary_op);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-returns para_num="2" id="transform.reduce.2">
    
    <dt>Returns:</dt><dd>
          <code><em>GENERALIZED_SUM</em>(binary_op, init, unary_op(*first), ..., unary_op(*(first + (last - first) -</code><br>
          <code>1)))</code>.
        </dd>
  </cxx-returns>

        <cxx-requires para_num="3" id="transform.reduce.3">
    
    <dt>Requires:</dt><dd>
          Neither <code>unary_op</code> nor <code>binary_op</code> shall invalidate subranges, or modify elements in the range <code>[first,last)</code>
        </dd>
  </cxx-requires>

        <cxx-complexity para_num="4" id="transform.reduce.4">
    
    <dt>Complexity:</dt><dd>
          O(<code>last - first</code>) applications each of <code>unary_op</code> and <code>binary_op</code>.
        </dd>
  </cxx-complexity>

        <cxx-notes para_num="5" id="transform.reduce.5">
    
    <dt>Notes:</dt><dd>
          <code>transform_reduce</code> does not apply <code>unary_op</code> to <code>init</code>.
        </dd>
  </cxx-notes>
      
    </dl>
  </cxx-function>
    
    </section>
  </cxx-section>

    <cxx-section id="transform.exclusive.scan">
    

    <section>
      <header><span class="section-number">26.7.NaN</span> <h1 data-bookmark-label="26.7.NaN Transform exclusive scan">Transform exclusive scan</h1> <span style="float:right"><a href="#transform.exclusive.scan">[transform.exclusive.scan]</a></span></header>
      
      

      <cxx-function para_num="1" id="transform.exclusive.scan.1">
    
    <pre><code><cxx-signature>template&lt;class InputIterator, class OutputIterator,
      class UnaryOperation,
      class T, class BinaryOperation&gt;
OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last,
                                        OutputIterator result,
                                        UnaryOperation unary_op,
                                        T init, BinaryOperation binary_op);</cxx-signature></code></pre>

    <dl>
      
        

        <cxx-effects para_num="2" id="transform.exclusive.scan.2">
    
    <dt>Effects:</dt><dd>
          Assigns through each iterator <code>i</code> in <code>[result,result + (last - first))</code> the value of
          <code><em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(binary_op, init, unary_op(*first), ..., unary_op(*(first + (i</code><br>
          <code>- result) - 1)))</code>.
        </dd>
  </cxx-effects>

        <cxx-returns para_num="3" id="transform.exclusive.scan.3">
    
    <dt>Returns:</dt><dd>
          The end of the resulting range beginning at <code>result</code>.
        </dd>
  </cxx-returns>

        <cxx-requires para_num="4" id="transform.exclusive.scan.4">
    
    <dt>Requires:</dt><dd>
          Neither <code>unary_op</code> nor <code>binary_op</code> shall invalidate iterators or subranges, or modify elements in the
          ranges <code>[first,last)</code> or <code>[result,result + (last - first))</code>.
        </dd>
  </cxx-requires>

        <cxx-complexity para_num="5" id="transform.exclusive.scan.5">
    
    <dt>Complexity:</dt><dd>
          O(<code>last - first</code>) applications each of <code>unary_op</code> and <code>binary_op</code>.
        </dd>
  </cxx-complexity>

        <cxx-notes para_num="6" id="transform.exclusive.scan.6">
    
    <dt>Notes:</dt><dd>
          The difference between <code>transform_exclusive_scan</code> and <code>transform_inclusive_scan</code> is that <code>transform_exclusive_scan</code>
          excludes the ith input element from the ith sum. If <code>binary_op</code> is not mathematically associative, the behavior of
          <code>transform_exclusive_scan</code> may be non-deterministic. <code>transform_exclusive_scan</code> does not apply <code>unary_op</code> to <code>init</code>.
        </dd>
  </cxx-notes>
      
    </dl>
  </cxx-function>
    
    </section>
  </cxx-section>

    <cxx-section id="transform.inclusive.scan">
    

    <section>
      <header><span class="section-number">26.7.NaN</span> <h1 data-bookmark-label="26.7.NaN Transform inclusive scan">Transform inclusive scan</h1> <span style="float:right"><a href="#transform.inclusive.scan">[transform.inclusive.scan]</a></span></header>
      
      

      <cxx-function para_num="1" id="transform.inclusive.scan.1">
    
    <pre><code><cxx-signature>template&lt;class InputIterator, class OutputIterator,
      class UnaryOperation,
      class BinaryOperation&gt;
OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
                                        OutputIterator result,
                                        UnaryOperation unary_op,
                                        BinaryOperation binary_op);</cxx-signature><cxx-signature>template&lt;class InputIterator, class OutputIterator,
      class UnaryOperation,
      class BinaryOperation, class T&gt;
OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
                                        OutputIterator result,
                                        UnaryOperation unary_op,
                                        BinaryOperation binary_op, T init);</cxx-signature></code></pre>

    <dl>
      
        

        

        <cxx-effects para_num="2" id="transform.inclusive.scan.2">
    
    <dt>Effects:</dt><dd>
          Assigns through each iterator <code>i</code> in <code>[result,result + (last - first))</code> the value of
          <code><em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(binary_op, unary_op(*first), ..., unary_op(*(first + (i -</code><br>
          <code>result))))</code> or
          <code><em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(binary_op, init, unary_op(*first), ..., unary_op(*(first + (i</code><br>
          <code>- result))))</code>
          if <code>init</code> is provided.
        </dd>
  </cxx-effects>

        <cxx-returns para_num="3" id="transform.inclusive.scan.3">
    
    <dt>Returns:</dt><dd>
          The end of the resulting range beginning at <code>result</code>.
        </dd>
  </cxx-returns>

        <cxx-requires para_num="4" id="transform.inclusive.scan.4">
    
    <dt>Requires:</dt><dd>
          Neither <code>unary_op</code> nor <code>binary_op</code> shall invalidate iterators or subranges, or modify elements in the ranges <code>[first,last)</code>
          or <code>[result,result + (last - first))</code>.
        </dd>
  </cxx-requires>

        <cxx-complexity para_num="5" id="transform.inclusive.scan.5">
    
    <dt>Complexity:</dt><dd>
          O(<code>last - first</code>) applications each of <code>unary_op</code> and <code>binary_op</code>.
        </dd>
  </cxx-complexity>

        <cxx-notes para_num="6" id="transform.inclusive.scan.6">
    
    <dt>Notes:</dt><dd>
          The difference between <code>transform_exclusive_scan</code> and <code>transform_inclusive_scan</code> is that <code>transform_inclusive_scan</code>
          includes the ith input element from the ith sum. If <code>binary_op</code> is not mathematically associative, the behavior of
          <code>transform_inclusive_scan</code> may be non-deterministic. <code>transform_inclusive_scan</code> does not apply <code>unary_op</code> to <code>init</code>.
        </dd>
  </cxx-notes>
      
    </dl>
  </cxx-function>
    
    </section>
  </cxx-section>
  
    </section>
  </cxx-section>

    </section>
  </cxx-clause>
</ins>








</body></html>
