2007-05-29 06:40:25 +00:00
< html >
< head >
2011-04-06 20:54:18 +00:00
< meta http-equiv = "Content-Type" content = "text/html; charset=US-ASCII" >
< title > Chapter  1.  Boost.Optional< / title >
2014-04-12 20:54:37 +02:00
< link rel = "stylesheet" href = "../../../../doc/src/boostbook.css" type = "text/css" >
< meta name = "generator" content = "DocBook XSL Stylesheets V1.78.1" >
2011-04-06 20:54:18 +00:00
< link rel = "home" href = "index.html" title = "Chapter 1. Boost.Optional" >
2014-05-07 17:07:12 +02:00
< link rel = "next" href = "boost_optional/motivation.html" title = "Motivation" >
2007-05-29 06:40:25 +00:00
< / head >
< body bgcolor = "white" text = "black" link = "#0000FF" vlink = "#840084" alink = "#0000FF" >
2008-02-14 17:43:52 +00:00
< table cellpadding = "2" width = "100%" > < tr >
< td valign = "top" > < img alt = "Boost C++ Libraries" width = "277" height = "86" src = "../../../../boost.png" > < / td >
2009-02-12 14:01:48 +00:00
< td align = "center" > < a href = "../../../../index.html" > Home< / a > < / td >
2011-04-06 20:54:18 +00:00
< td align = "center" > < a href = "../../../../libs/libraries.htm" > Libraries< / a > < / td >
2009-02-12 14:01:48 +00:00
< td align = "center" > < a href = "http://www.boost.org/users/people.html" > People< / a > < / td >
< td align = "center" > < a href = "http://www.boost.org/users/faq.html" > FAQ< / a > < / td >
2008-02-14 17:43:52 +00:00
< td align = "center" > < a href = "../../../../more/index.htm" > More< / a > < / td >
< / tr > < / table >
2007-05-29 06:40:25 +00:00
< hr >
2014-05-07 17:07:12 +02:00
< div class = "spirit-nav" > < a accesskey = "n" href = "boost_optional/motivation.html" > < img src = "../../../../doc/src/images/next.png" alt = "Next" > < / a > < / div >
2011-04-06 20:54:18 +00:00
< div class = "chapter" >
2007-05-29 06:40:25 +00:00
< div class = "titlepage" > < div >
< div > < h2 class = "title" >
2011-04-06 20:54:18 +00:00
< a name = "optional" > < / a > Chapter  1.  Boost.Optional< / h2 > < / div >
2007-05-29 06:40:25 +00:00
< div > < div class = "author" > < h3 class = "author" >
< span class = "firstname" > Fernando Luis< / span > < span class = "surname" > Cacciola Carballal< / span >
< / h3 > < / div > < / div >
2011-04-06 20:54:18 +00:00
< div > < p class = "copyright" > Copyright © 2003-2007 Fernando Luis Cacciola Carballal< / p > < / div >
2014-05-05 19:08:11 +02:00
< div > < p class = "copyright" > Copyright © 2014 Andrzej Krzemień ski< / p > < / div >
2011-04-06 20:54:18 +00:00
< div > < div class = "legalnotice" >
2013-02-16 19:42:42 +00:00
< a name = "optional.legal" > < / a > < p >
2007-05-29 06:40:25 +00:00
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at < a href = "http://www.boost.org/LICENSE_1_0.txt" target = "_top" > http://www.boost.org/LICENSE_1_0.txt< / a > )
< / p >
< / div > < / div >
< / div > < / div >
< div class = "toc" >
< p > < b > Table of Contents< / b > < / p >
2014-04-12 20:54:37 +02:00
< dl class = "toc" >
2014-05-07 17:07:12 +02:00
< dt > < span class = "section" > < a href = "index.html#optional.introduction" > Introduction< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/motivation.html" > Motivation< / a > < / span > < / dt >
2007-05-29 06:40:25 +00:00
< dt > < span class = "section" > < a href = "boost_optional/development.html" > Development< / a > < / span > < / dt >
2008-02-14 17:43:52 +00:00
< dd > < dl >
< dt > < span class = "section" > < a href = "boost_optional/development.html#boost_optional.development.the_models" > The models< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/development.html#boost_optional.development.the_semantics" > The semantics< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/development.html#boost_optional.development.the_interface" > The Interface< / a > < / span > < / dt >
< / dl > < / dd >
2007-05-29 06:40:25 +00:00
< dt > < span class = "section" > < a href = "boost_optional/synopsis.html" > Synopsis< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/detailed_semantics.html" > Detailed Semantics< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/examples.html" > Examples< / a > < / span > < / dt >
2008-02-14 17:43:52 +00:00
< dd > < dl >
< dt > < span class = "section" > < a href = "boost_optional/examples.html#boost_optional.examples.optional_return_values" > Optional
return values< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/examples.html#boost_optional.examples.optional_local_variables" > Optional
local variables< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/examples.html#boost_optional.examples.optional_data_members" > Optional
data members< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction" > Bypassing
expensive unnecessary default construction< / a > < / span > < / dt >
< / dl > < / dd >
2007-05-29 06:40:25 +00:00
< dt > < span class = "section" > < a href = "boost_optional/optional_references.html" > Optional references< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/rebinding_semantics_for_assignment_of_optional_references.html" > Rebinding
semantics for assignment of optional references< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/in_place_factories.html" > In-Place Factories< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/a_note_about_optional_bool_.html" > A note about
optional< bool> < / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/exception_safety_guarantees.html" > Exception Safety
Guarantees< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/type_requirements.html" > Type requirements< / a > < / span > < / dt >
< dt > < span class = "section" > < a href = "boost_optional/dependencies_and_portability.html" > Dependencies
and Portability< / a > < / span > < / dt >
2014-05-08 21:50:41 +02:00
< dd > < dl > < dt > < span class = "section" > < a href = "boost_optional/dependencies_and_portability.html#boost_optional.dependencies_and_portability.optional_reference_binding" > Optional
Reference Binding< / a > < / span > < / dt > < / dl > < / dd >
2007-05-29 06:40:25 +00:00
< dt > < span class = "section" > < a href = "boost_optional/acknowledgments.html" > Acknowledgments< / a > < / span > < / dt >
< / dl >
< / div >
2014-04-11 23:36:24 +02:00
< div class = "section" >
2007-05-29 06:40:25 +00:00
< div class = "titlepage" > < div > < div > < h2 class = "title" style = "clear: both" >
2014-05-07 17:07:12 +02:00
< a name = "optional.introduction" > < / a > < a class = "link" href = "index.html#optional.introduction" title = "Introduction" > Introduction< / a >
2007-05-29 06:40:25 +00:00
< / h2 > < / div > < / div > < / div >
< p >
2014-05-08 21:50:41 +02:00
This library can be used to represent 'optional' (or 'nullable') objects that
can be safely passed by value:
2007-05-29 06:40:25 +00:00
< / p >
2014-05-07 17:07:12 +02:00
< pre class = "programlisting" > < span class = "identifier" > optional< / span > < span class = "special" > < < / span > < span class = "keyword" > int< / span > < span class = "special" > > < / span > < span class = "identifier" > readInt< / span > < span class = "special" > ();< / span > < span class = "comment" > // this function may return either an int or a not-an-int< / span >
< span class = "keyword" > if< / span > < span class = "special" > (< / span > < span class = "identifier" > optional< / span > < span class = "special" > < < / span > < span class = "keyword" > int< / span > < span class = "special" > > < / span > < span class = "identifier" > oi< / span > < span class = "special" > =< / span > < span class = "identifier" > readInt< / span > < span class = "special" > ())< / span > < span class = "comment" > // did I get a real int< / span >
< span class = "identifier" > cout< / span > < span class = "special" > < < < / span > < span class = "string" > "my int is: "< / span > < span class = "special" > < < < / span > < span class = "special" > *< / span > < span class = "identifier" > oi< / span > < span class = "special" > ;< / span > < span class = "comment" > // use my int< / span >
< span class = "keyword" > else< / span >
< span class = "identifier" > cout< / span > < span class = "special" > < < < / span > < span class = "string" > "I have no int"< / span > < span class = "special" > ;< / span >
2007-05-29 06:40:25 +00:00
< / pre >
< / div >
< / div >
< table xmlns:rev = "http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width = "100%" > < tr >
2014-05-22 23:32:49 +02:00
< td align = "left" > < p > < small > Last revised: May 22, 2014 at 21:28:38 GMT< / small > < / p > < / td >
2008-02-14 17:43:52 +00:00
< td align = "right" > < div class = "copyright-footer" > < / div > < / td >
2007-05-29 06:40:25 +00:00
< / tr > < / table >
< hr >
2014-05-07 17:07:12 +02:00
< div class = "spirit-nav" > < a accesskey = "n" href = "boost_optional/motivation.html" > < img src = "../../../../doc/src/images/next.png" alt = "Next" > < / a > < / div >
2007-05-29 06:40:25 +00:00
< / body >
< / html >