<!DOCTYPE html>
<!-- Sources at https://github.com/cplusplus/fundamentals-ts -->
<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-TITLEPAGE");document.createElement("CXX-DOCNUM");document.createElement("CXX-REVISES");document.createElement("CXX-EDITOR");document.createElement("CXX-EMAIL");document.createElement("CXX-TOC");document.createElement("CXX-CLAUSE");document.createElement("CXX-SECTION");document.createElement("CXX-REF");document.createElement("CXX-FOOTNOTE");document.createElement("CXX-FOREIGN-INDEX");document.createElement("CXX-NOTE");document.createElement("CXX-FUNCTION");document.createElement("CXX-SIGNATURE");document.createElement("CXX-EFFECTS");document.createElement("CXX-POSTCONDITIONS");document.createElement("CXX-NOTES");document.createElement("CXX-EXAMPLE");document.createElement("CXX-RETURNS");document.createElement("CXX-REQUIRES");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; } 
</style><style shim-shadowdom-css="">style { display: none !important; }
cxx-function {
	display: block;
}

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;
}

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;
}

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].center td {
	text-align: center;
}

[is=cxx-table].list td {
	border: medium none;
}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;
}core-xhr {
	display: none;
}cxx-foreign-index {
	display: none;
}cxx-titlepage {
	display: block; min-height: 100%;
}

cxx-titlepage  {
	position: relative;
}

cxx-titlepage table {
	position: absolute; right: 0px; top: 0px;
}

cxx-titlepage h1 {
	position: absolute; top: 40%;
}

cxx-titlepage p.warning {
	position: absolute; bottom: 5%;
}

cxx-titlepage h1 {
	text-align: center;
}

cxx-titlepage th {
	text-align: left; vertical-align: top;
}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-note .nowrap {
	white-space: nowrap;
}cxx-footnote {
	font-family: serif; white-space: normal; text-indent: initial;textIndent: initial; 
}

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


}

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

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;
}</style>
  <meta charset="utf-8">
  
  <link rel="import" href="bower_components/cxx-html-doc-framework/framework.html">
<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%;
    @top-left { content: "© ISO/IEC"; font-size: 10pt; }
    @top-right { content: string(docnum); font-weight: bold; font-size: 10pt; }
    @bottom-left { content: string(current-section, last); font-size: 10pt; }
    @bottom-right { content: counter(page); font-size: 10pt; }
}
cxx-titlepage { page: title; page-break-after: always; }
@page title {
    @top-left { content: "© ISO 2014 — All rights reserved"; }
    @top-right { content: normal; }
    @bottom-left { content: normal; }
    @bottom-right { content: normal; }
}

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

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

/* Needed to make the <cxx-titlepage>'s vertical spacing work. */
html, body {height: 100%}

cxx-docnum { string-set: docnum content(); }

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

cxx-clause  header { 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 { bookmark-level: 2; }
cxx-clause cxx-section h1 { bookmark-level: 3; }
cxx-clause cxx-section cxx-section h1 { bookmark-level: 4; }

*  .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;
}
pre > code { display: inline-block; }


/* Use an em-dash for the list bullet. */
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;
}

/* 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><title>Technical Specification for C++ Extensions for Concurrency, Working Draft</title></head>
<body>
<cxx-titlepage stage="draft">
    
    <table>
      
        <tbody><tr><th>Document Number:</th><td><cxx-docnum>N4107</cxx-docnum></td></tr>
      
      
        <tr><th>Date:</th><td><time pubdate="">2014-07-07</time></td></tr>
      
      
        <tr><th>Revises:</th><td><cxx-revises><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3970.html">N3970</a></cxx-revises></td></tr>
      
      
        <tr><th>Editor:</th><td><cxx-editor>
    Artur Laksberg<br>
    Microsoft Corp.<br>
    <cxx-email><a href="mailto:arturl@microsoft.com">arturl@microsoft.com</a></cxx-email>
  </cxx-editor></td></tr>
      
    </tbody></table>
    <h1>Working Draft, Technical Specification for C++ Extensions for Concurrency</h1>
    
      <p class="warning"><strong>Note: this is an early draft. It’s known to be
      incomplet and incorrekt, and it has lots of b<span style="margin-left: -1.2pt; margin-right: 1pt">a</span>d<span style="width:1.5em"> </span>for<span style="margin-left:-3pt; margin-right:0.6pt">mat</span>ti<span style="position:relative; top:-0.15ex">n</span>g.</strong></p>
    
  </cxx-titlepage>

<cxx-toc>
    
    <nav>
      <h1>Contents</h1>
      
        
          <ol>
            
              <li><span class="marker">1</span><a href="#general">General</a>
        
          <ol>
            
              <li><span class="marker">1.1</span><a href="#general.scope">Scope</a>
        
      </li>
            
              <li><span class="marker">1.2</span><a href="#general.references">Normative references</a>
        
      </li>
            
              <li><span class="marker">1.3</span><a href="#general.namespaces">Namespaces, headers, and modifications to standard classes</a>
        
      </li>
            
          </ol>
        
      </li>
            
              <li><span class="marker">2</span><a href="#future"> Improvements to std::future&lt;T&gt; and Related APIs</a>
        
          <ol>
            
              <li><span class="marker">2.1</span><a href="#futures.general">General</a>
        
      </li>
            
              <li><span class="marker">2.2</span><a href="#futures.unique_future"> Changes to class template future</a>
        
      </li>
            
              <li><span class="marker">2.3</span><a href="#futures.shared_future">Changes to class template shared_future</a>
        
      </li>
            
              <li><span class="marker">2.4</span><a href="#futures.when_all"> Function template when_all</a>
        
      </li>
            
              <li><span class="marker">2.5</span><a href="#futures.when_any"> Function template when_any</a>
        
      </li>
            
              <li><span class="marker">2.6</span><a href="#futures.when_any_back"> Function template when_any_back</a>
        
      </li>
            
              <li><span class="marker">2.7</span><a href="#futures.make_ready_future"> Function template make_ready_future</a>
        
      </li>
            
          </ol>
        
      </li>
            
          </ol>
        
      
    </nav>
  </cxx-toc>

<cxx-clause id="general">
    

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

    <section>
      <header><span class="section-number">1.1</span> <h1 data-bookmark-label="1.1 Scope">Scope</h1> <span style="float:right"><a href="#general.scope">[general.scope]</a></span></header>
      
    

<p para_num="1" id="general.scope.1">This technical specification describes a number of concurrency extensions to
the C++ Standard Library (<cxx-ref to="general.references"><a title="general.references" href="#general.references">1.2</a></cxx-ref>). These
extensions are classes and functions that are likely to be used widely within a
program and/or on the interface boundaries between libraries written by
different organizations.</p>

<p para_num="2" id="general.scope.2">This technical specification is non-normative. Some of the library components
in this technical specification may be considered for standardization in a
future version of C++, but they are not currently part of any C++ standard. Some
of the components in this technical specification may never be standardized, and
others may be standardized in a substantially changed form.</p>

<p para_num="3" id="general.scope.3">The goal of this technical `specification` is to build more
widespread existing practice for an expanded C++ standard
library. It gives advice on extensions to those vendors who wish
to provide them.</p>

  
    </section>
  </cxx-section>

  <cxx-section id="general.references">
    

    <section>
      <header><span class="section-number">1.2</span> <h1 data-bookmark-label="1.2 Normative references">Normative references</h1> <span style="float:right"><a href="#general.references">[general.references]</a></span></header>
      
    

    <p para_num="1" id="general.references.1">The following referenced document is indispensable for the
    application of this document. For dated references, only the
    edition cited applies. For undated references, the latest edition
    of the referenced document (including any amendments) applies.</p>

    <ul>
      <li>ISO/IEC 14882:—<cxx-footnote><!--
    Be sure not to introduce whitespace here, as it appears around the footnote.
  --><sup id="footnote-call-1"><a href="#footnote-body-1">1</a></sup><aside class="footnote" id="footnote-body-1"><span class="marker"><a href="#footnote-call-1">1</a>) </span>To be published. Section references are relative to <a href="http://open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf">N3797</a>.</aside></cxx-footnote>,
      <cite>Programming Languages — C++</cite>
      </li>

      <li><a href="http://www.ietf.org/rfc/rfc2781.txt">RFC 2781</a>, <cite>UTF-16, an encoding of ISO 10646</cite></li>
    </ul>

    <p para_num="2" id="general.references.2">ISO/IEC 14882:— is herein called the <dfn>C++ Standard</dfn>.
    References to clauses within the C++ Standard are written as "C++14
    §3.2". The library described in ISO/IEC 14882:— clauses 17–30 is
    herein called the <dfn>C++ Standard Library</dfn>.</p>

  
    </section>
  </cxx-section>

  <cxx-section id="general.namespaces">
    

    <section>
      <header><span class="section-number">1.3</span> <h1 data-bookmark-label="1.3 Namespaces, headers, and modifications to standard classes">Namespaces, headers, and modifications to standard classes</h1> <span style="float:right"><a href="#general.namespaces">[general.namespaces]</a></span></header>
      
    

<p para_num="1" id="general.namespaces.1"> Some of the extensions described in this Technical Specification represent
types and functions that are currently not part of the C++ Standards Library,
and because these extensions are experimental, they should not be declared
directly within namespace <code>std</code>. Instead, such extensions are
declared in namespace <code>std::experimental</code>. </p><p para_num="2" id="general.namespaces.2">

      <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
Once standardized, these components are expected to be promoted to namespace <code>std</code>. 
      
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note> </p><p para_num="3" id="general.namespaces.3">

Unless otherwise specified, references to such entities described in this
Technical Specification are assumed to be qualified with
<code>std::experimental</code>, and references to entities described in the C++
Standard Library are assumed to be qualified with <code>std::</code>.

  


<cxx-clause id="future">
    

    </cxx-clause></p><section>
      <header><span class="section-number">2</span> <h1 data-bookmark-label="2  Improvements to std::future&lt;T&gt; and Related APIs"> Improvements to <code>std::future&lt;T&gt;</code> and Related APIs</h1> <span style="float:right"><a href="#future">[future]</a></span></header>
      


<cxx-section id="futures.general">
    

    <section>
      <header><span class="section-number">2.1</span> <h1 data-bookmark-label="2.1 General">General</h1> <span style="float:right"><a href="#futures.general">[futures.general]</a></span></header>
      

<p para_num="1" id="futures.general.1">
The extensions proposed here are an evolution of the functionality of
<code>std::future</code> and <code>std::shared_future</code>. The extensions enable wait free
composition of asynchronous operations.
</p>

    </section>
  </cxx-section>

<cxx-section id="futures.unique_future">
    

    <section>
      <header><span class="section-number">2.2</span> <h1 data-bookmark-label="2.2  Changes to class template future"> Changes to class template <code>future</code></h1> <span style="float:right"><a href="#futures.unique_future">[futures.unique_future]</a></span></header>
      


<p para_num="1" id="futures.unique_future.1">
To the class declaration found in <cxx-ref in="cxx" to="futures.unique_future">C++14 <span title="futures.unique_future">§30.6.6</span></cxx-ref> paragraph 3, add the following to the public
functions:
<cxx-function>
    
    </cxx-function></p><pre><code><cxx-signature>
bool is_ready() const;

future(future&lt;future&lt;R&gt;&gt;&amp;&amp; rhs) noexcept;

template&lt;typename F&gt;
<em>see below</em> then(F&amp;&amp; func);

<del>template&lt;typename F&gt;
<em>see below</em> then(executor &amp;ex, F&amp;&amp; func);</del>

template&lt;typename F&gt;
<em>see below</em> then(launch policy, F&amp;&amp; func);
</cxx-signature></code></pre>

    <dl>
      


    </dl>
  

<p></p><p para_num="2" id="futures.unique_future.2">
In <cxx-ref in="cxx" to="futures.unique_future">C++14 <span title="futures.unique_future">§30.6.6</span></cxx-ref> between paragraphs 8 and 9, add the following:
</p>
<cxx-function para_num="3" id="futures.unique_future.3">
    
    <pre><code><cxx-signature>future(future&lt;future&lt;R&gt;&gt;&amp;&amp; rhs) noexcept;</cxx-signature></code></pre>

    <dl>
      
  
  <cxx-effects para_num="4" id="futures.unique_future.4">
    
    <dt>Effects:</dt><dd>Constructs a <code>future</code> object by moving the instance referred to by
  <code>rhs</code> and unwrapping the inner future.</dd>
  </cxx-effects>
  <cxx-postconditions para_num="5" id="futures.unique_future.5">
    
    <dt>Postconditions:</dt><dd>
    <!-- revisit: what happens when innner future is invalid? -->
    <ul>
      <li><code>valid()</code> returns the same value as <code>rhs.valid()</code> prior to the 
    constructor invocation.</li>
      <li><code>rhs.valid() == false</code>.</li>
    </ul>
  </dd>
  </cxx-postconditions>

    </dl>
  </cxx-function>

<p para_num="6" id="futures.unique_future.6">
After <cxx-ref in="cxx" to="futures.unique_future">C++14 <span title="futures.unique_future">§30.6.6</span></cxx-ref> paragraph 26, add the following:
<cxx-function>
    
    </cxx-function></p><pre><code><cxx-signature>
template&lt;typename F&gt;
<em>see below</em> then(F&amp;&amp; func);

<del>template&lt;typename F&gt;
<em>see below</em> then(executor &amp;ex, F&amp;&amp; func);</del>

template&lt;typename F&gt;
<em>see below</em> then(launch policy, F&amp;&amp; func);
</cxx-signature></code></pre>

    <dl>
      


  <cxx-notes>
    
    <dt>Notes:</dt><dd>  The <del>three</del><ins>two</ins> functions differ only by input parameters. The first only
  takes a callable object which accepts a <code>future</code> object as a parameter. <del>The
  second function takes an <code>executor</code> as the first parameter and a callable object
  as the second parameter.</del> The <del>third</del><ins>second</ins> function takes a launch policy as the first
  parameter and a callable object as the second parameter.
  </dd>
  </cxx-notes>
  <cxx-effects>
    
    <dt>Effects:</dt><dd>
    </dd>
  </cxx-effects>
    </dl>
  <p></p><ul>
      <li>The <i>continuation</i> <code>INVOKE(DECAY_COPY (std::forward&lt;F&gt;(func)))</code> is called when the object's shared state is ready (has a value or exception  stored).</li>
      <li>The continuation launches according to the specified launch policy<del> or
      <code>executor</code></del>.</li>
      <li>When the <del><code>executor</code> or</del> launch policy is not provided the continuation inherits
      the parent's launch policy <del>or <code>executor</code></del>.</li>
      <li>
      Any value returned from the continuation is stored as the result in the
      shared state of the resulting <code>future</code>. Any exception propagated from the execution of 
      the continuation is stored as the exceptional result in the shared state of the resulting <code>future</code>.
      </li>
      <li>If the parent was created with <code>std::promise</code> or with a <code>packaged_task</code> (has
      no associated launch  policy), the continuation behaves the same as the <del>third</del><ins>second</ins>
      overload with a policy argument of <code>launch::async | launch::deferred</code> and the
      same argument for <code>func</code>.</li>
      <li>If the parent has a policy of <code>launch::deferred</code>, then it is filled by
      calling <code>wait()</code> or <code>get()</code> on the resulting <code>future</code>.
      <a id="futures.unique_future.example"></a>
      <cxx-example>
    
    <span class="nowrap">[ <em>Example:</em></span>
    
      <pre>auto f1 = async(launch::deferred, [] { return 1; });

auto f2 = f1.then([](future<int> n) { return 2; });

f2.wait(); // execution of f1 starts here, followed by f2
      </int></pre> 
    <span class="nowrap">— <em>end example</em> ]</span>
  </cxx-example>
      </li>
    </ul>
  

  <cxx-returns para_num="7" id="futures.unique_future.7">
    
    <dt>Returns:</dt><dd> 
    The return type of <code>then</code> depends on the return type of the closure
    <code>func</code> as defined below:

    <ul>
      <li>
        When <code>result_of_t&lt;decay_t&lt;F&gt;()&gt;</code>
        is <code>future&lt;R&gt;</code>, the function returns <code>future&lt;R&gt;</code>.
      </li>
      <li>
        Otherwise, the function returns <code>future&lt;result_of_t&lt;decay_t&lt;F&gt;()&gt;&gt;</code>.
    <cxx-notes>
    
    <dt>Notes:</dt><dd>
        The first rule above is called the <em>implicit unwrapping</em>. Without this rule,
        the return type of <code>then</code> taking a closure returning a 
        <code>future&lt;R&gt;</code> would have been <code>future&lt;future&lt;R&gt;&gt;</code>.
        This rule avoids such nested <code>future</code> objects.
        <cxx-example>
    
    <span class="nowrap">[ <em>Example:</em></span>
    
          The type of <code>f2</code> below is 
          <code>future&lt;int&gt;</code> and not <code>future&lt;future&lt;int&gt;&gt;</code>:
<pre>future&lt;int&gt; f1 = g();
future&lt;int&gt; f2 = f1.then([](future&lt;int&gt; f) {
                    future&lt;int&gt; f3 = h();
                    return f3;
                 });
</pre>
        
    <span class="nowrap">— <em>end example</em> ]</span>
  </cxx-example>
    </dd>
  </cxx-notes>
      </li>
    </ul>

  </dd>
  </cxx-returns>

  <cxx-postconditions para_num="8" id="futures.unique_future.8">
    
    <dt>Postconditions:</dt><dd>
  <ul>
  <li>The <code>future</code> object is moved to the parameter of the continuation function.</li>
  <li><code>valid() == false</code> on original <code>future</code> object immediately after it returns.</li>
  </ul>
  </dd>
  </cxx-postconditions>


<cxx-function para_num="9" id="futures.unique_future.9">
    
    <pre><code><cxx-signature>bool is_ready() const;</cxx-signature></code></pre>

    <dl>
      
  
  <cxx-returns para_num="10" id="futures.unique_future.10">
    
    <dt>Returns:</dt><dd> <code>true</code> if the shared state is ready, <code>false</code> if it isn't.</dd>
  </cxx-returns>

    </dl>
  </cxx-function>


    </section>
  </cxx-section>

<cxx-section id="futures.shared_future">
    

    <section>
      <header><span class="section-number">2.3</span> <h1 data-bookmark-label="2.3 Changes to class template shared_future">Changes to class template <code>shared_future</code></h1> <span style="float:right"><a href="#futures.shared_future">[futures.shared_future]</a></span></header>
      

<p para_num="1" id="futures.shared_future.1">
To the class declaration found in <cxx-ref in="cxx" to="futures.shared_future">C++14 <span title="futures.shared_future">§30.6.7</span></cxx-ref>
paragraph 3, add the following to the public functions:
</p>

<pre>bool is_ready() const;

template&lt;typename F&gt;
<em>see below</em> then(F&amp;&amp; func);

<del>template&lt;typename F&gt;
<em>see below</em> then(executor &amp;ex, F&amp;&amp; func);</del>

template&lt;typename F&gt;
<em>see below</em> then(launch policy, F&amp;&amp; func);
</pre>

<p para_num="2" id="futures.shared_future.2">
After <cxx-ref in="cxx" to="futures.shared_future">C++14 <span title="futures.shared_future">§30.6.7</span></cxx-ref> paragraph 28, add the following:
</p>

<cxx-function para_num="3" id="futures.shared_future.3">
    
    <pre><code><cxx-signature>
template&lt;typename F&gt;
<em>see below</em> shared_future::then(F&amp;&amp; func);

<del>template&lt;typename F&gt;
<em>see below</em> shared_future::then(executor &amp;ex, F&amp;&amp; func);</del>

template&lt;typename F&gt;
<em>see below</em> shared_future::then(launch policy, F&amp;&amp; func);
</cxx-signature></code></pre>

    <dl>
      


<cxx-notes para_num="4" id="futures.shared_future.4">
    
    <dt>Notes:</dt><dd>The <del>three</del><ins>two</ins> functions differ only by input parameters. The first
only takes a callable object which  accepts a <code>shared_future</code> object as a
parameter. <del>The second function takes an <code>executor</code> as the first parameter and a
callable object as the second parameter.</del> The <del>third</del><ins>second</ins> function takes a launch
policy as the  first parameter and a callable object as the second parameter.
</dd>
  </cxx-notes>

<cxx-effects para_num="5" id="futures.shared_future.5">
    
    <dt>Effects:</dt><dd>
  <ul>
    <li>The <i>continuation</i> <code>INVOKE(DECAY_COPY (std::forward&lt;F&gt;(func)))</code> is called when the object's shared state is ready (has a value or exception  stored).</li>
    <li>The continuation launches according to the specified policy<del> or executor</del>.</li>
    <li>When the <del>scheduler or </del>launch policy is not provided the continuation
    inherits the parent's launch policy<del> or executor</del>.</li>
    <li>
    Any value returned from the continuation is stored as the result in the
    shared state of the resulting <code>future</code>. Any exception propagated from the execution of 
    the continuation is stored as the exceptional result in the shared state of the resulting <code>future</code>.
    </li>
    <li>If the parent was created with <code>std::promise</code> (has no associated launch
    policy), the continuation behaves the same as the <del>third</del><ins>second</ins> function with a policy
    argument of <code>launch::async | launch::deferred</code> and the same argument for <code>func</code>.</li>
    <li>If the parent has a policy of <code>launch::deferred</code>, then it is filled by
    calling <code>wait()</code> or <code>get()</code> on the resulting <code>shared_future</code>.
    <cxx-note><span class="nowrap">[ <em>Note:</em></span>
    
    This is similar to <code>future</code>. See example in <cxx-ref to="futures.unique_future"><a title="futures.unique_future" href="#futures.unique_future">2.2</a></cxx-ref>.
    
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
    </li>
  </ul>
</dd>
  </cxx-effects>

  <cxx-returns para_num="6" id="futures.shared_future.6">
    
    <dt>Returns:</dt><dd> 
    The return type of <code>then</code> depends on the return type of the closure
    <code>func</code> as defined below:

    <ul>
      <li>
        When <code>result_of_t&lt;decay_t&lt;F&gt;()&gt;</code>
        is <code>future&lt;R&gt;</code>, the function returns <code>future&lt;R&gt;</code>.
      </li>
      <li>
        Otherwise, the function returns <code>future&lt;result_of_t&lt;decay_t&lt;F&gt;()&gt;&gt;</code>.
        <cxx-notes>
    
    <dt>Notes:</dt><dd>
          This is the same as in <code>future</code>. See the notes on <code>future::then</code> return type in <cxx-ref to="futures.unique_future"><a title="futures.unique_future" href="#futures.unique_future">2.2</a></cxx-ref>.
        </dd>
  </cxx-notes>
      </li>
    </ul>

  </dd>
  </cxx-returns>

<cxx-postconditions para_num="7" id="futures.shared_future.7">
    
    <dt>Postconditions:</dt><dd>
  <ul>
    <li>
    The <code>shared_future</code> passed to the continuation function is
    a copy of the original <code>shared_future</code>.
    </li>
    <li>
    <code>valid() == true</code> on the original <code>shared_future</code> object.
    </li>
  </ul>
</dd>
  </cxx-postconditions>


    </dl>
  </cxx-function>

<cxx-function para_num="8" id="futures.shared_future.8">
    
    <pre><code><cxx-signature>bool is_ready() const;</cxx-signature></code></pre>

    <dl>
      

<cxx-returns para_num="9" id="futures.shared_future.9">
    
    <dt>Returns:</dt><dd> <code>true</code> if the shared state is ready, <code>false</code> if it isn't.</dd>
  </cxx-returns>

    </dl>
  </cxx-function>


    </section>
  </cxx-section>

<cxx-section id="futures.when_all">
    

    <section>
      <header><span class="section-number">2.4</span> <h1 data-bookmark-label="2.4  Function template when_all"> Function template <code>when_all</code></h1> <span style="float:right"><a href="#futures.when_all">[futures.when_all]</a></span></header>
      

<p para_num="1" id="futures.when_all.1">
A new section 30.6.10 shall be inserted at the end of <cxx-ref in="cxx" to="futures">C++14 <span title="futures">§30.6</span></cxx-ref>. Below is the content of that section.
</p>

<cxx-function para_num="2" id="futures.when_all.2">
    
    <pre><code><cxx-signature>
template <class inputiterator="">
<em>see below</em> when_all(InputIterator first, InputIterator last);

template &lt;typename... T&gt;
<em>see below</em> when_all(T&amp;&amp;... futures);
</class></cxx-signature></code></pre>

    <dl>
      


<cxx-requires para_num="3" id="futures.when_all.3">
    
    <dt>Requires:</dt><dd> <code>T</code> is of type <code>future&lt;R&gt;</code> or 
<code>shared_future&lt;R&gt;</code>.</dd>
  </cxx-requires>

<cxx-notes para_num="4" id="futures.when_all.4">
    
    <dt>Notes:</dt><dd>
  <ul>
    <li>There are two variations of <code>when_all</code>. The first version takes a pair of
    <code>InputIterators</code>. The  second takes any arbitrary number of <code>future&lt;R0&gt;</code> and
    <code>shared_future&lt;R1&gt;</code> objects, where <code>R0</code>  and <code>R1</code> need not be the same type.</li>

    <li>Calling the first signature of <code>when_all</code> where <code>InputIterator</code> first
    equals last,  returns a future with an empty vector that is immediately
    ready.</li>

    <li>Calling the second signature of <code>when_any</code> with no arguments returns a
    <code>future&lt;tuple&lt;&gt;&gt;</code> that is  immediately ready.</li>
    </ul>
</dd>
  </cxx-notes>

<cxx-effects para_num="5" id="futures.when_all.5">
    
    <dt>Effects:</dt><dd>
  <ul>
    <li>Each <code>future</code> and <code>shared_future</code> is waited upon and then copied into the
    collection of the  output (returned) future, maintaining the order of the
    futures in the input collection.</li>

    <li>The future returned by <code>when_all</code> will not throw an exception, but the
    futures held in the output collection may.</li>
  </ul>
</dd>
  </cxx-effects>

<cxx-returns para_num="6" id="futures.when_all.6">
    
    <dt>Returns:</dt><dd>
  <ul>
    <li><code>future&lt;tuple&lt;&gt;&gt;</code> if <code>when_all</code> is called with zero arguments.</li>

    <li><code>future&lt;vector&lt;future&lt;R&gt;&gt;&gt;</code> if the input cardinality is unknown at compile
    and the iterator pair  yields <code>future&lt;R&gt;</code>. <code>R</code> may be <code>void</code>. The order of the
    futures in the output vector will be the same  as given by the input iterator.</li>

    <li><code>future&lt;vector&lt;shared_future&lt;R&gt;&gt;&gt;</code> if the input cardinality is unknown at
    compile time and  the iterator pair yields <code>shared_future&lt;R&gt;</code>. <code>R</code> may be
    <code>void</code>. The order of the futures in the output  vector will be the same as given
    by the input iterator.</li>

    <li><code>future&lt;tuple&lt;future&lt;R0&gt;, future&lt;R1&gt;, future&lt;R2&gt;...&gt;&gt;</code> if inputs are fixed in
    number. The  inputs can be any arbitrary number of <code>future</code> and <code>shared_future</code>
    objects. The type of the  element at each position of the tuple corresponds to
    the type of the argument at the same  position. Any of <code>R0</code>, <code>R1</code>, <code>R2</code>, etc.
    may be <code>void</code>.</li>
  </ul>
</dd>
  </cxx-returns>

<cxx-postconditions para_num="7" id="futures.when_all.7">
    
    <dt>Postconditions:</dt><dd>
  <ul>
    <li>All input <code>future&lt;T&gt;</code>s <code>valid() == false</code>.</li>
    <li>All output <code>shared_future&lt;T&gt;</code> <code>valid() == true</code>.</li>
  </ul>
</dd>
  </cxx-postconditions>

    </dl>
  </cxx-function>

    </section>
  </cxx-section>

<cxx-section id="futures.when_any">
    

    <section>
      <header><span class="section-number">2.5</span> <h1 data-bookmark-label="2.5  Function template when_any"> Function template <code>when_any</code></h1> <span style="float:right"><a href="#futures.when_any">[futures.when_any]</a></span></header>
      

<p para_num="1" id="futures.when_any.1">
A new section 30.6.11 shall be inserted at the end of <cxx-ref in="cxx" to="futures">C++14 <span title="futures">§30.6</span></cxx-ref>. Below is the content of that section.
</p>

<cxx-function para_num="2" id="futures.when_any.2">
    
    <pre><code><cxx-signature>
template &lt;class InputIterator&gt;
<em>see below</em> when_any(InputIterator first, InputIterator last);

template &lt;typename... T&gt;
<em>see below</em> when_any(T&amp;&amp;... futures);
</cxx-signature></code></pre>

    <dl>
      


<cxx-requires para_num="3" id="futures.when_any.3">
    
    <dt>Requires:</dt><dd> <code>T</code> is of type <code>future&lt;R&gt;</code> or <code>shared_future&lt;R&gt;</code>.</dd>
  </cxx-requires>

<cxx-notes para_num="4" id="futures.when_any.4">
    
    <dt>Notes:</dt><dd>
<ul>
  <li>There are two variations of <code>when_any</code>. The first version takes a pair of
  <code>InputIterators</code>. The  second takes any arbitrary number of <code>future&lt;R&gt;</code> and
  <code>shared_future&lt;R&gt;</code> objects, where <code>R</code> need  not be the same type.</li>

  <li>Calling the first signature of <code>when_any</code> where <code>InputIterator</code> first
  equals last, returns a future with an empty vector that is immediately
  ready.</li>

  <li>Calling the second signature of <code>when_any</code> with no arguments returns a
  <code>future&lt;tuple&lt;&gt;&gt;</code> that is  immediately ready.</li>
</ul>
</dd>
  </cxx-notes>

<cxx-effects para_num="5" id="futures.when_any.5">
    
    <dt>Effects:</dt><dd>
<ul>
  <li>Each <code>future</code> and <code>shared_future</code> is waited upon. When at least one is ready,
  all the futures are  copied into the collection of the output (returned) future,
  maintaining the order of the futures  in the input collection.</li>

  <li>The <code>future</code> returned by <code>when_any</code> will not throw an exception, but the
  futures held in the  output collection may.</li>
</ul>
</dd>
  </cxx-effects>

<cxx-returns para_num="6" id="futures.when_any.6">
    
    <dt>Returns:</dt><dd>
<ul>
  <li><code>future&lt;tuple&lt;&gt;&gt;</code> if <code>when_any</code> is called with zero arguments. </li>

  <li><code>future&lt;vector&lt;future&lt;R&gt;&gt;&gt;</code> if the input cardinality is unknown at compile
  time and the  iterator pair yields <code>future&lt;R&gt;</code>. <code>R</code> may be void. The order of
  the futures in the output vector will  be the same as given by the input
  iterator.</li>

  <li><code>future&lt;vector&lt;shared_future&lt;R&gt;&gt;&gt;</code> if the input cardinality is unknown at
  compile time and  the iterator pair yields <code>shared_future&lt;R&gt;</code>. <code>R</code> may be
  <code>void</code>. The order of the futures in the output  vector will be the same as given
  by the input iterator.</li>

  <li><code>future&lt;tuple&lt;future&lt;R0&gt;, future&lt;R1&gt;, future&lt;R2&gt;...&gt;&gt;</code> if inputs are fixed in
  number. The  inputs can be any arbitrary number of <code>future</code> and <code>shared_future</code>
  objects. The type of the  element at each position of the tuple corresponds to
  the type of the argument at the same  position. Any of <code>R0</code>, <code>R1</code>, <code>R2</code>, etc.
  maybe <code>void</code>.</li>
</ul>
</dd>
  </cxx-returns>

<cxx-postconditions para_num="7" id="futures.when_any.7">
    
    <dt>Postconditions:</dt><dd>
<ul>
  <li>All input <code>future&lt;T&gt;</code>s <code>valid() == false</code>.</li>
  <li>All input <code>shared_future&lt;T&gt; valid() == true</code>.</li>
</ul>
</dd>
  </cxx-postconditions>

    </dl>
  </cxx-function>

    </section>
  </cxx-section>

<cxx-section id="futures.when_any_back">
    

    <section>
      <header><span class="section-number">2.6</span> <h1 data-bookmark-label="2.6  Function template when_any_back"> Function template <code>when_any_back</code></h1> <span style="float:right"><a href="#futures.when_any_back">[futures.when_any_back]</a></span></header>
      

<p para_num="1" id="futures.when_any_back.1">
A new section 30.6.12 shall be inserted at the end of <cxx-ref in="cxx" to="futures">C++14 <span title="futures">§30.6</span></cxx-ref>. Below is the content of that section.
</p>

<cxx-function para_num="2" id="futures.when_any_back.2">
    
    <pre><code><cxx-signature>
template &lt;class InputIterator&gt;
<em>see below</em> when_any_back(InputIterator first, InputIterator last);
</cxx-signature></code></pre>

    <dl>
      


<cxx-requires para_num="3" id="futures.when_any_back.3">
    
    <dt>Requires:</dt><dd> <code>InputIterator</code>'s value type shall be convertible to <code>future&lt;R&gt;</code>
or <code>shared_future&lt;R&gt;</code>. All <code>R</code> types  must be the same.
</dd>
  </cxx-requires>

<cxx-notes para_num="4" id="futures.when_any_back.4">
    
    <dt>Notes:</dt><dd>
  <ul>
    <li>The function <code>when_any_back</code> takes a pair of <code>InputIterators</code>.</li>
    <li>Calling <code>when_any_back</code> where <code>InputIterator</code> first equals
    last, returns a <code>future</code> with an empty vector that is immediately ready.</li>
  </ul>
</dd>
  </cxx-notes>

<cxx-effects para_num="5" id="futures.when_any_back.5">
    
    <dt>Effects:</dt><dd>
  <ul>
    <li>Each <code>future</code> and <code>shared_future</code> is waited upon. When at least one is ready,
    all the futures are  copied into the collection of the output (returned)
    <code>future</code>.</li>

    <li>After the copy, the <code>future</code> or <code>shared_future</code> that was first detected as
    being ready swaps its  position with that of the last element of the result
    collection, so that the ready <code>future</code> or <code>shared_future</code> may be identified in
    constant time. Only one <code>future</code> or <code>shared_future</code> is thus  moved.</li>

    <li>The <code>future</code> returned by <code>when_any_back</code> will not throw an exception, but
    the futures held in  the output collection may.</li>
  </ul>
</dd>
  </cxx-effects>

<cxx-returns para_num="6" id="futures.when_any_back.6">
    
    <dt>Returns:</dt><dd>
  <ul>
    <li><code>future&lt;vector&lt;future&lt;R&gt;&gt;&gt;</code> if the input cardinality is unknown at compile
    time and the  iterator pair yields <code>future&lt;R&gt;</code>. <code>R</code> may be <code>void</code>.</li>
    <li><code>future&lt;vector&lt;shared_future&lt;R&gt;&gt;&gt;</code> if the input cardinality is unknown at
    compile time and  the iterator pair yields <code>shared_future&lt;R&gt;</code>. <code>R</code> may be
    <code>void</code>.</li>
  </ul>
</dd>
  </cxx-returns>

<cxx-postconditions para_num="7" id="futures.when_any_back.7">
    
    <dt>Postconditions:</dt><dd>
  <ul>
    <li>All input <code>future&lt;T&gt;</code>s <code>valid() == false</code>.</li>
    <li>All input <code>shared_future<t> valid() == true</t></code>.</li>
  </ul>
</dd>
  </cxx-postconditions>

    </dl>
  </cxx-function>

    </section>
  </cxx-section>

<cxx-section id="futures.make_ready_future">
    

    <section>
      <header><span class="section-number">2.7</span> <h1 data-bookmark-label="2.7  Function template make_ready_future"> Function template <code>make_ready_future</code></h1> <span style="float:right"><a href="#futures.make_ready_future">[futures.make_ready_future]</a></span></header>
      

<p para_num="1" id="futures.make_ready_future.1">
A new section 30.6.13 shall be inserted at the end of <cxx-ref in="cxx" to="futures">C++14 <span title="futures">§30.6</span></cxx-ref>. Below is the content of that section.
</p>

<cxx-function para_num="2" id="futures.make_ready_future.2">
    
    <pre><code><cxx-signature>
  template &lt;typename T&gt;
  future&lt;decay_t&lt;T&gt;&gt; make_ready_future(T&amp;&amp; value);

  future&lt;void&gt; make_ready_future();
  </cxx-signature></code></pre>

    <dl>
      
  

  <cxx-effects para_num="3" id="futures.make_ready_future.3">
    
    <dt>Effects:</dt><dd> The value that is passed in to the function is moved to the shared state of the returned <code>future</code> if it 
  is an rvalue. Otherwise the value is copied to the shared state of the returned <code>future</code>.
  </dd>
  </cxx-effects>

  <cxx-returns para_num="4" id="futures.make_ready_future.4">
    
    <dt>Returns:</dt><dd>
    <ul>
      <li><code>future&lt;decay_t&lt;T&gt;&gt;</code>, if function is given a value of type <code>T</code>.</li>
      <li><code>future&lt;void&gt;</code>, if the function is not given any inputs. </li>
    </ul>
  </dd>
  </cxx-returns>

  <cxx-postconditions para_num="5" id="futures.make_ready_future.5">
    
    <dt>Postconditions:</dt><dd>
    <ul>
      <li>Returned <code>future&lt;decay_t&lt;T&gt;&gt;, valid() == true</code>.</li>
      <li>Returned <code>future&lt;decay_t&lt;T&gt;&gt;, is_ready() == true</code>.</li>
    </ul>
  </dd>
  </cxx-postconditions>

    </dl>
  </cxx-function>

    </section>
  </cxx-section>

<del>
<cxx-section id="futures.async">
    

    <section>
      <header><span class="section-number">?</span> <h1>Function template <code>async</code></h1> <span style="float:right"><a href="#futures.async">[futures.async]</a></span></header>
      

<p para_num="1" id="futures.async.1">
Change <cxx-ref in="cxx" to="futures.async">C++14 <span title="futures.async">§30.6.8</span></cxx-ref> paragraph 1 as follows:
</p>
<p para_num="2" id="futures.async.2">
The function template <code>async</code> provides a mechanism to launch a function
potentially in a new thread  and provides the result of the function in a future
object with which it shares a shared state.
</p>
<p para_num="3" id="futures.async.3">
</p><pre>template &lt;class F, class... Args&gt;
future&lt;result_of_t&lt;decay_t&lt;F&gt;(decay_t&lt;Args&gt;...)&gt;&gt;
async(F&amp;&amp; f, Args&amp;&amp;... args);

template &lt;class F, class... Args&gt;
future&lt;result_of_t&lt;decay_t&lt;F&gt;(decay_t&lt;Args&gt;...)&gt;&gt;
async(launch policy, F&amp;&amp; f, Args&amp;&amp;... args);

<del>
template&lt;class F, class... Args&gt;
future&lt;result_of_t&lt;decay_t&lt;F&gt;(decay_t&lt;Args&gt;...)&gt;&gt;
async(executor&amp; ex, F&amp;&amp; f, Args&amp;&amp;... args);
</del>
</pre>
<p para_num="4" id="futures.async.4"></p>

Change <cxx-ref in="cxx" to="futures.async">C++14 <span title="futures.async">§30.6.8</span></cxx-ref> paragraph 3 as follows:

<cxx-effects para_num="5" id="futures.async.5">
    
    <dt>Effects:</dt><dd>
The first function behaves the same as a call to the second
function with a policy argument of  <code>launch::async | launch::deferred</code> and the
same arguments for <code>F</code> and <code>Args</code>. The second <ins>and third</ins> function<ins>s</ins> create<del>s</del> a
shared state that is associated with the returned future object. The further
behavior of the second function depends on the policy argument as follows (if
more than one of these conditions applies, the  implementation may choose any of
the corresponding policies):
  <ul>
    <li>if <code>policy &amp; launch::async</code> is non-zero — calls
    <code>INVOKE (DECAY_COPY (std::forward&lt;F&gt;(f))</code>, <code>DECAY_COPY (std::forward&lt;Args&gt;(args))...)</code>
    (20.8.2, 30.3.1.2) as if in a new thread of execution  represented by a thread object
    with the calls to <code>DECAY_COPY ()</code> being evaluated in the thread that called
    <code>async</code>. Any return value is stored as the result in the shared state. Any
    exception  propagated from the execution of 
    <code>INVOKE (DECAY_COPY (std::forward&lt;F&gt;(f)), DECAY_COPY (std::forward&lt;Args&gt;(args))...)</code>
    is stored as the exceptional result in the shared state. The thread object is stored in the
    shared state and affects the behavior of any asynchronous return objects  that
    reference that state.</li>

    <li>if <code>policy &amp; launch::deferred</code> is non-zero — Stores <code>DECAY_COPY(std::forward&lt;F&gt;(f))</code>
    and <code>DECAY_COPY  (std::forward&lt;Args&gt;(args))...</code> in the
    shared state. These copies of <code>f</code> and <code>args</code> constitute a deferred  function.
    Invocation of the deferred function evaluates 
    <code>INVOKE std::move(g), std::move(xyz))</code> where <code>g</code> is  the stored value of 
    <code>DECAY_COPY (std::forward&lt;F&gt;(f))</code> and <code>xyz</code> is the stored copy of 
    <code>DECAY_COPY (std::forward&lt;Args&gt;(args))...</code>. The shared state is not made ready until the
    function has completed. The  first call to a non-timed waiting function (30.6.4)
    on an asynchronous return object referring to this shared state shall invoke
    the deferred function in the thread that called the waiting function. Once
    evaluation of <code>INVOKE (std::move(g), std::move(xyz))</code> begins, the function is no
    longer considered  deferred. <cxx-note><span class="nowrap">[ <em>Note:</em></span>
     If this policy is specified together with
    other policies, such as when using a policy value  of 
    <code>launch::async | launch::deferred</code>, implementations should defer invocation or the selection of
    the policy when no more concurrency can be effectively exploited.
    
    <span class="nowrap">— <em>end note</em> ]</span>
  </cxx-note>
    </li>

    <li>If no value is set in the launch policy, or a value is set that is 
    neither specified in this International Standard or by the implementation,
    the behaviour is undefined.</li>

  </ul>
</dd>
  </cxx-effects>

<ins>
The further behavior of the third function is as follows:<br>
<blockquote>
  The <code>executor::add()</code> function is given a <code>function&lt;void()&gt;</code> which calls
  <code>INVOKE (DECAY_COPY (std::forward&lt;F&gt;(f)) DECAY_COPY
  (std::forward&lt;Args&gt;(args))...)</code>. The implementation of the executor is decided
  by the programmer.
</blockquote>
</ins>

    </section>
  </cxx-section></del>




    </section>
  





<p></p>
    </section>
  </cxx-section>
    </section>
  </cxx-clause></body></html>