﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <!-- TITLE -->
    <title>Overly attached promise</title>

    <style name="main.css">
        @import url(https://fonts.googleapis.com/css?family=Muli:400,300);
        @import url(https://fonts.googleapis.com/css?family=Share:400,700);

        /* ============================== */
        /* BODY */
        /* ============================== */

        body {
            font-family: 'Muli',arial,sans-serif;
            background-color: #FEFEFE;
            margin: 0;
            padding: 0;
            font-size: 0.875em;
            color: #616161;
        }

        h1, h2, h3, h4, h5, h6 {
            margin-bottom: 0.5em;
            font-family: 'Share';
        }

        .title {
            border-bottom: solid 2px #f5aa10;
        }

        #container {
            margin: 0 auto;
            width: 60%;
            min-width: 640px;
            overflow: auto;
        }

        #main {
            width: 100%;
        }

        a {
            color: #3C6EB4;
            cursor: pointer;
            text-decoration: none;
        }

            a:hover {
                text-decoration: underline;
            }


        /* ============================== */
        /* HEADER */
        /* ============================== */
        #head {
            overflow: auto;
            margin: 40px 0;
        }

            #head div.top {
                font-size: 2.4em;
                margin-right: 80px;
            }

            #head div.bottom {
                height: 38px;
                margin-right: 80px;
            }

            #head .logo {
                vertical-align: bottom;
            }

            #head a.name {
                text-decoration: none;
                color: #555;
                font-weight: bold;
                overflow: auto;
            }

            #head span.slogan {
                color: #CCC;
            }

        /* ============================== */
        /* POST VIEW*/
        /* ============================== */
        article.post {
            margin-bottom: 60px;
            clear: both;
            overflow: auto;
        }

            article.post header.post {
                margin-bottom: 10px;
            }

                article.post header.post h1.title {
                    font-weight: bold;
                    margin: 0;
                }

                    article.post header.post h1.title a {
                        color: inherit;
                        text-decoration: none;
                    }

                article.post header.post div.date {
                    font-size: 0.9em;
                    font-weight: bold;
                    text-align: right;
                    text-transform: uppercase;
                    color: #999;
                }

            article.post .body {
                font-size: 1.2em;
            }

            article.post .console {
                background: url("img/console.png") no-repeat scroll 10px center #F1F1F1;
                display: block;
                line-height: 50px;
                margin: 5px 0;
                padding-left: 60px;
            }

            article.post img:not(.captcha) {
                max-width: 100%;
            }

            article.post blockquote {
                font-size: 1em;
                width: 80%;
                margin-left: 2em;
                padding-left: 0.5em;
                border-left: 2px solid #C3C3C3;
            }

            article.post footer.post {
                clear: both;
                margin-top: 20px;
                text-align: center;
            }

        article pre {
            border: 1px dashed #ccc;
            padding: 1em;
            background: #f4f4f4;
        }

        article.pre, article.code {
            font-family: monospace;
            font-size: 1em;
        }

        /* ============================== */
        /* TABLES */
        /* ============================== */
        table {
            border: 1px solid #999;
        }

            table th, table td {
                background: #f4f4f4;
                padding: 5px 15px;
            }

            table thead {
                border-bottom: 1px solid #999;
            }

            table th {
                font-weight: bold;
                background: #eaeaea;
            }

            table td, table th {
                border-right: 1px solid #999;
            }
    </style>

    <!-- SyntaxHighlighter -->
    <style name="normalize.css">
        article, aside, details, figcaption, figure, footer, header, hgroup, nav, section, summary {
            display: block;
        }

        audio, canvas, video {
            display: inline-block;
        }

            audio:not([controls]) {
                display: none;
                height: 0;
            }

        [hidden] {
            display: none;
        }

        html {
            font-family: sans-serif;
            -webkit-text-size-adjust: 100%;
            -ms-text-size-adjust: 100%;
        }

        a:focus {
            outline: thin dotted;
        }

        a:active, a:hover {
            outline: 0;
        }

        h1 {
            font-size: 2em;
        }

        abbr[title] {
            border-bottom: 1px dotted;
        }

        b, strong {
            font-weight: 700;
        }

        dfn {
            font-style: italic;
        }

        mark {
            background: #ff0;
            color: #000;
        }

        code, kbd, pre, samp {
            font-family: monospace, serif;
            font-size: 1em;
        }

        pre {
            white-space: pre-wrap;
            word-wrap: break-word;
        }

        q {
            quotes: \201C \201D \2018 \2019;
        }

        small {
            font-size: 80%;
        }

        sub, sup {
            font-size: 75%;
            line-height: 0;
            position: relative;
            vertical-align: baseline;
        }

        sup {
            top: -.5em;
        }

        sub {
            bottom: -.25em;
        }

        img {
            border: 0;
        }

        svg:not(:root) {
            overflow: hidden;
        }

        fieldset {
            border: 1px solid silver;
            margin: 0 2px;
            padding: .35em .625em .75em;
        }

        button, input, select, textarea {
            font-family: inherit;
            font-size: 100%;
            margin: 0;
        }

        button, input {
            line-height: normal;
        }

            button, html input[type=button], /* 1 */
            input[type=reset], input[type=submit] {
                -webkit-appearance: button;
                cursor: pointer;
            }

                button[disabled], input[disabled] {
                    cursor: default;
                }

            input[type=checkbox], input[type=radio] {
                box-sizing: border-box;
                padding: 0;
            }

            input[type=search] {
                -webkit-appearance: textfield;
                -moz-box-sizing: content-box;
                -webkit-box-sizing: content-box;
                box-sizing: content-box;
            }

                input[type=search]::-webkit-search-cancel-button, input[type=search]::-webkit-search-decoration {
                    -webkit-appearance: none;
                }

        textarea {
            overflow: auto;
            vertical-align: top;
        }

        table {
            border-collapse: collapse;
            border-spacing: 0;
        }

        body, figure {
            margin: 0;
        }

        legend, button::-moz-focus-inner, input::-moz-focus-inner {
            border: 0;
            padding: 0;
        }
    </style>
    <style name="shCore.css">
        .syntaxhighlighter a,
        .syntaxhighlighter div,
        .syntaxhighlighter code,
        .syntaxhighlighter table,
        .syntaxhighlighter table td,
        .syntaxhighlighter table tr,
        .syntaxhighlighter table tbody,
        .syntaxhighlighter table thead,
        .syntaxhighlighter table caption,
        .syntaxhighlighter textarea {
            -moz-border-radius: 0 0 0 0 !important;
            -webkit-border-radius: 0 0 0 0 !important;
            background: none !important;
            border: 0 !important;
            bottom: auto !important;
            float: none !important;
            height: auto !important;
            left: auto !important;
            line-height: 1.1em !important;
            margin: 0 !important;
            outline: 0 !important;
            overflow: visible !important;
            padding: 0 !important;
            position: static !important;
            right: auto !important;
            text-align: left !important;
            top: auto !important;
            vertical-align: baseline !important;
            width: auto !important;
            box-sizing: content-box !important;
            font-family: monospace !important;
            font-weight: normal !important;
            font-style: normal !important;
            font-size: 1em !important;
            min-height: inherit !important;
            min-height: auto !important;
        }

        .syntaxhighlighter {
            margin: 1em 0 1em 0 !important;
            overflow: auto !important;
            font-size: 1em !important;
        }

            .syntaxhighlighter.source {
                overflow: hidden !important;
            }

            .syntaxhighlighter .bold {
                font-weight: bold !important;
            }

            .syntaxhighlighter .italic {
                font-style: italic !important;
            }

            .syntaxhighlighter .line {
                white-space: pre !important;
            }

            .syntaxhighlighter table {
                width: 100% !important;
            }

                .syntaxhighlighter table caption {
                    text-align: left !important;
                    padding: .5em 0 0.5em 1em !important;
                }

                .syntaxhighlighter table td.code {
                    width: 100% !important;
                }

                    .syntaxhighlighter table td.code .container {
                        position: relative !important;
                    }

                        .syntaxhighlighter table td.code .container textarea {
                            box-sizing: border-box !important;
                            position: absolute !important;
                            left: 0 !important;
                            top: 0 !important;
                            width: 100% !important;
                            height: 100% !important;
                            border: none !important;
                            background: white !important;
                            padding-left: 1em !important;
                            overflow: hidden !important;
                            white-space: pre !important;
                        }

                .syntaxhighlighter table td.gutter .line {
                    text-align: right !important;
                    padding: 0 0.5em 0 1em !important;
                }

                .syntaxhighlighter table td.code .line {
                    padding: 0 1em !important;
                }

            .syntaxhighlighter.nogutter td.code .container textarea, .syntaxhighlighter.nogutter td.code .line {
                padding-left: 0em !important;
            }

            .syntaxhighlighter.show {
                display: block !important;
            }

            .syntaxhighlighter.collapsed table {
                display: none !important;
            }

            .syntaxhighlighter.collapsed .toolbar {
                padding: 0.1em 0.8em 0em 0.8em !important;
                font-size: 1em !important;
                position: static !important;
                width: auto !important;
                height: auto !important;
            }

                .syntaxhighlighter.collapsed .toolbar span {
                    display: inline !important;
                    margin-right: 1em !important;
                }

                    .syntaxhighlighter.collapsed .toolbar span a {
                        padding: 0 !important;
                        display: none !important;
                    }

                        .syntaxhighlighter.collapsed .toolbar span a.expandSource {
                            display: inline !important;
                        }

            .syntaxhighlighter .toolbar {
                position: absolute !important;
                right: 1px !important;
                top: 1px !important;
                width: 11px !important;
                height: 11px !important;
                font-size: 10px !important;
                z-index: 10 !important;
            }

                .syntaxhighlighter .toolbar span.title {
                    display: inline !important;
                }

                .syntaxhighlighter .toolbar a {
                    display: block !important;
                    text-align: center !important;
                    text-decoration: none !important;
                    padding-top: 1px !important;
                }

                    .syntaxhighlighter .toolbar a.expandSource {
                        display: none !important;
                    }

            .syntaxhighlighter.ie {
                font-size: .9em !important;
                padding: 1px 0 1px 0 !important;
            }

                .syntaxhighlighter.ie .toolbar {
                    line-height: 8px !important;
                }

                    .syntaxhighlighter.ie .toolbar a {
                        padding-top: 0px !important;
                    }

            .syntaxhighlighter.printing .line.alt1 .content,
            .syntaxhighlighter.printing .line.alt2 .content,
            .syntaxhighlighter.printing .line.highlighted .number,
            .syntaxhighlighter.printing .line.highlighted.alt1 .content,
            .syntaxhighlighter.printing .line.highlighted.alt2 .content {
                background: none !important;
            }

            .syntaxhighlighter.printing .line .number {
                color: #bbbbbb !important;
            }

            .syntaxhighlighter.printing .line .content {
                color: black !important;
            }

            .syntaxhighlighter.printing .toolbar {
                display: none !important;
            }

            .syntaxhighlighter.printing a {
                text-decoration: none !important;
            }

            .syntaxhighlighter.printing .plain, .syntaxhighlighter.printing .plain a {
                color: black !important;
            }

            .syntaxhighlighter.printing .comments, .syntaxhighlighter.printing .comments a {
                color: #008200 !important;
            }

            .syntaxhighlighter.printing .string, .syntaxhighlighter.printing .string a {
                color: blue !important;
            }

            .syntaxhighlighter.printing .keyword {
                color: #006699 !important;
                font-weight: bold !important;
            }

            .syntaxhighlighter.printing .preprocessor {
                color: gray !important;
            }

            .syntaxhighlighter.printing .variable {
                color: #aa7700 !important;
            }

            .syntaxhighlighter.printing .value {
                color: #009900 !important;
            }

            .syntaxhighlighter.printing .functions {
                color: #ff1493 !important;
            }

            .syntaxhighlighter.printing .constants {
                color: #0066cc !important;
            }

            .syntaxhighlighter.printing .script {
                font-weight: bold !important;
            }

            .syntaxhighlighter.printing .color1, .syntaxhighlighter.printing .color1 a {
                color: gray !important;
            }

            .syntaxhighlighter.printing .color2, .syntaxhighlighter.printing .color2 a {
                color: #ff1493 !important;
            }

            .syntaxhighlighter.printing .color3, .syntaxhighlighter.printing .color3 a {
                color: red !important;
            }

            .syntaxhighlighter.printing .break, .syntaxhighlighter.printing .break a {
                color: black !important;
            }
    </style>
    <style name="shThemeDefault.css">
        .syntaxhighlighter {
            background-color: #f4f4f4 !important;
            border: 1px dashed #ccc;
            padding: 1em;
        }

            .syntaxhighlighter .line.alt1 {
                background-color: #f4f4f4 !important;
            }

            .syntaxhighlighter .line.alt2 {
                background-color: #f4f4f4 !important;
            }

            .syntaxhighlighter .line.highlighted.alt1, .syntaxhighlighter .line.highlighted.alt2 {
                background-color: #e0e0e0 !important;
            }

            .syntaxhighlighter .line.highlighted.number {
                color: black !important;
            }

            .syntaxhighlighter table caption {
                color: black !important;
            }

            .syntaxhighlighter .gutter {
                color: #afafaf !important;
            }

                .syntaxhighlighter .gutter .line {
                    border-right: 3px solid #6ce26c !important;
                }

                    .syntaxhighlighter .gutter .line.highlighted {
                        background-color: #6ce26c !important;
                        color: white !important;
                    }

            .syntaxhighlighter.printing .line .content {
                border: none !important;
            }

            .syntaxhighlighter.collapsed {
                overflow: visible !important;
            }

                .syntaxhighlighter.collapsed .toolbar {
                    color: blue !important;
                    background: #f4f4f4 !important;
                    border: 1px solid #6ce26c !important;
                }

                    .syntaxhighlighter.collapsed .toolbar a {
                        color: blue !important;
                    }

                        .syntaxhighlighter.collapsed .toolbar a:hover {
                            color: red !important;
                        }

            .syntaxhighlighter .toolbar {
                color: #f4f4f4 !important;
                background: #6ce26c !important;
                border: none !important;
            }

                .syntaxhighlighter .toolbar a {
                    color: #f4f4f4 !important;
                }

                    .syntaxhighlighter .toolbar a:hover {
                        color: black !important;
                    }

            .syntaxhighlighter .plain, .syntaxhighlighter .plain a {
                color: black !important;
            }

            .syntaxhighlighter .comments, .syntaxhighlighter .comments a {
                color: #008200 !important;
            }

            .syntaxhighlighter .string, .syntaxhighlighter .string a {
                color: blue !important;
            }

            .syntaxhighlighter .keyword {
                color: #006699 !important;
            }

            .syntaxhighlighter .preprocessor {
                color: gray !important;
            }

            .syntaxhighlighter .variable {
                color: #aa7700 !important;
            }

            .syntaxhighlighter .value {
                color: #009900 !important;
            }

            .syntaxhighlighter .functions {
                color: #ff1493 !important;
            }

            .syntaxhighlighter .constants {
                color: #0066cc !important;
            }

            .syntaxhighlighter .script {
                font-weight: bold !important;
                color: #006699 !important;
                background-color: none !important;
            }

            .syntaxhighlighter .color1, .syntaxhighlighter .color1 a {
                color: gray !important;
            }

            .syntaxhighlighter .color2, .syntaxhighlighter .color2 a {
                color: #ff1493 !important;
            }

            .syntaxhighlighter .color3, .syntaxhighlighter .color3 a {
                color: red !important;
            }

            .syntaxhighlighter .keyword {
                font-weight: bold !important;
            }
    </style>
</head>
<body>
    <div id="container">
        <section id="main">
            <article class="post">
                <p>
                    Document number: N4445<br>
                    Date: 2015-04-09<br>
                    Project: Programming Language C++, Concurrency and Parallelism Study Group<br>
                    Reply-to: Agustín Bergé <a href="mailto:agustinberge@gmail.com">agustinberge@gmail.com</a>, Hartmut Kaiser <a href="mailto:hartmut.kaiser@gmail.com">hartmut.kaiser@gmail.com</a>
                </p>
                <a name="overly-attached-promise" href="#overly-attached-promise"><h1>Overly attached promise</h1></a>
                <a name="1.-introduction" href="#1.-introduction"><h2>1. Introduction</h2></a>
                <p>
                    This paper proposes changes and additions to <code>std::promise</code> to allow an
                    efficient use of its shared state.
                </p>
                <a name="2.-motivation" href="#2.-motivation"><h2>2. Motivation</h2></a>
                <p>
                    A <code>std::promise</code> explicitly specifies when its shared state is released, and
                    under certain circumstances it clings to it and keeps it around long after it
                    is needed. Since releasing the shared state may cause a user-defined
                    destructor to run, and that would be an observable effect, there is little
                    wiggle room for implementations to be more efficient under the as-if rule.
                    Implementors should be allowed to release the shared state early as an
                    optimization, reclaiming the shared state resources (which might be limited
                    resources on some systems) as well as the dynamic memory used by it (if any).
                </p>
                <div>
                    <div id="highlighter_351311" class="syntaxhighlighter nogutter  cpp">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                                <tr>
                                    <td class="code">
                                        <div class="container">
                                            <div class="line number1 index0 alt2"><code class="cpp color1 bold">std::promise</code><code class="cpp plain">&lt;</code><code class="cpp color1 bold">int</code><code class="cpp plain">&gt; p;</code></div>
                                            <div class="line number2 index1 alt1"><code class="cpp plain">p.get_future();</code></div>
                                            <div class="line number3 index2 alt2"><code class="cpp plain">p.set_value(42);</code></div>
                                            <div class="line number4 index3 alt1"><code class="cpp comments">// p's shared state no longer needed, sticks around until ~promise()</code></div>
                                            <div class="line number5 index4 alt2"><code class="cpp plain">...</code></div>
                                            <div class="line number6 index5 alt1">&nbsp;</div>
                                            <div class="line number7 index6 alt2"><code class="cpp color1 bold">std::promise</code><code class="cpp plain">&lt;</code><code class="cpp color1 bold">int</code><code class="cpp plain">&gt;{}.set_value_at_thread_exit(42);</code></div>
                                            <div class="line number8 index7 alt1"><code class="cpp comments">// shared state no longer needed, sticks around until thread exit (maybe)</code></div>
                                            <div class="line number9 index8 alt2"><code class="cpp plain">...</code></div>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <p>
                    The intention of this paper is to allow (but not require) an implementation to
                    release a <code>promise</code>'s shared state as early as possible, once both the future
                    has been acquired and the shared state has been made ready, or once the last
                    future releases the shared state of a promise satisfied via one of the
                    <code>*_at_thread_exit</code> member functions.
                </p>
                <p>
                    Some existing implementations choose to bundle the state of the <code>promise</code>
                    itself into its shared state. Such implementations would not be able to retain
                    their state after releasing the shared state, hence the need for explicit ways
                    to accomplish the same effects. This can be already accomplished today with
                    the following constructs:
                </p>
                <div>
                    <div id="highlighter_529067" class="syntaxhighlighter nogutter  cpp">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                                <tr>
                                    <td class="code">
                                        <div class="container">
                                            <div class="line number1 index0 alt2"><code class="cpp plain">p = </code><code class="cpp color1 bold">std::promise</code><code class="cpp plain">&lt;</code><code class="cpp color1 bold">int</code><code class="cpp plain">&gt;{};&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </code><code class="cpp comments">// okayish</code></div>
                                            <div class="line number2 index1 alt1"><code class="cpp color1 bold">std::promise</code><code class="cpp plain">&lt;</code><code class="cpp color1 bold">int</code><code class="cpp plain">&gt;(</code><code class="cpp color1 bold">std::move</code><code class="cpp plain">(p)); </code><code class="cpp comments">// better</code></div>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <p>
                    The first line effectively resets the <code>promise</code>, it first constructs a new
                    shared state and then replaces the current state, abandoning the old one. The
                    second line effectively releases the <code>promise</code>, abandoning any shared state.
                    This paper additionally proposes two new <code>promise</code> member functions: <code>reset</code>
                    and <code>release</code>, with the aforementioned effects. It should be noted that a
                    <code>reset</code> member function could potentially recycle the current shared state,
                    provided it is its sole owner (either the future was never obtained or it has
                    already released this shared state).
                </p>
                <p>
                    Finally, this paper includes a drive-by fix to <code>future::get</code>'s wording, which
                    does not specify that the shared state is released.
                </p>
                <a name="3.-implementability" href="#3.-implementability"><h2>3. Implementability</h2></a>
                <p>
                    This implementation builds on top of any current implementation. It is
                    sufficient to meet this paper's requirements, but is not as efficient as
                    intended by it.
                </p>
                <div>
                    <div id="highlighter_514221" class="syntaxhighlighter nogutter  cpp">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                                <tr>
                                    <td class="code">
                                        <div class="container">
                                            <div class="line number1 index0 alt2"><code class="cpp keyword bold">class</code> <code class="cpp plain">promise {</code></div>
                                            <div class="line number2 index1 alt1"><code class="cpp spaces">&nbsp;&nbsp;</code><code class="cpp comments">// everything else as today</code></div>
                                            <div class="line number3 index2 alt2">&nbsp;</div>
                                            <div class="line number4 index3 alt1"><code class="cpp spaces">&nbsp;&nbsp;</code><code class="cpp keyword bold">void</code> <code class="cpp plain">reset() { *</code><code class="cpp keyword bold">this</code> <code class="cpp plain">= promise{}; }</code></div>
                                            <div class="line number5 index4 alt2">&nbsp;</div>
                                            <div class="line number6 index5 alt1"><code class="cpp spaces">&nbsp;&nbsp;</code><code class="cpp keyword bold">template</code> <code class="cpp plain">&lt;</code><code class="cpp keyword bold">class</code> <code class="cpp plain">Allocator&gt;</code></div>
                                            <div class="line number7 index6 alt2"><code class="cpp spaces">&nbsp;&nbsp;</code><code class="cpp keyword bold">void</code> <code class="cpp plain">reset(</code><code class="cpp keyword bold">const</code> <code class="cpp plain">Allocator&amp; a) { *</code><code class="cpp keyword bold">this</code> <code class="cpp plain">= promise{allocator_arg, a}; }</code></div>
                                            <div class="line number8 index7 alt1">&nbsp;</div>
                                            <div class="line number9 index8 alt2"><code class="cpp spaces">&nbsp;&nbsp;</code><code class="cpp keyword bold">void</code> <code class="cpp plain">release() </code><code class="cpp keyword bold">noexcept</code> <code class="cpp plain">{ promise{</code><code class="cpp color1 bold">std::move</code><code class="cpp plain">(*</code><code class="cpp keyword bold">this</code><code class="cpp plain">)}; }</code></div>
                                            <div class="line number10 index9 alt1"><code class="cpp plain">};</code></div>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <a name="4.-proposed-wording" href="#4.-proposed-wording"><h2>4. Proposed Wording</h2></a>
                <p>This wording is relative to [N4296].</p>
                <a name="4.1-shared-state-early-release" href="#4.1-shared-state-early-release"><h3>4.1 Shared state early release</h3></a>
                <p>Change 30.6.4 [futures.state], shared state, as indicated.</p>
                <p>Add the following as a new paragraph after paragraph 11:</p>
                <blockquote>
                    <p>
                        Implementations are allowed to execute user-defined destructors for shared
                        state results without releasing the shared state when this cannot be
                        otherwise observed.
                    </p>
                </blockquote>
                <a name="4.2-`promisereset`" href="#4.2-`promisereset`"><h3>4.2 <code>promise::reset</code></h3></a>
                <p>Change 30.6.5 [futures.promise], class template <code>promise</code>, as indicated.</p>
                <p>Add the following at the end of the synopsis:</p>
                <blockquote>
                    <div>
                        <div id="highlighter_493292" class="syntaxhighlighter nogutter  cpp">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tbody>
                                    <tr>
                                        <td class="code">
                                            <div class="container">
                                                <div class="line number1 index0 alt2"><code class="cpp comments">// modifiers</code></div>
                                                <div class="line number2 index1 alt1"><code class="cpp keyword bold">void</code> <code class="cpp plain">reset();</code></div>
                                                <div class="line number3 index2 alt2"><code class="cpp keyword bold">template</code> <code class="cpp plain">&lt;</code><code class="cpp keyword bold">class</code> <code class="cpp plain">Allocator&gt;</code></div>
                                                <div class="line number4 index3 alt1"><code class="cpp spaces">&nbsp;&nbsp;</code><code class="cpp keyword bold">void</code> <code class="cpp plain">reset(</code><code class="cpp keyword bold">const</code> <code class="cpp plain">Allocator&amp; a);</code></div>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </blockquote>
                <p>Add the following as a new paragraph after paragraph 26:</p>
                <blockquote>
                    <div>
                        <div id="highlighter_593450" class="syntaxhighlighter nogutter  cpp">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tbody>
                                    <tr>
                                        <td class="code">
                                            <div class="container">
                                                <div class="line number1 index0 alt2"><code class="cpp keyword bold">void</code> <code class="cpp plain">promise::reset();</code></div>
                                                <div class="line number2 index1 alt1"><code class="cpp keyword bold">template</code> <code class="cpp plain">&lt;</code><code class="cpp keyword bold">class</code> <code class="cpp plain">Allocator&gt;</code></div>
                                                <div class="line number3 index2 alt2"><code class="cpp spaces">&nbsp;&nbsp;</code><code class="cpp keyword bold">void</code> <code class="cpp plain">promise::reset(</code><code class="cpp keyword bold">const</code> <code class="cpp plain">Allocator&amp; a);</code></div>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <ul>
                        <li>
                            <em>Effects:</em> Abandons any shared state (30.6.4) and then as if
                            <code>promise().swap(*this)</code> for the first version and as if
                            <code>promise(allocator_arg, a).swap(*this)</code> for the second version.
                        </li>
                    </ul>
                </blockquote>
                <a name="4.3-`promiserelease`" href="#4.3-`promiserelease`"><h3>4.3 <code>promise::release</code></h3></a>
                <p>Change 30.6.5 [futures.promise], class template <code>promise</code>, as indicated.</p>
                <p>Add the following at the end of the synopsis:</p>
                <blockquote>
                    <div>
                        <div id="highlighter_581201" class="syntaxhighlighter nogutter  cpp">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tbody>
                                    <tr>
                                        <td class="code">
                                            <div class="container">
                                                <div class="line number1 index0 alt2"><code class="cpp comments">// modifiers</code></div>
                                                <div class="line number2 index1 alt1"><code class="cpp keyword bold">void</code> <code class="cpp plain">release() </code><code class="cpp keyword bold">noexcept</code><code class="cpp plain">;</code></div>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </blockquote>
                <p>Add the following as a new paragraph after paragraph 26:</p>
                <blockquote>
                    <div>
                        <div id="highlighter_656831" class="syntaxhighlighter nogutter  cpp">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tbody>
                                    <tr>
                                        <td class="code">
                                            <div class="container">
                                                <div class="line number1 index0 alt2"><code class="cpp keyword bold">void</code> <code class="cpp plain">promise::release() </code><code class="cpp keyword bold">noexcept</code><code class="cpp plain">;</code></div>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <ul>
                        <li><em>Effects:</em> Abandons any shared state (30.6.4).</li>
                    </ul>
                </blockquote>
                <a name="4.4-`futureget`" href="#4.4-`futureget`"><h3>4.4 <code>future::get</code></h3></a>
                <p>Change 30.6.6 [futures.unique_future], class template <code>future</code>, as indicated.</p>
                <p>Change paragraph 15 as indicated:</p>
                <blockquote>
                    <ul>
                        <li>
                            <p><em>Effects:</em></p>

                            <ul>
                                <li>
                                    <p>
                                        <code>wait()</code>s until the shared state is ready, then retrieves the value
                                        stored in the shared state.
                                    </p>
                                </li>
                                <li><p><ins style="background-color: #A0FFA0;">releases the shared state (30.6.4).</ins></p></li>
                            </ul>
                        </li>
                    </ul>
                </blockquote>
                <a name="5.-references" href="#5.-references"><h2>5. References</h2></a>
                <ul>
                    <li>
                        <p>
                            [N4296] ISO/IEC JTC1 SC22 WG21, Programming Languages - C++, working draft, November 2014
                            <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf</a>
                        </p>
                    </li>
                    <li><p>[c++std-parallel-1162] If a shared state is made ready when there's noone around, does it make a sound?</p></li>
                </ul>
            </article>
        </section>
    </div>
</body>
