<!-- saved from url=(0022)http://internet.e-mail -->
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>I</title>
</head>

<body>

  <p><b><span lang="en-us">Author</span>:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  Fernando Cacciola<br>
  <b>Contact:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="mailto:fernando.cacciola@gmail.com">fernando.cacciola@gmail.com</a><br>
  <b>Organization:&nbsp;&nbsp;&nbsp; </b>SciSoft<br>
  <b>Date:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  2005-08-29<br>
  <b>Number:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  N1878=05-0138</p>
  <h1>A proposal to add an utility class to represent optional objects (Revision 1)</h1>
  <h1><b><i>Motivation and Scope</i></b></h1>
  <h3>A. Concepts</h3>
  <p>The fundamental data unit in C++ is the <b>object</b>, and according to the 
  C++ Object Model (1.8), <u>an object is a region of storage</u>, that is, a (possibly 
  fragmented) block of memory. <i>All</i> objects have an <i>object 
  representation</i> which is the sequence of unsigned bytes taken up by the 
  object and a <i>value representation</i> which is the set of bits in the 
  object representation that determines the <i>value</i> of the object (3.9/4). 
  The standard loosely defines a <b>value</b> as <u>an 
  implementation-defined discrete element of a set of values</u>, and an <b>object</b>
  <b>type</b> (39.9/9) as <u>a name that specifies such a value set and the valid 
  operations on it</u>. A <b>variable</b> is an <i>entity</i> (3.3) introduced 
  by the <i>declaration</i> of an object and it's name denotes the object (3.4). 
  In the standard text,&nbsp; variable and object are interchangeable terms 
  (though in theory a variable can be considered to hold an object).</p>
  <p><font face="Times New Roman">Objects are created (3.1,5.3.4,12.2) </font>, 
  but unlike other languages, the value of an object is not always given 
  automatically by the implementation. Various <i>initialization</i> rules 
  determine-based on the <i>storage duration</i>, the <i>type</i>, and the 
  presence or absence of an <i>intializer-</i> if and how objects and subobjects 
  are initialized; that is, are given an initial value 
  (3.6.2,8.5,12.1,12.6,12.8). Since these rules are based on lexical properties 
  of a program, the property of an object of being fully or partially 
  initialized (or not) is static, not dynamic, and is independent of any object 
  or value representation used by the implementation in the cases when, for 
  instance, there is no initializer. That is, <u>the <b>static initialization 
  state</b> of an object or variable is determined by its <i>definition</i> and 
  is independent of the actual (possibly garbage) value of the object</u>. 
  Consequently, 
  objects are (statically) <b>initialized</b> or <b>uninitialized</b> based on 
  how they are created regardless of any initial value, well defined or 
  indeterminate.<br>
&nbsp;[1. this definition of a static initialization state is important because 
  the general concept of a <i>uninitialized variable</i> is often debated as not 
  being well defined because the concept is sometimes defined in terms of the 
  initial value given by the language implementation to variables defined without 
  initializers]</p>
  <p>Ultimately, a program carries on a computation and a computation is a 
  transformation of values; they are <i>produced</i> and <i>consumed.</i></p>
  <p>From the point of view of the producer, a value can be <b>unset:</b> 
  purposely set to 0 or any other special value with that meaning; or <b>
  incomputable:</b> dependable on other values which are invalid, 
  missing, corrupted, etc. A NULL passed as the argument to filebuf::setuf() is 
  an example of&nbsp;an unset value, while the square root of a negative 
  number, the area of an open figure, the result of dereferencing a past the end 
  iterator, the next char in an exhausted stream and a field from an unreachable 
  remote database are examples of incomputable values.</p>
  <p>From the point of view of the consumer, a value can be <b>invalid</b> or <b>
  missing</b>. A 0 divisor and an out of range index are examples of invalid 
  values and a value considered incomputable from the producer point of view 
  is missing from the consumer point of view.</p>
  <p>An unset or incomputable value such that a particular consumer can 
  unequivocally interpret as missing is called <b>absent</b>. Absent values are 
  distinctive values whose only purpose is to express in a testable way the 
  fact that a conceptual value is really unset or incomputable.&nbsp; </p>
  <p>In software design, <i>absent</i> values are fundamentally important: If a 
  requested value is incomputable because of an invalid value being used in the 
  request, such as a zero divisor or a negative argument to sqrt(), it is common 
  and reasonable to allow the producer to just fail because the consumer can 
  detect by itself that the request is invalid. However, when the requested 
  value is unset or incomputable for reasons not directly related to the input 
  values used in a request, like when requesting for the field of an unreachable 
  database or the next char in an empty stream, or a point guaranteed to be 
  inside a degenerate figure whose area is 0, it is impractical and unnecessary 
  to allow the producer to fail requiring the consumer to always check first or 
  afterwards (for a solid design). A much more effective and safer technique is 
  to use <b>absent</b> values. </p>
  <p>A<b> </b>type which one way or another is capable of distinctively 
  expressing an absent value is called <b>optional</b> or <b>nullable</b>. C/C++ 
  pointers for example are nullable types.</p>
  <h3>B. Current ad-hoc techniques for expressing absent values</h3>
  <p>In C++, it is simply impractical to formally define as <i>absent</i> all 
  <i>uninitialized</i> objects  because not every type in the system includes a 
  special null value; only pointers do that. Consequently, <i>absent</i> values are 
  traditionally expressed in C++ in one of 3 ways: </p>
  <ol>
    <li>Using ad-hoc special values, like EOF.</li>
    <li>Using ad-hoc additional flags, like pair&lt;T,bool&gt;.</li>
    <li>Using pointers  even if the object would have been passed or returned 
    by-value if it wouldn't be possibly absent.</li>
  </ol>
  <p>Techniques (1) and (2) suffer from two important problems:</p>
  <ul>
    <li>Lack of uniformity. </li>
    <li>Lack of idioms and mechanisms to diagnose or prevent observing the state 
    of absent values.</li>
  </ul>
  <p>Technique (3), OTOH, uses a <i>null pointer value</i> (4.10) and so it 
  solves the two problems mentioned before: is uniform because users can 
  unequivocally test if the value is indeed absent and being formally undefined 
  behavior 
  to access an object pointed to by a null pointer, an implementation if free to incorporate into the program 
  mechanisms to diagnose or handle (in any particular way) such violations. However, using pointers to represent 
  absent values has many 
  limitations:</p>
  <ul>
    <li>Objects with automatic storage duration cannot be returned via a 
    pointer.</li>
    <li>A <i>null pointer value </i>cannot be used as an absent value marker in 
    non-pointer member subobjets.</li>
    <li>Is illegal to create a pointer to a reference, so absent references 
    cannot be represented via pointers. </li>
  </ul>
  <p>The following paper proposes a library solution to the problem of 
  effectively representing absent values of <i>any</i> type: the template class 
  optional&lt;T&gt;. This rather simple class contains within its own storage any 
  object and keeps explicit track of its initialization state. A C++ program can 
  use a default-constructed instance of optional&lt;T&gt; to represent an absent value 
  of type T. Unlike a pointer, optional&lt;T&gt; can be used to return local objects 
  and in non-pointer member subobjects so it can represent absent values of any 
  type (like pointers) but also in any context.</p>
  <p>The proposed solution is simple to understand, simple to use and it allows 
  a program to much better express the presence of absent values and its role 
  in the program design. It even encourages the usage of absent values. Therefore, the proposed addition is targeted to all C++ 
  programmers of all levels and for all types of programs.</p>
  <p>Explicit support for absent values is common in other languages: In <i>Haskell</i>, for 
  example, the <i>Maybe</i> built-in constructor logically extends a type adding 
  '<i>Nothing</i>' to it which allows a haskell program to represent absent 
  values of any type. In<i> </i>most purely object-oriented or scripting 
  languages, <i>uninitialized variables</i> (even of built-in type) are automatically 
  initialized with a <i>distinctive</i> 
  value:&nbsp; <i>undef</i> in Perl, <i>None </i>in Phyton<i>, nil</i> in 
  Smalltalk, <i>Void</i> in Effiel, <i>Null</i> in Java, etc...so programs 
  written in these languages can uniquely express absent values through 
  uninitialized variables; and recently, <i>nullable value types</i> were introduced 
  into NET 2.0 were uninitialized variables of a nullable types are 
  automatically initialized with <i>null</i> (with direct language 
  support for it). </p>
  <p>The <a href="http://www.boost.org/libs/optional/doc/optional.html">Boost.Optional</a> library is a reference implementation 
  (with some added functionality not included in this proposal) that was 
  introduced in boost 1.30.0, around March 2003, and which has been widely accepted, used and 
  even occasionally recommended ever since.</p>
  <h1><i><b>Impact On the Standard</b></i></h1>
  <p>This is purely an extension which only adds an utility class to the 
  library.</p>
  <h1><b><i>Design Decisions</i></b></h1>
  <p>Value wrappers explicitly tracking the initialization state for the very 
  purpose of representing absent values have been invented over and over, both 
  publicly and privately. Perhaps the first published such wrapper for C++ is 
  the Fallible&lt;&gt; type in &quot;Scientific and Engineering C++, by Barton and 
  Nackman&quot;.</p>
  <p>These wrappers all share in common the fact that they contain values in 
  their own storage allowing local absent values to be returned and non-pointer 
  absent member subobjects to be represented.</p>
  <p>The class proposed for standardization in this paper, however, has been 
  designed with the following unique added goals in mind:</p>
  <ol>
    <li>It shall permit the representation of absent values of class type with 
    no default constructor.</li>
    <li>It shall permit the representation of absent values of reference type.</li>
    <li>It shall benefit from the traditional and well-established idioms that 
    have been used to represent absent objects, thus helping the programmer avoid making 
    mistakes arising from the fact that the value is possibly absent and 
    accessing it is undefined behavior.</li>
  </ol>
  <p>Goals 1 and 2 are usability features which have been shown to be radically 
  important during the early stages of the development of the Boost 
  implementation. These features require template metaprogramming techniques 
  and/or compiler magic but the Boost implementation proved this to be entirely 
  possible in a large base of current compilers (the Boost version for example 
  works in all the compilers supported by the Boost project)</p>
  <p>Goal 2 conduced to a design decision which was largely debated on the Boost 
  forums:</p>
  <p>Optional references <i>rebind</i> when assigned, that is:</p>
  <pre>	int  a = 123 ;
	int&amp; ra = a ; // ra is bound to a
	optional&lt;int&amp;&gt; ora = ra ; // ora is bound to a 
        int b = 456 ;
	int&amp; rb = b ;
	ora = rb ; // ora is re-bound to rb. </pre>
  <p>This is in sharp contrast with normal C++ references.</p>
  <p>This decision was made to allow the definition of assignment to be 
  independent of the prior initialization state of the lvalue. If the lvalue 
  optional reference is uninitialized before the assignment there is no choice 
  but to rebind.</p>
  <pre>	int  a = 123 ;
	int&amp; ra = a ; // ra is bound to a
	optional&lt;int&amp;&gt; ora = ra ; // ora is bound to a 
        int b = 456 ;
	int&amp; rb = b ;
	ora = nullptr ; // explicitly reset to uninitialized to make the point even more clear.
	ora = rb ; // ora MUST bind to rb, there is no choice here. </pre>
  <p>Assignment to an initialized optional reference could be made to assign the 
  referenced value, following the behavior of normal C++ references, but then 
  the semantics of assignment would depend on the prior initialization state of 
  the lvalue. The decision, albeit arbitrary, is to rebind. </p>
  <p>Goal 3 conduced to another design decision which was also largely debated 
  on the Boost forums:</p>
  <p>Access to the contained value is only supported via operators * and -&gt;</p>
  <p>The reason for this interface design is that pointers and a null pointer 
  value have been used to represent absent objects from the very first days of 
  C. This technique is so extensively used that the expressions used to access 
  the pointed object, (*p) and p-&gt;, have an extraordinary power at expressing 
  optionally: all by themselves, from syntax alone, they make loudly clear that the 
  value being accessed might be absent.</p>
  <p>On the other hand, a T* (or a wrapper of it) and an optional&lt;T&gt; are 
  different in nature as the former <i>points to an external object</i> while 
  the later <i>contains an internal object</i>.</p>
  <p>In the boost forums it has been argued that users can (and will) confuse 
  optional&lt;T&gt; as a form of wrapper for T*. That is quite possible yet the 
  confusion is harmless: it turns out that any valid expression for a wrapper of 
  T* (say shared_ptr&lt;T&gt;) which is also valid for optional&lt;T&gt; happens the have 
  the same semantics, with the only exception of copying optional&lt;T&gt; or 
  smart_ptr&lt;T&gt; objects which in the former is a deep copy and in the later a 
  shallow copy.</p>
  <p>In other words, these expressions:</p>
  <pre>p-&gt;fmember();
p-&gt;datamember ;
(*p).fmember();
(*p).datamember ;
T lvalue = *p ;
if ( p ) ...
</pre>
  <p>have the same semantics whether p is optional&lt;T&gt; or smart_ptr&lt;T&gt;.</p>
  <p>Assignment of values to an optional&lt;T&gt; object is an operation that doesn't depend on 
  the prior value being absent or not. In fact, it shall succeed even if the 
  lvalue optional&lt;T&gt; was uninitialized before the assignment. For that reason, 
  value assignment of an optional is directly supported via the assignment operator. That 
  is:</p>
  <pre>optional&lt;int&gt; o = 1; 
o = 2 ; // direct-assignment of the vale
*o = 3 ; // indirect-assignment of the value, OK here because 'o' is uninitialized
o = nullptr ; // explicit de-initialization
*o = 5 ; // ERROR, undefined behavior because *o is absent
o = 6 ; // OK. direct-initialization is always well-defined
</pre>
  <h1><b><i>Proposed Text for the Standard</i></b></h1>
  <p>A. Add &lt;optional&gt; to Table 11 in 17.4.1.2/1</p>
  <p>B. Change Table 27 in 20.0 adding the row:</p>
  <font FACE="NimbusRomNo9L-Regu" SIZE="2" COLOR="#0000ff">
  <p ALIGN="LEFT">&nbsp;&nbsp;&nbsp; 20.6&nbsp;&nbsp;&nbsp; </font>
  <font face="NimbusRomNo9L-Regu" size="2">Optional types&nbsp;&nbsp;&nbsp; &lt;optional&gt;</font></p>
  <p>C. Add the following subclauses to clause 20</p>
  <h4>20.6 Optional objects&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  [lib.optional.synopsis]</h4>
  <p>1.Header &lt;optional&gt; synopsis</p>
  <pre>namespace std {

template&lt;class T&gt; class optional ;

template&lt;class T&gt; inline bool operator == ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y ) ;

template&lt;class T&gt; inline bool operator != ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y ) ;

template&lt;class T&gt; inline bool operator &lt;  ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y ) ;

template&lt;class T&gt; inline bool operator &gt;  ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y ) ;

template&lt;class T&gt; inline bool operator &lt;= ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y ) ;

template&lt;class T&gt; inline bool operator &gt;= ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y ) ;

template&lt;class T&gt; inline bool operator == ( optional&lt;T&gt; const&amp; x, decltype(nullptr) y ) ;

template&lt;class T&gt; inline bool operator != ( optional&lt;T&gt; const&amp; x, decltype(nullptr) y ) ;

template&lt;class T&gt; inline bool operator == ( decltype(nullptr) x, optional&lt;T&gt; const&amp; y ) ;

template&lt;class T&gt; inline bool operator != ( decltype(nullptr) x, optional&lt;T&gt; const&amp; y ) ;

template&lt;class T&gt; inline T const&amp; get ( optional&lt;T&gt; const&amp; opt ) ;

template&lt;class T&gt; inline T&amp;       get ( optional&lt;T&gt; &amp; opt ) ;

template&lt;class T&gt; inline T const* get ( optional&lt;T&gt; const* opt ) ;

template&lt;class T&gt; inline T*       get ( optional&lt;T&gt;* opt ) ;

template&lt;class T&gt; inline T const* get_pointer ( optional&lt;T&gt; const&amp; opt ) ;

template&lt;class T&gt; inline T*       get_pointer ( optional&lt;T&gt; &amp; opt ) ;

template&lt;class T&gt; inline void swap( optional&lt;T&gt;&amp; x, optional&lt;T&gt;&amp; y ) ;

} // namespace std
</pre>
  <h4>20.6.1 Explicit initialization state&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  [lib.optional.state]</h4>
  <p>1.An instance of <code>optional&lt;T&gt;</code> is said to be <b>uninitialized</b> if it has 
  been default constructed, assigned <code>nullptr</code><sup><a href="#footnote1" style="text-decoration: none">1</a></sup>, 
  copy-constructed from or assigned with an uninitialized <code>optional&lt;U&gt;</code> instance 
  (with U equal or not to T).</p>
  <p>2.An instance of <code>optional&lt;T&gt;</code> is said to be <b>initialized</b> if it has 
  been constructed with any value of type T, assigned a value of type T, copy-constructed from or assigned with an initialized
  <code>optional&lt;U&gt;</code> instance (with U equal  or not to T).</p>
  <p>3.Instances of <code>optional&lt;T&gt;</code> shall explicitly track whether they are 
  initialized or not, though the mechanism for doing this is unspecified<a href="#footnote2" style="text-decoration: none"><sup>2</sup></a>.</p>
  <h4>20.6.2 Contained value&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  [lib.optional.value]</h4>
  <p><i>Initialized</i> instances of <code>optional&lt;T&gt;</code> shall store a value of type T <i>
  within its own storage</i>. This value is referred to as the<b> contained value
  </b>of the <code>optional&lt;T&gt;</code> instance. Implementations are not permitted to use 
  additional storage, such as dynamic memory, to allocate its contained value. 
  As required by the language, the contained value must be allocated in a region 
  of the <code>optional&lt;T&gt;</code> storage suitably aligned for the type T. The mechanism used 
  to allocate the contained value is unspecified<a href="#footnote3" style="text-decoration: none"><sup>3</sup></a>. Whether an 
  <i>uninitialized</i> 
  <code>optional&lt;T&gt;</code> must store some form of contained value and how at that is also 
  unspecified.</p>
  <p>If T is of reference type, an implementation is free to store a value of a 
  type other than T (such as a reference wrapper<a href="#footnote4" style="text-decoration: none"><sup>4</sup></a>) provided any operation 
  on the <i>contained value</i> behaves as if it were of type T.</p>
  <h4>20.6.3 Class template optional				[lib.optional]</h4>
  <pre>namespace std {

template&lt;class T&gt;
class optional
{
  public :

    optional () ;

    optional ( decltype(nullptr)<sup><a href="#footnote1" style="text-decoration: none">1</a></sup> ) ;

    optional ( T const&amp; v ) ;

    optional ( optional const&amp; rhs ) ;

    template&lt;class U&gt; explicit optional ( optional&lt;U&gt; const&amp; rhs ) ;

    optional&amp; operator = ( decltype(nullptr) ) ;</pre>
  <pre>    optional&amp; operator = ( T const&amp; v ) ;

    optional&amp; operator = ( optional const&amp; rhs ) ;

    template&lt;class U&gt; optional&amp; operator = ( optional&lt;U&gt; const&amp; rhs ) ;

    T const* operator -&gt;() const ;
    T*       operator -&gt;() ;

    T const&amp; operator *() const ;
    T&amp;       operator *() ;

    operator <i>unspecified-bool-type</i>() const ;

    bool operator!() const ;

} ;

} // namespace std
</pre>
  <h4>20.6.3.1 Constructors&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  [lib.optional.ctor]</h4>
  <pre>optional&lt;T&gt;::optional();</pre>
  <blockquote>
    <p><i>Effects:</i> Default-Constructs an <b>optional</b>.</p>
    <p><i>Postconditions:</i> <b>*this</b> is <i>uninitialized</i></p>
    <p><i>Remarks:</i> T's default constructor <u><i>is not</i></u> called.</p>
  </blockquote>
  <pre>optional&lt;T&gt;::optional( delctype(nullptr)<sup><a href="#footnote1" style="text-decoration: none">1</a></sup> const&amp; v )</pre>
  <blockquote>
    <p><i>Effects:</i> Directly-constructs an <i>uninitialized</i><b> optional </b>.</p>
    <!-- TemplateName: general/sy_footer_inc.isml -->
    <p><i>Postconditions:</i> <b>*this</b> is <i>uninitialized</i>.</p>
    <p><i>Remarks:</i> T's default constructor <u><i>is not</i></u> called.</p>
  </blockquote>
  <pre>optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt;::optional( T const&amp; v )			</pre>
  <blockquote>
    <p><i>Effects:</i> Directly-Constructs an <b>optional</b>.</p>
    <!-- TemplateName: general/sy_footer_inc.isml -->
    <p><i>Postconditions:</i> <b>*this</b> is <i>initialized</i> and its
    <i>contained value</i> is a <i>copy</i> of 'v'.</p>
    <p><i>Throws:</i> Whatever T::T( T const&amp; ) throws.</p>
    <p><i>Remarks</i><b>: </b>T::T( T const&amp; ) is called to define the <i>contained value</i>.</p>
    <p><b>Exception Safety:</b> Exceptions can only be thrown during T::T( T 
    const&amp; ); in that case, this constructor has no effect. </p>
  </blockquote>
  <pre>optional&lt;T&amp;<a href="#footnote6" style="text-decoration: none"><sup>6</sup></a>&gt;::optional( T&amp; ref )				</pre>
  <blockquote>
    <p><i>Effects:</i> Directly-Constructs an <b>optional</b>.</p>
    <p><i>Postconditions:</i> <b>*this</b> is <i>initialized</i> and its <i>
    contained value</i> is another reference to the same object referenced by <b>
    ref</b>.</p>
    <p><i>Remarks:</i> both the <i>contained value</i> and <b>ref</b> shall refer to the same object<b> </b>(alias).</p>
  </blockquote>
  <pre>optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt;::optional( optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt; const&amp; rhs );	</pre>
  <blockquote>
    <p><i>Effects:</i> Copy-Constructs an <b>optional</b>.</p>
    <p><i>Postconditions:</i> If <b>rhs</b> is <i>initialized</i>, <b>*this</b> is 
    <i>initialized</i> and its <i>contained value</i> is a <i>copy</i> of the <i>
    contained value</i> of <b>rhs</b>; else
    <b>*this</b> is <i>uninitialized</i>.</p>
    <p><i>Throws:</i> Whatever T::T( T const&amp; ) throws.</p>
    <p><i>Remarks:</i> If <b>rhs</b> is <i>initialized</i>, T::T(T const&amp; ) is 
    called to define the contained value..</p>
    <p><b>Exception Safety:</b> Exceptions can only be thrown during T::T( T 
    const&amp; ); in that case, this constructor has no effect. </p>
  </blockquote>
  <pre>optional&lt;T&amp;<a href="#footnote6" style="text-decoration: none"><sup>6</sup></a>&gt;::optional( optional&lt;T&amp;<a href="#footnote6" style="text-decoration: none"><sup>6</sup></a>&gt; const&amp; rhs );			</pre>
  <blockquote>
    <p><i>Effects:</i> Copy-Constructs an <b>optional</b>.</p>
    <p><i>Postconditions:</i> If <b>rhs</b> is <i>initialized</i>, <b>*this</b> is 
    <i>initialized</i> and its <i>contained</i> <i>value</i> is another 
    reference to the same object referenced by the <i>contained value</i> of <b>*rhs</b>; else <b>*this</b> is 
    <i>uninitialized</i>.</p>
    <p><i>Remarks:</i> If <b>*this</b> is initialized, the <i>contained values</i> 
    of both <b>*this</b> and <b>rhs</b> shall refer to the same object<b> </b>(they alias).</p>
  </blockquote>
  <pre> template&lt;U<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt; explicit optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt;::optional( optional&lt;U<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt; const&amp; rhs ); 	</pre>
  <blockquote>
    <p><i>Effects:</i> Copy-Constructs an <b>optional</b>.</p>
    <p><i>Postconditions:</i> If <b>rhs</b> is <i>initialized</i>, <b>*this</b> is 
    <i>initialized</i> and its <i>contained value</i> is a <i>copy</i> of the <i>
    contained value</i> of <b>rhs</b> <i>
    converted</i> to type T; else <b>*this</b> is <i>uninitialized</i>. </p>
    <p><i>Throws:</i> Whatever T::T( U const&amp; ) throws.</p>
    <p><i>Remarks:</i> T::T( U const&amp; ) is called to define the contained 
    value if <b>rhs</b> is initialized. If there is not conversion from U to T 
    the program is ill-formed. </p>
    <p><b>Exception Safety:</b> Exceptions can only be thrown during T::T( U 
    const&amp; ); in that case, this constructor has no effect. </p>
    <p>&nbsp;</p>
  </blockquote>
  <h4>20.6.3.2 Assignment&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  [lib.optional.assign]</h4>
  <pre>optional&lt;T&gt;&amp; optional&lt;T&gt;::operator= ( decltype(nullptr) null ) ;			</pre>
  <blockquote>
    <p><i>Effects:</i> Resets the <b>optional</b> to uninitialized state</p>
    <p><i>Postconditions:</i> <b>*this</b> is <i>uninitialized</i><b>.</b></p>
    <p><i>Remarks:</i> If <b>*this</b> was <i>initialized</i>, T::~T() is 
    called to destroy the contained value.</p>
  </blockquote>
  <pre>optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt;&amp; optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt;::operator= ( T const&amp; rhs ) ;			</pre>
  <blockquote>
    <p><i>Effects:</i> Assigns the value 'rhs' to an <b>optional</b>.</p>
    <p><i>Postconditions:</i> <b>*this</b> is <i>initialized</i> and its <i>
    contained</i> <i>value</i> is a <i>
    copy</i> of <b>rhs.</b></p>
    <p><i>Throws:</i> Whatever T::operator=( T const&amp; ) or T::T(T const&amp;) 
    throws.</p>
    <p><i>Remarks:</i> If <b>*this</b> was <i>initialized</i>, T::operator=( T 
    const&amp; ) is 
    used to define the contained value, otherwise, T::T(T const&amp;) is used for 
    that.</p>
    <p><b>Exception Safety:</b> In the event of an exception, the initialization 
    state of <b>*this</b> is unchanged and its <i>contained value</i> undefined (it is up to T's operator=()) [If <b>*this</b> is 
    initially <i>uninitialized</i> and T's <i>copy constructor</i> throws, <b>*this</b> 
    is left properly <i>uninitialized</i>]</p>
  </blockquote>
  <pre>optional&lt;T&amp;<a href="#footnote6" style="text-decoration: none"><sup>6</sup></a>&gt;&amp; optional&lt;T&amp;<a href="#footnote6" style="text-decoration: none"><sup>6</sup></a>&gt;::operator= ( T&amp; const&amp; rhs ) ;			</pre>
  <blockquote>
    <p><i>Effects:</i> (Re)binds the wrapped reference.</p>
    <p><i>Postconditions:</i> <b>*this</b> is <i>initialized</i> and its 
    contained value references the 
    same object referenced by <b>rhs.</b></p>
    <p><i>Remarks:</i> If <b>*this</b> was initialized, is is <i>rebound</i> to 
    the new object. See <a href="#rebindref">20.6.1.4</a> for details.</p>
  </blockquote>
  <pre>optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt;&amp; optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt;::operator= ( optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt; const&amp; rhs ) ;			</pre>
  <blockquote>
    <p><i>Effects:</i> Assigns another <b>optional</b> to an <b>optional</b>.</p>
    <p><i>Postconditions:</i> If <b>rhs</b> is <i>initialized</i>, <b>*this</b> is 
    <i>initialized</i> and its <i>contained value</i> is a <i>copy</i> of the <i>
    contained value</i> of <b>rhs</b>; else
    <b>*this</b> is <i>uninitialized</i>. </p>
    <p><i>Throws:</i> Whatever T::operator( T const&amp;) or&nbsp; T::T( T const&amp; ) 
    throws.</p>
    <p><i>Remarks:</i> In order to define the <i>contained value</i>: if both<b> *this</b> and <b>rhs</b> are initially 
    <i>initialized</i>, T's <i>assignment</i> <i>operator</i> is used. If <b>*this</b> 
    is initially <i>initialized</i> but <b>rhs</b> is <i>uninitialized</i>, T's <i>destructor</i> 
    is called. If <b>*this</b> is initially <i>uninitialized</i> but rhs is 
    <i>initialized</i>, T's <i>copy constructor</i> is called. </p>
    <p><b>Exception Safety:</b> In the event of an exception, the initialization 
    state of <b>*this</b> is unchanged and the <i>contained value</i> undefined (it is up to T's operator=()) [If <b>*this</b> is 
    initially <i>uninitialized</i> and T's <i>copy constructor</i> throws, <b>*this</b> 
    is left properly <i>uninitialized</i>]</p>
  </blockquote>
  <pre>optional&lt;T&amp;<a href="#footnote6" style="text-decoration: none"><sup>6</sup></a>&gt; &amp; optional&lt;T&amp;<a href="#footnote6" style="text-decoration: none"><sup>6</sup></a>&gt;::operator= ( optional&lt;T&amp;<a href="#footnote6" style="text-decoration: none"><sup>6</sup></a>&gt; const&amp; rhs ) ;		</pre>
  <blockquote>
    <p><i>Effects:</i> (Re)binds the wrapped reference.</p>
    <p><i>Postconditions:</i> If <b>*rhs</b> is <i>initialized</i>, *<b>this</b> is 
    <i>initialized</i> and its contained value references the same object referenced by <b>*rhs</b>; 
    otherwise, <b>*this</b> is <i>uninitialized</i> (and references no object).</p>
    <p><i>Remarks:</i> If <b>*this</b> was <i>initialized</i> and so is <b>*rhs</b>, <b>
    this</b> is <i>rebound</i> to the new object. See <a href="#rebindref">20.6.1.4</a> for details.</p>
  </blockquote>
  <pre>template&lt;U<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt; optional&amp; optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt;::operator= ( optional&lt;U<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt; const&amp; rhs ) ;		</pre>
  <blockquote>
    <p><i>Effects:</i> Assigns another <i>convertible</i> <b>optional</b> to an
    <b>optional</b>.</p>
    <p><i>Postconditions:</i> If <b>rhs</b> is <i>initialized</i>, <b>*this</b> is 
    <i>initialized</i> and its <i>contained value</i> is a <i>copy</i> of the <i>
    contained value</i> of <b>rhs</b> <i>
    converted</i> to type T; else <b>*this</b> is <i>uninitialized</i>. </p>
    <p><i>Throws:</i> Whatever T::operator=( U const&amp; ) or T::T( U const&amp; ) 
    throws.</p>
    <p><i>Remarks:</i> In order to define the contained value: if both<b> *this</b> and <b>rhs</b> are initially 
    <i>initialized</i>, T's <i>assignment</i> <i>operator</i> (from U) is used. If <b>
    *this</b> is initially <i>initialized</i> but <b>rhs</b> is <i>uninitialized</i>, T's <i>
    destructor</i> is called. If <b>*this</b> is initially <i>uninitialized</i> but rhs 
    is <i>initialized</i>, T's <i>converting constructor</i> (from U) is called. </p>
    <p><b>Exception Safety:</b> In the event of an exception, the initialization 
    state of <b>*this</b> is unchanged and its contained value undefined (it is up to T's operator=()) [If <b>*this</b> is 
    initially uninitialized and T's <i>converting constructor</i> fails, <b>
    *this</b> is left properly uninitialized]</p>
    <p>&nbsp;</p>
  </blockquote>
  <h4>20.6.3.3 Observers&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  [lib.optional.observers]</h4>
  <pre>T const&amp; optional&lt;T&gt;::operator*() const ;
T&amp;       optional&lt;T&gt;::operator*();		</pre>
  <pre>T const&amp; get ( optional&lt;T&gt; const&amp; ) ;
T&amp;       get ( optional&lt;T&gt; &amp;) ;</pre>
  <blockquote>
    <p><b>Requirements: *this</b> is <i>initialized</i></p>
    <p><i>Returns:</i> A reference to the <i>contained value.</i></p>
  </blockquote>
  <pre>T const* get ( optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt; const* ) ;
T*       get ( optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt; *) ;</pre>
  <pre>T const* get_pointer ( optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt; const&amp; ) ;
T*       get_pointer ( optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt; &amp;) ;</pre>
  <blockquote>
    <p><i>Returns:</i> If <b>*this</b> is <i>initialized</i>, a pointer to the 
    <i>contained value</i>; otherwise NULL. </p>
    <p><i>Remarks:</i> Accessing the returned pointer (which points <i>into</i> 
    the optional&lt;T&gt;) after the optional&lt;T&gt; has been destroyed or assigned 
    nullptr; or deleting it, is undefined behavior.</p>
  </blockquote>
  <pre>T const* optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt;::operator -&gt;() const ;
T*       optional&lt;T<a href="#footnote5" style="text-decoration: none"><sup>5</sup></a>&gt;::operator -&gt;()       ;</pre>
  <blockquote>
    <p><b>Requirements: *this</b> is <i>initialized</i>.</p>
    <p><i>Returns:</i> A pointer to the <i>contained value</i>.</p>
    <p><i>Remarks:</i> Accessing the returned pointer (which points <i>into</i> 
    the optional&lt;T&gt;) after the optional&lt;T&gt; has been destroyed or assigned 
    nullptr; or deleting it, is undefined behavior.</p>
  </blockquote>
  <pre>optional&lt;T&gt;::operator <i>unspecified-type</i>() const ;</pre>
  <blockquote>
    <p><i>Returns:</i> A value of an unspecified type which if used on a boolean context 
    is equivalent to (get(this) != 0)</p>
  </blockquote>
  <pre> bool optional&lt;T&gt;::operator!() ;</pre>
  <blockquote>
    <p><i>Returns:</i> If <b>*this</b> is <i>uninitialized</i>, <code>true</code>; else
    <code>false.</code></p>
  </blockquote>
  <h4>20.6.3.4 Relational operators&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  [lib.optional.relops]</h4>
  <pre>bool operator == ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y );</pre>
  <blockquote>
    <p><i>Returns:</i> If both <b>x</b> and <b>y</b> are <i>initialized</i>, <code>(*x 
    == *y)</code>. If only x or y is <i>initialized</i>, <code>false</code>. If both 
    are <i>uninitialized</i>, <code>true</code>. </p>
  </blockquote>
  <pre>bool operator &lt; ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y );</pre>
  <blockquote>
    <p><i>Returns:</i> If <b>y</b> is not <i>initialized</i>, <code>false</code>. If <b>
    y</b> is <i>initialized</i> and <b>x</b> is not <i>initialized</i>, <code>true</code>. If 
    both <b>x</b> and <b>y</b> are <i>initialized</i>, <code>(*x &lt; *y)</code>. </p>
  </blockquote>
  <pre>bool operator != ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y );
</pre>
  <blockquote>
    <p><i>Returns:</i> !( x == y );</p>
  </blockquote>
  <pre>bool operator &gt; ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y );
</pre>
  <blockquote>
    <p><i>Returns:</i> ( y &lt; x );</p>
  </blockquote>
  <pre>bool operator &lt;= ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y );
</pre>
  <blockquote>
    <p><i>Returns:</i> !( y&lt;x );</p>
  </blockquote>
  <pre>bool operator &gt;= ( optional&lt;T&gt; const&amp; x, optional&lt;T&gt; const&amp; y );
</pre>
  <blockquote>
    <p><i>Returns:</i> !( x&lt;y );</p>
  </blockquote>
  <pre>bool operator == ( optional&lt;T&gt; const&amp; x, decltype(nullptr) null );
bool operator == ( decltype(nullptr) null, optional&lt;T&gt; const&amp; x );</pre>
  <blockquote>
    <p><i>Returns:</i> true if x is <i>uninitialized</i>, false otherwise. </p>
  </blockquote>
  <pre>bool operator != ( optional&lt;T&gt; const&amp; x, decltype(nullptr) null );
bool operator != ( decltype(nullptr) null, optional&lt;T&gt; const&amp; x );</pre>
  <blockquote>
    <p><i>Returns:</i> true if x is not<i> uninitialized</i>, false otherwise. </p>
  </blockquote>
  <h4>20.6.3.5 Swap&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  [lib.optional.swap]</h4>
  <pre>void swap ( optional&lt;T&gt;&amp; x, optional&lt;T&gt;&amp; y );</pre>
  <blockquote>
    <p><i>Effects:</i> If both <b>x</b> and <b>y</b> are <i>initialized</i>, calls <code>
    swap(*x,*y)</code><a href="#footnote1" style="text-decoration: none"><sup>1</sup></a><br>
    If only one is <i>initialized</i>, say x, calls: <code>y = x; x = nullptr;</code><br>
    If none is <i>initialized</i>, does nothing. </p>
    <p><i>Postconditions:</i> The states of x and y interchanged.</p>
    <p><i>Throws:</i> If both are <i>initialized</i>, whatever swap(T&amp;,T&amp;) throws. If 
    only one is <i>initialized</i>, whatever T::T ( T const&amp; ) throws. </p>
    <p><i>Remarks:</i>
    If only one is <i>initialized</i>, T::~T() and T::T( T const&amp; ) are called 
    to defined the corresponding contained values. </p>
    <p><b>Exception Safety:</b> If both are <i>initialized</i>, this operation has the 
    exception safety guarantees of swap(T&amp;,T&amp;).<br>
    If only one is <i>initialized</i>, it has the same <b>basic</b> guarantee as 
    optional&lt;T&gt;::operator=( optional&lt;T&gt; const&amp; ). </p>
  </blockquote>
  <p><u>Footnotes: </u></p>
  <ol>
    <a name="footnote1"></a><li><i>decltype(nullptr) and nullptr refers to the special null 
    pointer value proposed in N1488</i></li>
    <a name="footnote2"></a><li><i>for example, an implementation can use a bool 
    data member</i></li>
    <a name="footnote3"></a><li><i>implementations can use any of the published 
    aligned storage techniques, or use align_as&lt;&gt; from N1546 if available.</i><a name="footnote4"></a><li><i>
    such as the 
    reference_wrapper&lt;&gt; proposed in N1453</i><a name="footnote5"></a><li><i>
    The semantics specified here correspond only to the case of T not being of 
    reference type.</i></li><li><i>The semantics specified here correspond only 
    to the case of T being of reference type.</i></li>
  </ol>
  <h1><b><i>Acknowledgements</i></b></h1>
  <p>All the people in the boost community, particularly those involved in the 
  development of the Boost.<span lang="es">Optional</span> library.</p>
  <h1><b><i>References</i></b></h1>

  <ol>
    <li>Scientific and Engineering C++: An Introduction with Advanced Techniques 
    and Examples, Barton and Nackman, Addison Wesley Professional</li>
    <li>Boost.Optional library, 
  <a href="http://www.boost.org/libs/numeric/conversion/doc/index.html">http://www.boost.org/libs/optional/doc/index.html</a>, Fernando Cacciola</li>
    <li>The Meaning of Nothing, <a href="http://www.chimu.com/publications/short/stNil.html">http://www.chimu.com/publications/short/stNil.html</a>, 
    Mark Fussel, (C) ChiMu Corporation.</li>
    <li>C# Nullable types, <a href="http://msdn.microsoft.com/vcsharp/2005/overview/language/nullabletypes/">
    http://msdn.microsoft.com/vcsharp/2005/overview/language/nullabletypes</a>, 
    MSDN, Microsoft (R) Visual C# (R) Developer Center</li>
  </ol>

  <p>&nbsp;</p>

</body>

</html>