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" >  
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< title > Optional references< / title >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< link  rel = "stylesheet"  href = "../boostbook.css"  type = "text/css" >  
						 
					
						
							
								
									
										
										
										
											2009-11-20 10:26:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< meta  name = "generator"  content = "DocBook XSL Stylesheets V1.75.2" >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< link  rel = "home"  href = "../index.html"  title = "Chapter 1. Boost.Optional" >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< link  rel = "up"  href = "../index.html"  title = "Chapter 1. Boost.Optional" >  
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< link  rel = "prev"  href = "examples.html"  title = "Examples" >  
						 
					
						
							
								
									
										
										
										
											2009-02-12 14:01:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< link  rel = "next"  href = "rebinding_semantics_for_assignment_of_optional_references.html"  title = "Rebinding semantics for assignment of optional references" >  
						 
					
						
							
								
									
										
										
										
											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 >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< div  class = "spirit-nav" >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< a  accesskey = "p"  href = "examples.html" > < img  src = "../../../../../doc/src/images/prev.png"  alt = "Prev" > < / a > < a  accesskey = "u"  href = "../index.html" > < img  src = "../../../../../doc/src/images/up.png"  alt = "Up" > < / a > < a  accesskey = "h"  href = "../index.html" > < img  src = "../../../../../doc/src/images/home.png"  alt = "Home" > < / a > < a  accesskey = "n"  href = "rebinding_semantics_for_assignment_of_optional_references.html" > < img  src = "../../../../../doc/src/images/next.png"  alt = "Next" > < / a >  
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< / div >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< div  class = "section" >  
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< div  class = "titlepage" > < div > < div > < h2  class = "title"  style = "clear: both" >  
						 
					
						
							
								
									
										
										
										
											2009-02-12 14:01:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< a  name = "boost_optional.optional_references" > < / a > < a  class = "link"  href = "optional_references.html"  title = "Optional references" > Optional references< / a >  
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< / h2 > < / div > < / div > < / div >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< p >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      This library allows the template parameter < code  class = "computeroutput" > < span  class = "identifier" > T< / span > < / code > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      to be of reference type: < code  class = "computeroutput" > < span  class = "identifier" > T< / span > < span  class = "special" > & < / span > < / code > , and to some extent, < code  class = "computeroutput" > < span  class = "identifier" > T< / span > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < span  class = "keyword" > const< / span > < span  class = "special" > & < / span > < / code > .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< p >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      However, since references are not real objects some restrictions apply and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      some operations are not available in this case:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < / p > 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-20 10:26:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< div  class = "itemizedlist" > < ul  class = "itemizedlist"  type = "disc" >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< li  class = "listitem" >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          Converting constructors
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < / li > 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-20 10:26:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< li  class = "listitem" >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          Converting assignment
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < / li > 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-20 10:26:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< li  class = "listitem" >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          InPlace construction
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < / li > 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-20 10:26:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< li  class = "listitem" >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          InPlace assignment
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < / li > 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-20 10:26:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< li  class = "listitem" >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          Value-access via pointer
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < / li > 
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< / ul > < / div >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< p >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      Also, even though < code  class = "computeroutput" > < span  class = "identifier" > optional< / span > < span  class = "special" > < < / span > < span  class = "identifier" > T< / span > < span  class = "special" > & > < / span > < / code > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      treats it wrapped pseudo-object much as a real value, a true real reference
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      is stored so aliasing will ocurr:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < / p > 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-20 10:26:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< div  class = "itemizedlist" > < ul  class = "itemizedlist"  type = "disc" >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< li  class = "listitem" >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          Copies of < code  class = "computeroutput" > < span  class = "identifier" > optional< / span > < span  class = "special" > < < / span > < span  class = "identifier" > T< / span > < span  class = "special" > & > < / span > < / code > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          will copy the references but all these references will nonetheless reefer
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          to the same object.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < / li > 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-20 10:26:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< li  class = "listitem" >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          Value-access will actually provide access to the referenced object rather
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          than the reference itself.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < / li > 
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< / ul > < / div >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / div >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< table  xmlns:rev = "http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"  width = "100%" > < tr >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< td  align = "left" > < / td >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< td  align = "right" > < div  class = "copyright-footer" > Copyright ©  2003-2007 Fernando Luis Cacciola Carballal< p >  
						 
					
						
							
								
									
										
										
										
											2008-02-14 17:43:52 +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 > < / td >  
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< / tr > < / table >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< hr >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< div  class = "spirit-nav" >  
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< a  accesskey = "p"  href = "examples.html" > < img  src = "../../../../../doc/src/images/prev.png"  alt = "Prev" > < / a > < a  accesskey = "u"  href = "../index.html" > < img  src = "../../../../../doc/src/images/up.png"  alt = "Up" > < / a > < a  accesskey = "h"  href = "../index.html" > < img  src = "../../../../../doc/src/images/home.png"  alt = "Home" > < / a > < a  accesskey = "n"  href = "rebinding_semantics_for_assignment_of_optional_references.html" > < img  src = "../../../../../doc/src/images/next.png"  alt = "Next" > < / a >  
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< / div >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / body >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / html >