<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">

<style type="text/css">
pre {margin-left:20pt; }
pre > i {
  font-family: "OCR A Extended", "Consolas", "Lucida Console", monospace;
  font-style:italic;
}
code > i {
  font-family: "OCR A Extended", "Consolas", "Lucida Console", monospace;
  font-style:italic;
}
pre > em {
  font-family: "OCR A Extended", "Consolas", "Lucida Console", monospace;
  font-style:italic;
}
code > em {
  font-family: "OCR A Extended", "Consolas", "Lucida Console", monospace;
  font-style:italic;
}
body { color: #000000; background-color: #FFFFFF; }
del { text-decoration: line-through; color: #8B0040; }
ins { text-decoration: underline; color: #005100; }

p.example { margin-left: 2em; }
pre.example { margin-left: 2em; }
div.example { margin-left: 2em; }

code.extract { background-color: #F5F6A2; }
pre.extract { margin-left: 2em; background-color: #F5F6A2;
  border: 1px solid #E1E28E; }

p.function { }
.attribute { margin-left: 2em; }
.attribute dt { float: left; font-style: italic;
  padding-right: 1ex; }
.attribute dd { margin-left: 0em; }

blockquote.std { color: #000000; background-color: #F1F1F1;
  border: 1px solid #D1D1D1;
  padding-left: 0.5em; padding-right: 0.5em; }
blockquote.stddel { text-decoration: line-through;
  color: #000000; background-color: #FFEBFF;
  border: 1px solid #ECD7EC;
  padding-left: 0.5empadding-right: 0.5em; ; }

blockquote.stdins { text-decoration: underline;
  color: #000000; background-color: #C8FFC8;
  border: 1px solid #B3EBB3; padding: 0.5em; }

table { border: 1px solid black; border-spacing: 0px;
  margin-left: auto; margin-right: auto; }
th { text-align: left; vertical-align: top;
  padding-left: 0.4em; border: none; 
  padding-right: 0.4em; border: none; }
td { text-align: left; vertical-align: top;
  padding-left: 0.4em; border: none;
  padding-right: 0.4em; border: none; }
</style>

<title>Fixes for optional objects</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"> </script>
<script type="text/javascript">$(function() {
    var next_id = 0
    function find_id(node) {
        // Look down the first children of 'node' until we find one
        // with an id. If we don't find one, give 'node' an id and
        // return that.
        var cur = node[0];
        while (cur) {
            if (cur.id) return curid;
            if (cur.tagName == 'A' && cur.name)
                return cur.name;
            cur = cur.firstChild;
        };
        // No id.
        node.attr('id', 'gensection-' + next_id++);
        return node.attr('id');
    };

    // Put a table of contents in the #toc nav.

    // This is a list of <ol> elements, where toc[N] is the list for
    // the current sequence of <h(N+2)> tags. When a header of an
    // existing level is encountered, all higher levels are popped,
    // and an <li> is appended to the level
    var toc = [$("<ol/>")];
    $(':header').not('h1').each(function() {
        var header = $(this);
        // For each <hN> tag, add a link to the toc at the appropriate
        // level.  When toc is one element too short, start a new list
        var levels = {H2: 0, H3: 1, H4: 2, H5: 3, H6: 4};
        var level = levels[this.tagName];
        if (typeof level == 'undefined') {
            throw 'Unexpected tag: ' + this.tagName;
        }
        // Truncate to the new level.
        toc.splice(level + 1, toc.length);
        if (toc.length < level) {
            // Omit TOC entries for skipped header levels.
            return;
        }
        if (toc.length == level) {
            // Add a <ol> to the previous level's last <li> and push
            // it into the array.
            var ol = $('<ol/>')
            toc[toc.length - 1].children().last().append(ol);
            toc.push(ol);
        }
        var header_text = header.text();
        toc[toc.length - 1].append(
            $('<li/>').append($('<a href="#' + find_id(header) + '"/>')
                              .text(header_text)));
    });
    $('#toc').append(toc[0]);
})
</script>
</head>

<body>


<!--<table>
<tr><td>Doc. no.</td><td>NXXXX=XX-XXXX</td></tr>
<tr><td>Date</td><td>YYYY-MM-DD</td></tr>
<tr><td valign='top'>Authors</td><td>Fernando Cacciola<br>Andrzej Krzemie&#x144;ski</td></tr>
<tr><td valign='top'>Contact</td><td><a href="mailto:fernando.cacciola@gmail.com">fernando.cacciola@gmail.com</a><br><a href='mailto:akrzemi1@gmail.com'>akrzemi1@gmail.com</a></td></tr>
<tr><td>Addresses</td><td>LWG</td></tr>
</table>-->

<h1><a name='title'>Fixes for optional objects</a></h1>

<p>
ISO/IEC JTC1 SC22 WG21 N3966 2014-03-01
</p>

<address>
Fernando Cacciola, fernando.cacciola@gmail.com
</address>
<address>
Andrzej Krzemie&#x144;ski, akrzemi1@gmail.com

</address>

<p>Project: Programming Language C++, fundamentals-ts</p>


<h2><a name='intro'>Introduction</a></h2>

<p>This document proposes a number of wording fixes, as suggested in Issaquah meeting, to optional objects proposed in <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3793.html">N3793</a>. We do not propose any changes in the functionality. We only reworded the standardese, and applied bug fixes:</p>

<ul>
<li>Got rid of terms 'engaged' and 'disengaged'; now using term 'contains a value' instead.</li>
<li>Using term 'direct-non-list-initialization'; it was missing in a number of places.</li>
<li>Now using alias template <code>decay_t</code> in place of the old type trait.</li>
<li>Changed the conditions under which function <code>value_or</code> shall be <code>costexpr</code>.</li>
<li>Fixed spelling and grammar mistakes.</li>
</ul>

<h2><a name='toc'>Table of contents</a></h2>

<p id='toc'></p>



<h2><a name='wording'>Proposed wording</a></h2>

<p>The insertions and deletions in this section describe the changes to Fundamentals TS after applying the changes from N3793. In other words, the changes are relative to N3793.</p>

Change [optional.synop]:

<blockquote class="std"> 
<pre>
  // <em><a href="#optional.inplace">5.5</a>, In-place construction</em>
  struct in_place_t{};
  constexpr in_place_t in_place{};

  // <em><a href="#optional.nullopt">5.6</a>, <del>Disengaged</del><ins>No-value</ins> state indicator</em>
  struct nullopt_t{<em>see below</em>};
  constexpr nullopt_t nullopt(<em>unspecified</em>);
  
  // <em><a href="#optional.bad_optional_access">5.7</a>, class bad_optional_access</em>
  class bad_optional_access;</pre>
</blockquote>

<blockquote class="std"> 
<pre>
  <var>private:</var>
    <del><var>bool init; //</var> <em>exposition only</em></del>
    <var>T*   val;  //</var> <em>exposition only</em>
  };
</pre>
</blockquote>

Replace [optional.object], para 1 and 2 with the following

<blockquote class="std">

<p><ins>Any instance of <code>optional&lt;T&gt;</code> at any given time can either <em>contain a value</em> or <em>not contain a value</em>. When an instance of <code>optional&lt;T&gt;</code> contains a value, it means that an object of type <code>T</code>, referred to as the optional object's <em>contained value</em>, is allocated within the storage of the optional object. Implementations are not permitted to use additional storage, such as dynamic memory, to allocate its contained value. The contained value shall be allocated in a region of the <code>optional&lt;T&gt;</code> storage suitably aligned for the type <code>T</code>. When an instance of <code>optional&lt;T&gt;</code> contains a value, its contextual conversion to <code>bool</code> returns <code>true</code>; otherwise it returns <code>false</code>.
</blockquote>


<blockquote class="std">
<ins>Member <code><var>val</var></code> is provided for exposition only. When an optional object contains a value <code><var>val</var></code> points to the contained value.</ins>
</blockquote>





<p>Change [optional.object] subclauses as follows:</p>
  

  <blockquote class="std">


<h5><a name="optional.object.ctor">5.4.1 Constructors <span style="float:right">[optional.object.ctor]</span></a></h5>

  
  <p class="function">
  <code>constexpr optional&lt;T&gt;::optional() noexcept;</code><br>
  <code>constexpr optional&lt;T&gt;::optional(nullopt_t) noexcept;</code>
  </p>

  <dl class="attribute">
  <dt>Postconditions:</dt> <dd><p><del><code>*this</code> is disengaged</del><ins><code>!*this</code></ins>.</p></dd>
  <dt>Remarks:</dt> <dd><p>No contained value is initialized. For every object type <code>T</code> these constructors shall be <code>constexpr</code> constructors (C++11 &sect;7.1.5).</p></dd>
  </dl>

  
  <p class="function">
  <code>optional&lt;T&gt;::optional(const optional&lt;T&gt;&amp; <var>rhs</var>);</code>
  </p>

  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_copy_constructible&lt;T&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>If <code><ins>bool(</ins><var>rhs</var><ins>)</ins></code> <del>is engaged </del>initializes the contained value as if direct-non-list-initializing an object of type <code>T</code> with the expression <code>*<var>rhs</var></code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code>bool(<var>rhs</var>) == bool(*this)</code>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
  </dl>
  
  
  <p class="function">
  <code>optional&lt;T&gt;::optional(optional&lt;T&gt; &amp;&amp; <var>rhs</var>) noexcept(<em>see below</em>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_move_constructible&lt;T&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>If <code><ins>bool(</ins><var>rhs</var><ins>)</ins></code> <del>is engaged </del>initializes the contained value as if direct-non-list-initializing an object of type <code>T</code> with the expression <code>std::move(*<var>rhs</var>)</code>. <code>bool(<var>rhs</var>)</code> is unchanged.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code>bool(<var>rhs</var>) == bool(*this)</code>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>The expression inside <code>noexcept</code> is equivalent to:</p> <pre>is_nothrow_move_constructible&lt;T&gt;::value</pre></dd>
  </dl>

  
  <p class="function">
  <code>constexpr optional&lt;T&gt;::optional(const T&amp; <var>v</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_copy_constructible&lt;T&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>Initializes the contained value as if direct-non-list-initializing an object of type <code>T</code> with the expression <code><var>v</var></code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>If <code>T</code>'s selected constructor is a <code>constexpr</code> constructor, this constructor shall be a <code>constexpr</code> constructor.</p></dd>
  </dl>
  
  
  <p class="function">
  <code>constexpr optional&lt;T&gt;::optional(T&amp;&amp; <var>v</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_move_constructible&lt;T&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>Initializes the contained value as if direct-non-list-initializing an object of type <code>T</code> with the expression <code>std::move(<var>v</var>)</code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>If <code>T</code>'s selected constructor is a <code>constexpr</code> constructor, this constructor shall be a <code>constexpr</code> constructor.</p></dd>
  </dl>
  
<!--  
  <p class="function">
  <code>template &lt;class U&gt; explicit optional&lt;T&gt;::optional(U&amp;&amp; <var>v</var>);<br>template &lt;class U&gt; optional&lt;T&gt;::optional(U&amp;&amp; <var>v</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_constructible&lt;T, U&amp;&amp;&gt;::value</code> is true.</p></dd>
    <dt>Effects:</dt> <dd><p>Initializes the contained value as if initializing an object of type <code>T</code> with argument <code>std::forward&lt;U&gt;(<var>v</var>)</code>.</p></dd>

    <dt>Postconditions:</dt> <dd><p><code>*this</code> is engaged and <code>*(*this)</code> is equivalent to <code><var>v</var></code> if converted to <code>T</code>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>The first function shall not participate in overload resolution unless <code>OnlyExplicitlyConstructible(T, U&amp;&amp;)</code> is <code>true</code>. The second function shall not participate in the overload resolution unless <code>is_convertible&lt;U&amp;&amp;, T&gt;::value</code> is <code>true</code>. The expression inside <code>noexcept</code> is equivalent to:</p> <pre>noexcept(T(std::declval&lt;U&amp;&amp;&gt;()))</pre></dd>
  </dl>
  
  
  <p class="function">
  <code>template &lt;class U&gt; explicit optional&lt;T&gt;::optional(const optional&lt;U&gt;&amp; <var>rhs</var>);<br>template &lt;class U&gt;  optional&lt;T&gt;::optional(const optional&lt;U&gt;&amp; <var>rhs</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_constructible&lt;T, const U&amp;&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>If <code>bool(<var>rhs</var>) == true</code> initializes the contained value as if constructing an object of type <code>T</code> with argument <code>*<var>rhs</var></code></p></dd>
    <dt>Postconditions:</dt> <dd><p>If <code>bool(<var>rhs</var>) == false</code> then <code>*this</code> is disengaged; otherwise <code>*this</code> is engaged and <code>*(*this)</code> is equivalent to <code>*<var>rhs</var></code> if converted to <code>T</code>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>The first function shall not participate in overload resolution unless <code>OnlyExplicitlyConstructible(T, const U&amp;)</code> is <code>true</code>. The second function shall not participate in the overload resolution unless <code>is_convertible&lt;const U&amp;, T&gt;::value</code> is <code>true</code>.</dd>
  </dl>
  
  
  <p class="function">
  <code>template &lt;class U&gt; explicit optional&lt;T&gt;::optional(optional&lt;U&gt;&amp;&amp; <var>rhs</var>);<br>template &lt;class U&gt;  optional&lt;T&gt;::optional(optional&lt;U&gt;&amp;&amp; <var>rhs</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_constructible&lt;T, U&amp;&amp;&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>If <code>bool(<var>rhs</var>) == true</code> initializes the contained value as if constructing an object of type <code>T</code> with argument <code>std::move(*<var>rhs</var>)</code></p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>The first function shall not participate in overload resolution unless <code>OnlyExplicitlyConstructible(T, U&amp;&amp;)</code> is <code>true</code>. The second function shall not participate in the overload resolution unless <code>is_convertible&lt;U&amp;&amp;, T&gt;::value</code> is <code>true</code>.</dd>
  </dl>
  
  <p class="function">
  <code>template &lt;class U&gt; explicit optional&lt;T&gt;::optional(initializer_list&lt;U&gt; <var>il</var>);<br>template &lt;class U&gt;  optional&lt;T&gt;::optional(initializer_list&lt;U&gt;<var>il</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_constructible&lt;T, initializer_list&lt;U&gt;&amp;&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>If <code>bool(<var>rhs</var>) == true</code> initializes the contained value as if constructing an object of type <code>T</code> with argument <code><var>il</var></code></p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>The first function shall not participate in overload resolution unless <code>OnlyExplicitlyConstructible(T, initializer_list&lt;U&gt;)</code> is <code>true</code>. The second function shall not participate in the overload resolution unless <code>is_convertible&lt;initializer_list&lt;U&gt;&amp;, T&gt;::value</code> is <code>true</code>.</dd>
  </dl>
-->
  
  <p class="function">
  <code>template &lt;class... Args&gt; constexpr explicit optional(in_place_t, Args&amp;&amp;... <var>args</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_constructible&lt;T, Args&amp;&amp;...&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>Initializes the contained value as if direct-non-list-initializing an object of type <code>T</code> with the arguments <code>std::forward&lt;Args&gt;(<var>args</var>)...</code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>If <code>T</code>'s constructor selected for the initialization is a <code>constexpr</code> constructor, this constructor shall be a <code>constexpr</code> constructor.</p></dd>
  </dl>


  <p class="function">
  <code>template &lt;class U, class... Args&gt;<br>
  constexpr explicit optional(in_place_t, initializer_list&lt;U&gt; <var>il</var>, Args&amp;&amp;... <var>args</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_constructible&lt;T, initializer_list&lt;U&gt;&amp;, Args&amp;&amp;...&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>Initializes the contained value as if direct-non-list-initializing an object of type <code>T</code> with the arguments <code><var>il</var>, std::forward&lt;Args&gt;(<var>args</var>)...</code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>The function shall not participate in overload resolution unless <code>is_constructible&lt;T, initializer_list&lt;U&gt;&amp;, Args&amp;&amp;...&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>If <code>T</code>'s constructor selected for the initialization is a <code>constexpr</code> constructor, this constructor shall be a <code>constexpr</code> constructor.</p></dd>
  </dl>


<h5><a name="optional.object.dtor">5.4.2 Destructor  <span style="float:right">[optional.object.dtor]</span></a></h5>
  
  <p class="function"> 
  <code>optional&lt;T&gt;::~optional();</code>
  </p>
  
  <dl class="attribute">
    <dt>Effects:</dt> <dd><p>If <code>is_trivially_destructible&lt;T&gt;::value != true</code> and <code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del>, calls <code><var>val</var>-&gt;T::~T()</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>If <code>is_trivially_destructible&lt;T&gt;::value == true</code> then this destructor shall be a trivial destructor.</p></dd>
  </dl>
  
  
<h5><a name="optional.object.assign">5.4.3 Assignment  <span style="float:right">[optional.object.assign]</span></a></h5>
  
  
  <p class="function">
  <code>optional&lt;T&gt;&amp; optional&lt;T&gt;::operator=(nullopt_t) noexcept;</code>
  </p>

  <dl class="attribute">
    <dt>Effects:</dt> <dd><p>If <code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del> calls <code><var>val</var>-&gt;T::~T()</code> to destroy the contained value; otherwise no effect.</p></dd>
    <dt>Returns:</dt> <dd><p><code>*this</code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code><ins>!</ins>*this</code><del> is disengaged</del>.</p></dd>
  </dl>
  
 
  <p class="function">
  <code>optional&lt;T&gt;&amp; optional&lt;T&gt;::operator=(const optional&lt;T&gt;&amp; <var>rhs</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_copy_constructible&lt;T&gt;::value</code> is <code>true</code> and <code>is_copy_assignable&lt;T&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> 
	<dd><br><ul>
	  <li>If <del><code>*this</code> is disengaged and <code><var>rhs</var></code> is disengaged</del><ins><code>!*this &amp;&amp; !<var>rhs</var></code></ins>, no effect, otherwise</li> 
	  <li>if <del><code>*this</code> is engaged and <code><var>rhs</var></code> is disengaged</del><ins><code>bool(*this) &amp;&amp; !<var>rhs</var></code></ins>, destroys the contained value by calling <code><var>val</var>-&gt;T::~T()</code>, otherwise</li>
	  <li>if <del><code>*this</code> is disengaged and <code><var>rhs</var></code> is engaged</del><ins><code>!*tis &amp;&amp; bool(<var>rhs</var>)</code></ins>, initializes the contained value as if direct-non-list-initializing an object of type <code>T</code> with <code>*<var>rhs</var></code>, otherwise</li>
	  <li>(if <del>both <code>*this</code> and <code><var>rhs</var></code> are engaged</del><ins><code>bool(*this) &amp;&amp; bool(<var>rhs</var>)</code></ins>) assigns <code>*<var>rhs</var></code> to the contained value.</li>
	  </ul></dd>
    <dt>Returns:</dt> <dd><p><code>*this</code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code>bool(<var>rhs</var>) == bool(*this)</code>.</p></dd>
    <dt>Exception Safety:</dt> <dd><p>If any exception is thrown, the values <ins><code>bool(*this)</code> and <code>bool(<var>rhs</var>)</code></ins><del> of <code><var>init</var></code> and <code><var>rhs.init</var></code></del> remain unchanged. If an exception is thrown during the call to <code>T</code>'s copy constructor, no effect. If an exception is thrown during the call to <code>T</code>'s copy assignment, the state of its contained value is as defined by the exception safety guarantee of <code>T</code>'s copy assignment.</p></dd>
  </dl>
  
 
  <p class="function">
  <code>optional&lt;T&gt;&amp; optional&lt;T&gt;::operator=(optional&lt;T&gt;&amp;&amp; <var>rhs</var>) noexcept(<em>see below</em>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_move_constructible&lt;T&gt;::value</code> is <code>true</code> and <code>is_move_assignable&lt;T&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt>
	<dd><br><ul>
	  <li>If <del><code>*this</code> is disengaged and <code><var>rhs</var></code> is disengaged</del><ins><code>!*this &amp;&amp; !<var>rhs</var></code></ins>, no effect, otherwise</li> 
	  <li>if <del><code>*this</code> is engaged and <code><var>rhs</var></code> is disengaged</del><ins><code>bool(*this) &amp;&amp; !<var>rhs</var></code></ins>, destroys the contained value by calling <code><var>val</var>-&gt;T::~T()</code>, otherwise</li>
	  <li>if <del><code>*this</code> is disengaged and <code><var>rhs</var></code> is engaged</del><ins><code>!*tis &amp;&amp; bool(<var>rhs</var>)</code></ins>, initializes the contained value as if direct-non-list-initializing an object of type <code>T</code> with <code>std::move(*<var>rhs</var>)</code>, otherwise</li>
	  <li>(if <del>both <code>*this</code> and <code><var>rhs</var></code> are engaged</del><ins><code>bool(*this) &amp;&amp; bool(<var>rhs</var>)</code></ins>) assigns <code>std::move(*<var>rhs</var>)</code> to the contained value.</li>
	  </ul></dd>
    <dt>Returns:</dt> <dd><p><code>*this</code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code>bool(<var>rhs</var>) == bool(*this)</code>.</p></dd>

    <dt>Remarks:</dt> <dd><p>The expression inside <code>noexcept</code> is equivalent to:</p> <pre>is_nothrow_move_assignable&lt;T&gt;::value &amp;&amp; is_nothrow_move_constructible&lt;T&gt;::value</pre></dd>
    <dt>Exception Safety:</dt> <dd><p>If any exception is thrown, the values <ins><code>bool(*this)</code> and <code>bool(<var>rhs</var>)</code></ins><del> of <code><var>init</var></code> and <code><var>rhs.init</var></code></del> remain unchanged. If an exception is thrown during the call to <code>T</code>'s move constructor, the state of <code>*rhs.val</code> is determined by exception safety guarantee of <code>T</code>'s move constructor. If an exception is thrown during the call to <code>T</code>'s move assignment, the state of <code><var>*val</var></code> and <code>*rhs.val</code> is determined by exception safety guarantee of <code>T</code>'s move assignment.</p></dd>

  </dl>
  
  
  <p class="function">
  <code>template &lt;class U&gt; optional&lt;T&gt;&amp; optional&lt;T&gt;::operator=(U&amp;&amp; <var>v</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_constructible&lt;T, U&gt;::value</code> is <code>true</code> and <code>is_assignable&lt;T&amp;, U&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>If <code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del> assigns <code>std::forward&lt;U&gt;(<var>v</var>)</code> to the contained value; otherwise initializes the contained value as if direct-non-list-initializing object of type <code>T</code> with <code>std::forward&lt;U&gt;(<var>v</var>)</code>.</p></dd>
    <dt>Returns:</dt> <dd><p><code>*this</code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del>.</p></dd>
    <dt>Exception Safety:</dt> <dd><p>If any exception is thrown, value <ins><code>bool(*this)</code></ins><del>of <code><var>init</var></code></del> remains unchanged. If an exception is thrown during the call to <code>T</code>'s constructor, the state of <code><var>v</var></code> is determined by exception safety guarantee of <code>T</code>'s constructor. If an exception is thrown during the call to <code>T</code>'s assignment, the state of <code><var>*val</var></code> and <code><var>v</var></code> is determined by exception safety guarantee of <code>T</code>'s assignment.</p></dd>
    <dt>Remarks:</dt> <dd><p>The function shall not participate in overload resolution unless  <code>is_same&lt;<del>typename decay&lt;U&gt;::type</del><ins>decay_t&lt;U&gt;, T&gt;::value</code> is  <code>true</code>.</dd>
  </dl>
  <p>[<i>Note:</i> The reason to provide such generic assignment and then constraining it so that effectively <code>T</code> == <code>U</code> is to guarantee that assignment of the form <code>o = {}</code> is unambiguous. &mdash;<i>end note</i>]</p>

  
  <p class="function">
  <code>template &lt;class... Args&gt; void optional&lt;T&gt;::emplace(Args&amp;&amp;... <var>args</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_constructible&lt;T, Args&amp;&amp;...&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>Calls <code>*this = nullopt</code>. Then initializes the contained value as if <del>constructing</del><ins>direct-non-list-initializing</ins> an object of type <code>T</code> with the arguments <code>std::forward&lt;Args&gt;(<var>args</var>)...</code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Exception Safety:</dt> <dd><p>If an exception is thrown during the call to <code>T</code>'s constructor, <code>*this</code> <del>is disengaged</del><ins>does not contain a value</ins>, and the previous <code><var>*val</var></code> (if any) has been destroyed.</p></dd>
  </dl>
  
  
   <p class="function">
  <code>template &lt;class U, class... Args&gt; void optional&lt;T&gt;::emplace(initializer_list&lt;U&gt; <var>il</var>, Args&amp;&amp;... <var>args</var>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_constructible&lt;T, initializer_list&lt;U&gt;&amp;, Args&amp;&amp;...&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt> <dd><p>Calls <code>*this = nullopt</code>. Then initializes the contained value as if <del>constructing</del><ins>direct-non-list-initializing</ins> an object of type <code>T</code> with the arguments <code><var>il</var>, std::forward&lt;Args&gt;(<var>args</var>)...</code>.</p></dd>
    <dt>Postconditions:</dt> <dd><p><code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Exception Safety:</dt> <dd><p>If an exception is thrown during the call to <code>T</code>'s constructor, <code>*this</code> <del>is disengaged</del><ins>does not contain a value</ins>, and the previous <code><var>*val</var></code> (if any) has been destroyed.</p></dd>
    <dt>Remarks:</dt> <dd><p>The function shall not participate in overload resolution unless <code>is_constructible&lt;T, initializer_list&lt;U&gt;&amp;, Args&amp;&amp;...&gt;::value</code> is <code>true</code>.</p></dd>
  </dl>


  
<h5><a name="optional.object.swap">5.4.4 Swap <span style="float:right">[optional.object.swap]</span></a></h5>


  <p class="function">
  <code>void optional&lt;T&gt;::swap(optional&lt;T&gt;&amp; rhs) noexcept(<em>see below</em>);</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> L<del>V</del><ins>v</ins>alues of type T shall be swappable and <code>is_move_constructible&lt;T&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Effects:</dt>
	<dd><br><ul>
	  <li>If <del><code>*this</code> is disengaged and <code><var>rhs</var></code> is disengaged</del><ins><code>!*this &amp;&amp; !<var>rhs</var></code></ins>, no effect, otherwise</li> 
	  <li>if <del><code>*this</code> is engaged and <code><var>rhs</var></code> is disengaged</del><ins><code>bool(*this) &amp;&amp; !<var>rhs</var></code></ins>, initializes the contained value of <code><var>rhs</var></code> <del>by direct-initialization</del><ins>as if direct-non-list-initializing an object of type <code>T</code></ins> with <ins>the expression </ins><code>std::move(*(*this))</code>, followed by <code>val-&gt;T::~T()<del>, swap(<var>init</var>, <var>rhs.init</var>)</del></code>, <ins><code>*this</code> does not contain a value and <code><var>rhs</var></code> contains a value</ins>, otherwise</li>
	  <li>if <del><code>*this</code> is disengaged and <code><var>rhs</var></code> is engaged</del><ins><code>!*tis &amp;&amp; bool(<var>rhs</var>)</code></ins>, initializes the contained value of <code>*this</code> <del>by direct-initialization</del><ins>as if direct-non-list-initializing an object of type <code>T</code></ins> with <ins>the expression </ins><code>std::move(*<var>rhs</var>)</code>, followed by <code>rhs.val-&gt;T::~T()<del>, swap(<var>init</var>, <var>rhs.init</var>)</del></code><ins>, <code>*this</code> contains a value and <code><var>rhs</var></code> does not contain a value, otherwise</li>
	  <li>(if <del>both <code>*this</code> and <code><var>rhs</var></code> are engaged</del><ins><code>bool(*this) &amp;&amp; bool(<var>rhs</var>)</code></ins>) calls <code>swap(*(*this), *<var>rhs</var>)</code>.</li>
	  </ul></dd>
    <dt>Throws:</dt> <dd><p>Any exceptions that the expressions in the Effects clause throw.</p></dd>
    <dt>Remarks:</dt> <dd><p>The expression inside <code>noexcept</code> is equivalent to: <pre>is_nothrow_move_constructible&lt;T&gt;::value &amp;&amp; noexcept(swap(declval&lt;T&amp;&gt;(), declval&lt;T&amp;&gt;()))</pre></dd>
    <dt>Exception Safety:</dt> <dd><p>If any exception is thrown, values <del>of <code><var>init</var></code> and <code><var>rhs.init</var></code></del><ins><code>bool(*this)</code> and <code>bool(<var>rhs</var>)</code></ins> remain unchanged. If an exception is thrown during the call to function <code>swap</code> the state of <code><var>*val</var></code> and <code>*rhs.val</code> is determined by the exception safety guarantee of <code>swap</code> for lvalues of <code>T</code>. If an exception is thrown during the call to <code>T</code>'s move constructor, the state of <code><var>*val</var></code> and <code>*rhs.val</code> is determined by the exception safety guarantee of <code>T</code>'s move constructor.</p></dd>

  </dl>

  
  
<h5><a name="optional.object.observe">5.4.5 Observers  <span style="float:right">[optional.object.observe]</span></a></h5>


  <p class="function">
  <code>constexpr T const* optional&lt;T&gt;::operator-&gt;() const;<br>T* optional&lt;T&gt;::operator-&gt;();</code>

  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del>.</p></dd>
    <dt>Returns:</dt> <dd><p><code><var>val</var></code>.</p></dd>
    <dt>Throws:</dt> <dd><p>Nothing.</p></dd>
    <dt>Remarks:</dt> <dd><p>Unless <code>T</code> is a user-defined type with overloaded unary <code>operator&amp;</code>, the first function shall be a <code>constexpr</code> function.</p></dd>
  </dl>
  
  
  <p class="function">
  <code>constexpr T const&amp; optional&lt;T&gt;::operator*() const;<br>T&amp; optional&lt;T&gt;::operator*();</code>

  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code><ins>bool(</ins>*this<ins>)</ins></code><del> is engaged</del></p></dd>
    <dt>Returns:</dt> <dd><p><code>*<var>val</var></code>.</p></dd>
    <dt>Throws:</dt> <dd><p>Nothing.</p></dd>
    <dt>Remarks:</dt> <dd><p>The first function shall be a <code>constexpr</code> function.</p></dd>

  </dl>
  
  
  <p class="function">
  <code>constexpr explicit optional&lt;T&gt;::operator bool() noexcept;</code>
  </p>
  
  <dl class="attribute">
    <dt>Returns:</dt> <dd><p><del><code><var>init</var></code></del><ins><code>true</code> if and only if <code>*this</code> contains a value</ins>.</p></dd>
    <dt>Remarks:</dt> <dd><p>This function shall be a <code>constexpr</code> function.</p></dd>
  </dl>
  
  
  <p class="function">
  <code>constexpr T const&amp; optional&lt;T&gt;::value() const;<br>T&amp; optional&lt;T&gt;::value();</code>
  </p>
  
  <dl class="attribute">
    <dt>Returns:</dt> <dd><p><code><var>*val</var></code>, if <code>bool(*this)</code>.</p></dd>
    <dt>Throws:</dt> <dd><p><code>bad_optional_access</code> if <code>!*this</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>The first function shall be a <code>constexpr</code> function.</p></dd>

  </dl>
  
  

  <p class="function">
  <code>template &lt;class U&gt; constexpr T optional&lt;T&gt;::value_or(U&amp;&amp; <var>v</var>) const&amp;;</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_copy_constructible&lt;T&gt;::value</code> is <code>true</code> and <code>is_convertible&lt;U&amp;&amp;, T&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Returns:</dt> <dd><p><code>bool(*this) ? **this : static_cast&lt;T&gt;(std::forward&lt;U&gt;(<var>v</var>))</code>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Exception Safety:</dt> <dd><p>If <del><code><var>init</var> == true</code></del><ins><code>bool(*this)</code></ins> and exception is thrown during the call to <code>T</code>'s constructor, the value of <del><code><var>init</var></code></del><ins><code>bool(*this)</code></ins> and <code><var>v</var></code> remains unchanged and the state of <code><var>*val</var></code> is determined by the exception safety guarantee of the selected constructor of <code>T</code>. Otherwise, when <ins>an </ins>exception is thrown during the call to <code>T</code>'s constructor, the value of <code><var>*this</var></code> remains unchanged and the state of <code><var>v</var></code> is determined by the exception safety guarantee of the selected constructor of <code>T</code>.</p></dd>
    <dt>Remarks:</dt> <dd><p>If <del>both</del><ins>any of the</ins> constructors of <code>T</code> which could be selected <del>are</del><ins>is a</ins> <code>constexpr </code> constructor<del>s</del>, this function shall be a <code>constexpr</code> function.</p></dd>
  </dl>
  
  
  <p class="function">
  <code>template &lt;class U&gt; T optional&lt;T&gt;::value_or(U&amp;&amp; <var>v</var>) &amp;&amp;;</code>
  </p>
  
  <dl class="attribute">
    <dt>Requires:</dt> <dd><p><code>is_move_constructible&lt;T&gt;::value</code> is <code>true</code> and <code>is_convertible&lt;U&amp;&amp;, T&gt;::value</code> is <code>true</code>.</p></dd>
    <dt>Returns:</dt> <dd><p><code>bool(*this) ? std::move(**this) : static_cast&lt;T&gt;(std::forward&lt;U&gt;(<var>v</var>))</code>.</p></dd>
    <dt>Throws:</dt> <dd><p>Any exception thrown by the selected constructor of <code>T</code>.</p></dd>
    <dt>Exception Safety:</dt> <dd><p>If <del><code><var>init</var> == true</code></del><ins><code>bool(*this)</code></ins> and exception is thrown during the call to <code>T</code>'s constructor, the value of <del><code><var>init</var></code></del><ins><code>bool(*this)</code></ins> and <code><var>v</var></code> remains unchanged and the state of <code><var>*val</var></code> is determined by the exception safety guarantee of the <code>T</code>'s constructor. Otherwise, when <ins>an </ins>exception is thrown during the call to <code>T</code>'s constructor, the value of <code><var>*this</var></code> remains unchanged and the state of <code><var>v</var></code> is determined by the exception safety guarantee of the selected constructor of <code>T</code>.</p></dd>
  </dl>



<h4><a name="optional.inplace">5.5 In-place construction  <span style="float:right">[optional.inplace]</span></a></h4>


  <p class="function">
  <code>struct in_place_t{}; <br>constexpr in_place_t in_place{};</code>
  </p>

  <p>The struct <code>in_place_t</code> is an empty structure type used as a unique type to disambiguate constructor and function overloading. Specifically, <code>optional&lt;T&gt;</code> has a constructor with <code>in_place_t</code> as the first argument followed by an argument pack; this indicates that <code>T</code> should be constructed in-place (as if by a call to placement new expression) with the forwarded argument pack as parameters.
  </p>

  
<h4><a name="optional.nullopt">5.6 <del>Disengaged</del><ins>No-value</ins> state indicator  <span style="float:right">[optional.nullopt]</span></a></h4>


  <p class="function">
  <code>struct nullopt_t{<em>see below</em>}; <br>constexpr nullopt_t nullopt(<em>unspecified</em>);</code>
  </p>

  <p>The struct <code>nullopt_t</code> is an empty structure type used as a unique type to indicate <del>a disengaged state</del><ins>the state of not containing a value</ins> for <code>optional</code> objects. In particular, <code>optional&lt;T&gt;</code> has a constructor with <code>nullopt_t</code> as single argument; this indicates that a<ins>n</ins><del> disengaged</del> optional object <ins>not containing a value </ins>shall be constructed.
  </p>
  
  <p>Type <code>nullopt_t</code> shall not have a default constructor. It shall be a literal type. Constant <code>nullopt</code> shall be initialized with an argument of literal type.</p>
  
 
  
<h4><a name="optional.bad_optional_access">5.7 Class <code>bad_optional_access</code>  <span style="float:right">[optional.bad_optional_access]</span></a></h4>
 
<pre>namespace std {
  class bad_optional_access : public logic_error {
  public:
    explicit bad_optional_access(const string&amp; what_arg);
    explicit bad_optional_access(const char* what_arg);
  };
}</pre>

<p>The class <code>bad_optional_access</code> defines the type of objects thrown as exceptions to report the situation where an attempt is made to access the value of a<ins>n</ins><del> disengaged</del> optional object<ins> that does not contain a value</ins>.</p>

  <p class="function"> 
  <code>bad_optional_access(const string&amp; what_arg);</code>
  </p>
  
  <dl class="attribute">
  <dt>Effects:</dt> <dd><p>Constructs an object of class <code>bad_optional_access</code>.</p></dd>
  <dt>Postcondition:</dt> <dd><p><code>strcmp(what(), what_arg.c_str()) == 0</code>.</p></dd>
  </dl>
  
  <p class="function"> 
  <code>bad_optional_access(const char* what_arg);</code>
  </p>
  
  <dl class="attribute">
  <dt>Effects:</dt> <dd><p>Constructs an object of class <code>bad_optional_access</code>.</p></dd>
  <dt>Postcondition:</dt> <dd><p><code>strcmp(what(), what_arg) == 0</code>.</p></dd>
  </dl>

</blockquote>

<p>Change [optional.relops] as follows:</p>

<blockquote class="std"> 
<h4><a name="optional.relops">5.8 Relational operators  <span style="float:right">[optional.relops]</span></a></h4>
 

  <p class="function"> 
  <code>template &lt;class T&gt; constexpr bool operator==(const optional&lt;T&gt;&amp; x, const optional&lt;T&gt;&amp; y);</code>
  </p>
  
  <dl class="attribute">
  <dt>Requires:</dt> <dd><p><code>T</code> shall meet the requirements of <code>EqualityComparable</code>.</p></dd>
  <dt>Returns:</dt> <dd><p>If <code>bool(x) != bool(y)</code>, <code>false</code>; otherwise if <code>bool(x) == false</code>, <code>true</code>; otherwise <code>*x == *y</code>.</p></dd>
  <dt>Remarks:</dt> <dd><p>Instantiations of this function template for which <code>*x == *y</code> is a core constant expression, shall be <code>constexpr</code> functions.</p></dd>
  </dl>
  
  
  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator!=(const optional&lt;T&gt;&amp; x, const optional&lt;T&gt;&amp; y);</code>
  </p>
  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code>!(x == y)</code>.</p></dd>
  </dl>
  
  
  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator&lt;(const optional&lt;T&gt;&amp; <var>x</var>, const optional&lt;T&gt;&amp; <var>y</var>);</code> 
  </p>

  <dl class="attribute">
  <dt>Requires:</dt> <dd><p><del>Expression </del><code>*<var>x</var> &lt; *<var>y</var></code> shall be well-formed and its result shall be convertible to <code>bool</code>.</p></dd>
  <dt>Returns:</dt> <dd><p>If <code>(!<var>y</var>)</code>, <code>false</code>; otherwise, if <code>(!<var>x</var>)</code>, <code>true</code>; otherwise <code>*<var>x</var> &lt; *<var>y</var></code>.</p></dd>
  <dt>Remarks:</dt> <dd><p>Instantiations of this function template for which expression <code>*<var>x</var> &lt; *<var>y</var></code> is a core constant expression, shall be <code>constexpr</code> functions.</p></dd>
  </dl>

</blockquote>

<p>Change [optional.nullops] as follows:</p>

<blockquote class="std"> 

 
<h4><a name="optional.nullops">5.9 Comparison with <code>nullopt</code> <span style="float:right">[optional.nullops]</span></a></h4>
 
  
  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator==(const optional&lt;T&gt;&amp; <var>x</var>, nullopt_t) noexcept;<br>template &lt;class T&gt; constexpr bool operator==(nullopt_t, const optional&lt;T&gt;&amp; x) noexcept;</code>
  </p>
  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code><del>(</del>!<var>x</var><del>)</del></code>.</p></dd>
  </dl>
  
  
  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator!=(const optional&lt;T&gt;&amp; <var>x</var>, nullopt_t) noexcept;<br>template &lt;class T&gt; constexpr bool operator!=(nullopt_t, const optional&lt;T&gt;&amp; x) noexcept;</code>
  </p>

  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code>bool(<var>x</var>)</code>.</p></dd>
  </dl> 

  <!-- -->
  
  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator&lt;(const optional&lt;T&gt;&amp; <var>x</var>, nullopt_t) noexcept;</code>
  </p>
  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code>false</code>.</p></dd>
  </dl>

  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator&lt;(nullopt_t, const optional&lt;T&gt;&amp; <var>x</var>) noexcept;</code>
  </p>
  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code>bool(<var>x</var>)</code>.</p></dd>
  </dl>

  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator&lt;=(const optional&lt;T&gt;&amp; <var>x</var>, nullopt_t) noexcept;</code>
  </p>
  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code><del>(</del>!<var>x</var><del>)</del></code>.</p></dd>
  </dl>

  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator&lt;=(nullopt_t, const optional&lt;T&gt;&amp; <var>x</var>) noexcept;</code>
  </p>
  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code>true</code>.</p></dd>
  </dl>
  
  
  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator&gt;(const optional&lt;T&gt;&amp; <var>x</var>, nullopt_t) noexcept;</code>
  </p>
  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code>bool(<var>x</var>)</code>.</p></dd>
  </dl>

  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator&gt;(nullopt_t, const optional&lt;T&gt;&amp; <var>x</var>) noexcept;</code>
  </p>
  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code>false</code>.</p></dd>
  </dl>

  
  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator&gt;=(const optional&lt;T&gt;&amp; <var>x</var>, nullopt_t) noexcept;</code>
  </p>
  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code>true</code>.</p></dd>
  </dl>

  <p class="function">
  <code>template &lt;class T&gt; constexpr bool operator&gt;=(nullopt_t, const optional&lt;T&gt;&amp; <var>x</var>) noexcept;</code>
  </p>
  
  <dl class="attribute">
  <dt>Returns:</dt> <dd><p><code><del>(</del>!<var>x</var><del>)</del></code>.</p></dd>
  </dl>
 
</blockquote>



<h2><a name='acknowledgements'>Acknowledgements</a></h2>

<p>Jonathan Wakely reviewed the proposal and offered useful suggestions.</p>

<p>Daniel Kr&uuml;gler provided numerous helpful suggestions, corrections and comments on this proposal; in particular he suggested the addition of and reference implementation for "perfect initialization" operations.</p>

<p>Many people from the Boost community, participated in the developement of the Boost.Optional library. Sebastian Redl suggested the usage of function <code>emplace</code>. </p>


<p>Tony Van Eerd offered many useful suggestions and corrections to the proposal.</p>

<p>People in discussion group "ISO C++ Standard - Future Proposals" provided numerous insightful suggestions: Vladimir Batov (who described and supported the perfect forwarding constructor), Nevin Liber, Ville Voutilainen, Richard Smiths, Dave Abrahams, Chris Jefferson, Jeffrey Yasskin, Nikolay Ivchenkov, Matias Capeletto, Olaf van der Spek, Vincent Jacquet, Kazutoshi Satoda, Vicente J. Botet Escriba, R&oacute;bert D&aacute;vid, Vincent Jacquet, Luc Danton, Greg Marr, and many more. </p>

<p>Joe Gottman suggested the support for hashing some optional objects.</p>

<p>Nicol Bolas suggested to make <code>operator-&gt;</code> conditionally <code>constexpr</code> based on whether <code>T::operator&amp;</code> is overloaded.</p>

  

</body>
</html>
