diff --git a/doc/html/boost_optional/a_note_about_optional_bool_.html b/doc/html/boost_optional/a_note_about_optional_bool_.html index 5191d1d..395e573 100644 --- a/doc/html/boost_optional/a_note_about_optional_bool_.html +++ b/doc/html/boost_optional/a_note_about_optional_bool_.html @@ -1,23 +1,21 @@ -A note about - optional<bool> +A note about optional<bool> - + - + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -26,8 +24,7 @@

-A note about +A note about optional<bool>

@@ -36,7 +33,7 @@

First, it is functionally similar to a tristate boolean (false,maybe,true) - —such as boost::tribool— + —such as boost::tribool— except that in a tristate boolean, the maybe state represents a valid value, unlike the corresponding state of an uninitialized optional<bool>. It @@ -52,8 +49,7 @@ lead to subtle errors due to the implicit bool conversion:

-
-void foo ( bool v ) ;
+
void foo ( bool v ) ;
 void bar()
 {
     optional<bool> v = try();
diff --git a/doc/html/boost_optional/acknowledgments.html b/doc/html/boost_optional/acknowledgments.html
index 09e3c71..49ac7c8 100644
--- a/doc/html/boost_optional/acknowledgments.html
+++ b/doc/html/boost_optional/acknowledgments.html
@@ -3,19 +3,18 @@
 
 Acknowledgments
 
-
+
 
 
-
+
 
 
 
-
+
-
-
+
+
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,11 +23,11 @@

-Acknowledgments +Acknowledgments

- - Pre-formal + + Pre-formal review

- - Post-formal + + Post-formal review

diff --git a/doc/html/boost_optional/detailed_semantics.html b/doc/html/boost_optional/detailed_semantics.html index ef68023..06a6a63 100644 --- a/doc/html/boost_optional/detailed_semantics.html +++ b/doc/html/boost_optional/detailed_semantics.html @@ -3,7 +3,7 @@ Detailed Semantics - + @@ -12,10 +12,10 @@ - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More


@@ -24,7 +24,7 @@

Because T might be of reference @@ -64,8 +64,8 @@ space

- - optional + + optional class member functions

@@ -97,8 +97,7 @@ called.

  • -Example:
    -optional<T> def ;
    +Example:
    optional<T> def ;
     assert ( !def ) ;
     
  • @@ -134,8 +133,7 @@ The expression boost::none denotes an instance of boost::none_t that can be used as the parameter.
  • -Example:
    -#include <boost/none.hpp>
    +Example:
    #include <boost/none.hpp>
     optional<T> n(none) ;
     assert ( !n ) ;
     
    @@ -180,8 +178,7 @@ has no effect.
  • -Example:
    -T v;
    +Example:
    T v;
     optional<T> opt(v);
     assert ( *opt == v ) ;
     
    @@ -212,8 +209,7 @@ Throws: Nothing.
  • -Example:
    -T v;
    +Example:
    T v;
     T& vref = v ;
     optional<T&> opt(vref);
     assert ( *opt == v ) ;
    @@ -338,8 +334,7 @@
             has no effect.
           
  • -Example:
    -optional<T> uninit ;
    +Example:
    optional<T> uninit ;
     assert (!uninit);
     
     optional<T> uinit2 ( uninit ) ;
    @@ -387,8 +382,7 @@
             will reefer to the same object (they alias).
           
  • -Example:
    -optional<T&> uninit ;
    +Example:
    optional<T&> uninit ;
     assert (!uninit);
     
     optional<T&> uinit2 ( uninit ) ;
    @@ -454,8 +448,7 @@
             has no effect.
           
  • -Example:
    -optional<double> x(123.4);
    +Example:
    optional<double> x(123.4);
     assert ( *x == 123.4 ) ;
     
     optional<int> y(x) ;
    @@ -506,7 +499,7 @@
             constructor called by the factory throws.
           
  • -Notes: See In-Place +Notes: See In-Place Factories
  • @@ -515,8 +508,7 @@ constructor used by the factory; in that case, this constructor has no effect.
  • -Example:
    -class C { C ( char, double, std::string ) ; } ;
    +Example:
    class C { C ( char, double, std::string ) ; } ;
     
     C v('A',123.4,"hello");
     
    @@ -574,8 +566,7 @@
             copy constructor fails, *this is left properly uninitialized.
           
  • -Example:
    -T x;
    +Example:
    T x;
     optional<T> def ;
     optional<T> opt(x) ;
     
    @@ -613,12 +604,11 @@
           
  • Notes: If *this was initialized, is is rebound - to the new object. See here for + to the new object. See here for details on this behavior.
  • -Example:
    -int a = 1 ;
    +Example:
    int a = 1 ;
     int b = 2 ;
     T& ra = a ;
     T& rb = b ;
    @@ -687,8 +677,7 @@
             copy constructor fails, *this is left properly uninitialized.
           
  • -Example:
    -T v;
    +Example:
    T v;
     optional<T> opt(v);
     optional<T> def ;
     
    @@ -721,12 +710,11 @@
           
  • Notes: If *this was initialized and so is *rhs, this - is is rebound to the new object. See here + is is rebound to the new object. See here for details on this behavior.
  • -Example:
    -int a = 1 ;
    +Example:
    int a = 1 ;
     int b = 2 ;
     T& ra = a ;
     T& rb = b ;
    @@ -800,8 +788,7 @@
             converting constructor fails, *this is left properly uninitialized.
           
  • -Example:
    -T v;
    +Example:
    T v;
     optional<T> opt0(v);
     optional<U> opt1;
     
    @@ -930,8 +917,7 @@
             BOOST_ASSERT().
           
  • -Example:
    -T v ;
    +Example:
    T v ;
     optional<T> opt ( v );
     T const& u = *opt;
     assert ( u == v ) ;
    @@ -1005,8 +991,7 @@
     Throws: Nothing.
           
  • -Example:
    -T v, z ;
    +Example:
    T v, z ;
     optional<T> def;
     T const& y = def.get_value_or(z);
     assert ( y == z ) ;
    @@ -1099,8 +1084,7 @@
             BOOST_ASSERT().
           
  • -Example:
    -T v ;
    +Example:
    T v ;
     T& vref = v ;
     optional<T&> opt ( vref );
     T const& vref2 = *opt;
    @@ -1173,8 +1157,7 @@
             so you should not hold nor delete this pointer
           
  • -Example:
    -T v;
    +Example:
    T v;
     optional<T> opt(v);
     optional<T> const copt(v);
     T* p = opt.get_ptr() ;
    @@ -1226,8 +1209,7 @@
             BOOST_ASSERT().
           
  • -Example:
    -struct X { int mdata ; } ;
    +Example:
    struct X { int mdata ; } ;
     X x ;
     optional<X> opt (x);
     opt->mdata = 2 ;
    @@ -1257,8 +1239,7 @@
     Throws: Nothing.
           
  • -Example:
    -optional<T> def ;
    +Example:
    optional<T> def ;
     assert ( def == 0 );
     optional<T> opt ( v ) ;
     assert ( opt );
    @@ -1294,8 +1275,7 @@
             in certain boolean contexts.
           
  • -Example:
    -optional<T> opt ;
    +Example:
    optional<T> opt ;
     assert ( !opt );
     *opt = some_T ;
     
    @@ -1328,8 +1308,7 @@
     Throws: Nothing.
           
  • -Example:
    -optional<T> def ;
    +Example:
    optional<T> def ;
     assert ( !def.is_initialized() );
     optional<T> opt ( v ) ;
     assert ( opt.is_initialized() );
    @@ -1340,8 +1319,8 @@
           space
         

    - - Free functions + + Free functions

    space @@ -1364,8 +1343,7 @@ of v.

  • -Example:
    -template<class T> void foo ( optional<T> const& opt ) ;
    +Example:
    template<class T> void foo ( optional<T> const& opt ) ;
     
     foo ( make_optional(1+1) ) ; // Creates an optional<int>
     
    @@ -1393,8 +1371,7 @@ of v.
  • -Example:
    -optional<double> calculate_foo()
    +Example:
    optional<double> calculate_foo()
     {
       double val = compute_foo();
       return make_optional(is_not_nan_and_finite(val),val);
    @@ -1441,8 +1418,7 @@
             instead
           
  • -Example:
    -T x(12);
    +Example:
    T x(12);
     T y(12);
     T z(21);
     optional<T> def0 ;
    @@ -1503,8 +1479,7 @@
             instead.
           
  • -Example:
    -T x(12);
    +Example:
    T x(12);
     T y(34);
     optional<T> def ;
     optional<T> optX(x);
    @@ -1674,8 +1649,7 @@
             If only one is initialized, it has the same basic guarantee as optional<T>::reset( T const& ).
           
  • -Example:
    -T x(12);
    +Example:
    T x(12);
     T y(21);
     optional<T> def0 ;
     optional<T> def1 ;
    diff --git a/doc/html/boost_optional/development.html b/doc/html/boost_optional/development.html
    index 8d58d8b..5a14713 100644
    --- a/doc/html/boost_optional/development.html
    +++ b/doc/html/boost_optional/development.html
    @@ -3,7 +3,7 @@
     
     Development
     
    -
    +
     
     
     
    @@ -12,10 +12,10 @@
     
     
    -
    +
    -
    -
    +
    +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

    @@ -24,7 +24,7 @@
  • The models
    @@ -33,7 +33,7 @@

    In C++, we can declare an object (a variable) of type @@ -170,7 +170,7 @@

    Objects of type optional<T> @@ -254,7 +254,7 @@

    Since the purpose of optional is to allow us to use objects with a formal @@ -292,8 +292,8 @@ itself which are supported by a special interface.

    - - Lexically-hinted + + Lexically-hinted Value Access in the presence of possibly untitialized optional objects: The operators * and ->
    @@ -357,8 +357,8 @@ incarnated by pointers.

    - - Optional<T> + + Optional<T> as a model of OptionalPointee

    diff --git a/doc/html/boost_optional/examples.html b/doc/html/boost_optional/examples.html index 7685a73..20bf2ec 100644 --- a/doc/html/boost_optional/examples.html +++ b/doc/html/boost_optional/examples.html @@ -3,7 +3,7 @@ Examples - + @@ -12,10 +12,10 @@ - + - - + +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More


    @@ -24,7 +24,7 @@
    -
    -optional<char> get_async_input()
    +
    optional<char> get_async_input()
     {
         if ( !queue.empty() )
             return optional<char>(queue.top());
    @@ -61,12 +59,10 @@
     
    -
    -optional<string> name ;
    +
    optional<string> name ;
     if ( database.open() )
     {
         name.reset ( database.lookup(employer_name) ) ;
    @@ -84,12 +80,10 @@
     
    -
    -class figure
    +
    class figure
     {
         public:
     
    @@ -124,12 +118,10 @@
     
    -
    -class ExpensiveCtor { ... } ;
    +
    class ExpensiveCtor { ... } ;
     class Fred
     {
         Fred() : mLargeVector(10000) {}
    diff --git a/doc/html/boost_optional/exception_safety_guarantees.html b/doc/html/boost_optional/exception_safety_guarantees.html
    index 8f6504f..42b6aa0 100644
    --- a/doc/html/boost_optional/exception_safety_guarantees.html
    +++ b/doc/html/boost_optional/exception_safety_guarantees.html
    @@ -1,23 +1,21 @@
     
     
     
    -Exception Safety
    -    Guarantees
    +Exception Safety Guarantees
     
    -
    +
     
     
    -
    +
     
     
     
     
    -
    +
    -
    -
    +
    +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

    @@ -26,12 +24,11 @@

    - Because of the current implementation (see Implementation + Because of the current implementation (see Implementation Notes), all of the assignment methods:

      @@ -75,8 +72,7 @@ know that optional's assignment and reset has the same guarantees.

      -
      -//
      +
      //
       // Case 1: Exception thrown during assignment.
       //
       T v0(123);
      @@ -116,8 +112,8 @@
       }
       

      - - Swap + + Swap

      void swap( optional<T>&, diff --git a/doc/html/boost_optional/implementation_notes.html b/doc/html/boost_optional/implementation_notes.html index c0225b3..31a2ebe 100644 --- a/doc/html/boost_optional/implementation_notes.html +++ b/doc/html/boost_optional/implementation_notes.html @@ -3,20 +3,19 @@ Implementation Notes - + - + - + - - + +
      Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More


      @@ -25,7 +24,7 @@

    optional<T> is diff --git a/doc/html/boost_optional/in_place_factories.html b/doc/html/boost_optional/in_place_factories.html index a972384..45896e5 100644 --- a/doc/html/boost_optional/in_place_factories.html +++ b/doc/html/boost_optional/in_place_factories.html @@ -3,21 +3,19 @@ In-Place Factories - + - - + + - + - - + +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More


    @@ -26,7 +24,7 @@

    One of the typical problems with wrappers and containers is that their interfaces @@ -36,8 +34,7 @@ but also requires the existence of a fully constructed object, often temporary, just to follow the copy from:

    -
    -struct X
    +
    struct X
     {
         X ( int, std:::string ) ;
     } ;
    @@ -62,8 +59,7 @@
           object right in the container's storage. In this scheme, the user only needs
           to supply the arguments to the constructor to use in the wrapped object construction.
         

    -
    -class W
    +
    class W
     {
         X wrapped_ ;
     
    @@ -96,8 +92,7 @@
     

    For example, one member of this family looks like:

    -
    -template<class T,class A0, class A1>
    +
    template<class T,class A0, class A1>
     class TypedInPlaceFactory2
     {
         A0 m_a0 ; A1 m_a1 ;
    @@ -112,8 +107,7 @@
     

    A wrapper class aware of this can use it as:

    -
    -class W
    +
    class W
     {
         X wrapped_ ;
     
    @@ -152,8 +146,7 @@
           This library provides an overloaded set of helper template functions to construct
           these factories without requiring unnecessary template parameters:
         

    -
    -template<class A0,...,class AN>
    +
    template<class A0,...,class AN>
     InPlaceFactoryN <A0,...,AN> in_place ( A0 const& a0, ..., AN const& aN) ;
     
     template<class T,class A0,...,class AN>
    @@ -162,8 +155,7 @@
     

    In-place factories can be used generically by the wrapper and user as follows:

    -
    -class W
    +
    class W
     {
         X wrapped_ ;
     
    diff --git a/doc/html/boost_optional/optional_references.html b/doc/html/boost_optional/optional_references.html
    index 1222a42..7ea6a39 100644
    --- a/doc/html/boost_optional/optional_references.html
    +++ b/doc/html/boost_optional/optional_references.html
    @@ -3,20 +3,19 @@
     
     Optional references
     
    -
    +
     
     
     
    -
    +
     
     
     
    -
    +
    -
    -
    +
    +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

    @@ -25,7 +24,7 @@

    This library allows the template parameter T diff --git a/doc/html/boost_optional/rebinding_semantics_for_assignment_of_optional_references.html b/doc/html/boost_optional/rebinding_semantics_for_assignment_of_optional_references.html index 5b894aa..3a7df8e 100644 --- a/doc/html/boost_optional/rebinding_semantics_for_assignment_of_optional_references.html +++ b/doc/html/boost_optional/rebinding_semantics_for_assignment_of_optional_references.html @@ -1,10 +1,9 @@ -Rebinding - semantics for assignment of optional references +Rebinding semantics for assignment of optional references - + @@ -13,10 +12,10 @@ - + - - + +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More


    @@ -25,8 +24,7 @@

    @@ -34,8 +32,7 @@ the effect is to bind (for the first time) to the object. Clearly, there is no other choice.

    -
    -int x = 1 ;
    +
    int x = 1 ;
     int& rx = x ;
     optional<int&> ora ;
     optional<int&> orb(x) ;
    @@ -47,8 +44,7 @@
           If you assign to a bare C++ reference, the assignment is forwarded to the referenced
           object; it's value changes but the reference is never rebound.
         

    -
    -int a = 1 ;
    +
    int a = 1 ;
     int& ra = a ;
     int b = 2 ;
     int& rb = b ;
    @@ -62,8 +58,7 @@
           the effect is to rebind to the new object
           instead of assigning the referee. This is unlike bare C++ references.
         

    -
    -int a = 1 ;
    +
    int a = 1 ;
     int b = 2 ;
     int& ra = a ;
     int& rb = b ;
    @@ -75,8 +70,8 @@
     assert(b==3); 
     

    - - Rationale + + Rationale

    Rebinding semantics for the assignment of initialized @@ -95,8 +90,7 @@ forwarding assignment to the referenced object (thus changing the referenced object value but not rebinding), and consider the following code:

    -
    -optional<int&> a = get();
    +
    optional<int&> a = get();
     int x = 1 ;
     int& rx = x ;
     optional<int&> b(rx);
    @@ -134,8 +128,7 @@
           for the first time is OK while rebinding is not which is IMO very unlikely.
           In such scenario, you can assign the value itself directly, as in:
         

    -
    -assert(!!opt);
    +
    assert(!!opt);
     *opt=value;
     
    diff --git a/doc/html/boost_optional/synopsis.html b/doc/html/boost_optional/synopsis.html index c128fc6..2f7aaeb 100644 --- a/doc/html/boost_optional/synopsis.html +++ b/doc/html/boost_optional/synopsis.html @@ -3,7 +3,7 @@ Synopsis - + @@ -12,10 +12,10 @@ - + - - + +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

    @@ -24,10 +24,9 @@
    -
    -namespace boost {
    +
    namespace boost {
     
     template<class T>
     class optional
    @@ -36,101 +35,101 @@
     
         // (If T is of reference type, the parameters and results by reference are by value)
     
    -    optional () ; R
    +    optional () ; R
     
    -    optional ( none_t ) ; R
    +    optional ( none_t ) ; R
     
    -    optional ( T const& v ) ; R
    +    optional ( T const& v ) ; R
     
         // [new in 1.34]
    -    optional ( bool condition, T const& v ) ; R 
    +    optional ( bool condition, T const& v ) ; R 
     
    -    optional ( optional const& rhs ) ; R
    +    optional ( optional const& rhs ) ; R
     
    -    template<class U> explicit optional ( optional<U> const& rhs ) ; R
    +    template<class U> explicit optional ( optional<U> const& rhs ) ; R
     
    -    template<class InPlaceFactory> explicit optional ( InPlaceFactory const& f ) ; R
    +    template<class InPlaceFactory> explicit optional ( InPlaceFactory const& f ) ; R
     
    -    template<class TypedInPlaceFactory> explicit optional ( TypedInPlaceFactory const& f ) ; R
    +    template<class TypedInPlaceFactory> explicit optional ( TypedInPlaceFactory const& f ) ; R
     
         optional& operator = ( none_t ) ; 
     
    -    optional& operator = ( T const& v ) ; R
    +    optional& operator = ( T const& v ) ; R
     
    -    optional& operator = ( optional const& rhs ) ; R
    +    optional& operator = ( optional const& rhs ) ; R
     
    -    template<class U> optional& operator = ( optional<U> const& rhs ) ; R
    +    template<class U> optional& operator = ( optional<U> const& rhs ) ; R
     
         template<class InPlaceFactory> optional& operator = ( InPlaceFactory const& f ) ; 
     
         template<class TypedInPlaceFactory> optional& operator = ( TypedInPlaceFactory const& f ) ; 
     
    -    T const& get() const ; R
    -    T&       get() ; R
    +    T const& get() const ; R
    +    T&       get() ; R
     
         // [new in 1.34]
    -    T const& get_value_or( T const& default ) const ; R 
    +    T const& get_value_or( T const& default ) const ; R 
     
    -    T const* operator ->() const ; R
    -    T*       operator ->() ; R
    +    T const* operator ->() const ; R
    +    T*       operator ->() ; R
     
    -    T const& operator *() const ; R
    -    T&       operator *() ; R
    +    T const& operator *() const ; R
    +    T&       operator *() ; R
     
    -    T const* get_ptr() const ; R
    -    T*       get_ptr() ; R
    +    T const* get_ptr() const ; R
    +    T*       get_ptr() ; R
     
    -    operator unspecified-bool-type() const ; R
    +    operator unspecified-bool-type() const ; R
     
    -    bool operator!() const ; R
    +    bool operator!() const ; R
     
         // deprecated methods
     
         // (deprecated)
    -    void reset() ; R
    +    void reset() ; R
     
         // (deprecated)
    -    void reset ( T const& ) ; R
    +    void reset ( T const& ) ; R
     
         // (deprecated)
    -    bool is_initialized() const ; R
    +    bool is_initialized() const ; R
     
     };
     
    -template<class T> inline bool operator == ( optional<T> const& x, optional<T> const& y ) ; R
    +template<class T> inline bool operator == ( optional<T> const& x, optional<T> const& y ) ; R
     
    -template<class T> inline bool operator != ( optional<T> const& x, optional<T> const& y ) ; R
    +template<class T> inline bool operator != ( optional<T> const& x, optional<T> const& y ) ; R
     
    -template<class T> inline bool operator <  ( optional<T> const& x, optional<T> const& y ) ; R
    +template<class T> inline bool operator <  ( optional<T> const& x, optional<T> const& y ) ; R
     
    -template<class T> inline bool operator >  ( optional<T> const& x, optional<T> const& y ) ; R
    +template<class T> inline bool operator >  ( optional<T> const& x, optional<T> const& y ) ; R
     
    -template<class T> inline bool operator <= ( optional<T> const& x, optional<T> const& y ) ; R
    +template<class T> inline bool operator <= ( optional<T> const& x, optional<T> const& y ) ; R
     
    -template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ; R
    +template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ; R
     
     // [new in 1.34]
    -template<class T> inline optional<T> make_optional ( T const& v ) ; R
    +template<class T> inline optional<T> make_optional ( T const& v ) ; R
     
     // [new in 1.34]
    -template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; R
    +template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; R
     
     // [new in 1.34]
    -template<class T> inline T const& get_optional_value_or ( optional<T> const& opt, T const& default ) ; R 
    +template<class T> inline T const& get_optional_value_or ( optional<T> const& opt, T const& default ) ; R 
     
    -template<class T> inline T const& get ( optional<T> const& opt ) ; R
    +template<class T> inline T const& get ( optional<T> const& opt ) ; R
     
    -template<class T> inline T& get ( optional<T> & opt ) ; R
    +template<class T> inline T& get ( optional<T> & opt ) ; R
     
    -template<class T> inline T const* get ( optional<T> const* opt ) ; R
    +template<class T> inline T const* get ( optional<T> const* opt ) ; R
     
    -template<class T> inline T* get ( optional<T>* opt ) ; R
    +template<class T> inline T* get ( optional<T>* opt ) ; R
     
    -template<class T> inline T const* get_pointer ( optional<T> const& opt ) ; R
    +template<class T> inline T const* get_pointer ( optional<T> const& opt ) ; R
     
    -template<class T> inline T* get_pointer ( optional<T> & opt ) ; R
    +template<class T> inline T* get_pointer ( optional<T> & opt ) ; R
     
    -template<class T> inline void swap( optional<T>& x, optional<T>& y ) ; R
    +template<class T> inline void swap( optional<T>& x, optional<T>& y ) ; R
     
     } // namespace boost
     
    diff --git a/doc/html/boost_optional/type_requirements.html b/doc/html/boost_optional/type_requirements.html index 0676bf1..308453e 100644 --- a/doc/html/boost_optional/type_requirements.html +++ b/doc/html/boost_optional/type_requirements.html @@ -3,20 +3,19 @@ Type requirements - + - + - + - - + +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

    @@ -25,7 +24,7 @@

    In general, T must be Copy Constructible and diff --git a/doc/html/index.html b/doc/html/index.html index 24277e1..dbe7199 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -3,17 +3,17 @@ Chapter 1. Boost.Optional - + - + - - + +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More


    @@ -27,7 +27,7 @@
    -

    +

    Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

    @@ -73,7 +73,7 @@

    Consider these functions which should return a value but which might not have @@ -142,16 +142,14 @@ the function would conceptually return. For example, the last two functions could have the following interface:

    -
    -std::pair<char,bool> get_async_input();
    +
    std::pair<char,bool> get_async_input();
     std::pair<point,bool> polygon::get_any_point_effectively_inside();
     

    These functions use a consistent interface for dealing with possibly inexistent results:

    -
    -std::pair<point,bool> p = poly.get_any_point_effectively_inside();
    +
    std::pair<point,bool> p = poly.get_any_point_effectively_inside();
     if ( p.second )
         flood_fill(p.first);
     
    @@ -174,7 +172,7 @@

    - +

    Last revised: February 12, 2008 at 22:47:14 GMT

    Last revised: October 10, 2008 at 20:53:37 GMT


    diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index 01db469..42277ba 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal. +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -9,9 +9,6 @@ // You are welcome to contact the author at: // fernando_cacciola@hotmail.com // -// Revisions: -// 27 Apr 2008 (improved swap) Fernando Cacciola, Niels Dekker, Thorsten Ottosen -// #ifndef BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP #define BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP @@ -22,7 +19,6 @@ #include "boost/assert.hpp" #include "boost/type.hpp" #include "boost/type_traits/alignment_of.hpp" -#include "boost/type_traits/has_nothrow_constructor.hpp" #include "boost/type_traits/type_with_alignment.hpp" #include "boost/type_traits/remove_reference.hpp" #include "boost/type_traits/is_reference.hpp" @@ -32,7 +28,6 @@ #include "boost/detail/reference_content.hpp" #include "boost/none.hpp" #include "boost/utility/compare_pointees.hpp" -#include "boost/utility/in_place_factory.hpp" #include "boost/optional/optional_fwd.hpp" @@ -521,7 +516,7 @@ class optional : public optional_detail::optional_base // Creates a deep copy of another optional // Can throw if T::T(T const&) does - optional ( optional const& rhs ) : base( static_cast(rhs) ) {} + optional ( optional const& rhs ) : base(rhs) {} // No-throw (assuming T::~T() doesn't) ~optional() {} @@ -555,7 +550,7 @@ class optional : public optional_detail::optional_base // (NOTE: On BCB, this operator is not actually called and left is left UNMODIFIED in case of a throw) optional& operator= ( optional const& rhs ) { - this->assign( static_cast(rhs) ) ; + this->assign( rhs ) ; return *this ; } @@ -576,14 +571,6 @@ class optional : public optional_detail::optional_base return *this ; } - void swap( optional & arg ) - { - // allow for Koenig lookup - using boost::swap ; - swap(*this, arg); - } - - // Returns a reference to the value if this is initialized, otherwise, // the behaviour is UNDEFINED // No-throw @@ -891,77 +878,44 @@ namespace optional_detail { #define BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE #endif - template struct swap_selector; - - template<> - struct swap_selector +// optional's swap: +// If both are initialized, calls swap(T&, T&). If this swap throws, both will remain initialized but their values are now unspecified. +// If only one is initialized, calls U.reset(*I), THEN I.reset(). +// If U.reset(*I) throws, both are left UNCHANGED (U is kept uinitialized and I is never reset) +// If both are uninitialized, do nothing (no-throw) +template +inline +void optional_swap ( optional& x, optional& y ) +{ + if ( !x && !!y ) { - template - static void optional_swap ( optional& x, optional& y ) - { - bool hasX = x; - bool hasY = y; - - if ( !hasX && !hasY ) - return; - - if( !hasX ) - x = boost::in_place(); - else if ( !hasY ) - y = boost::in_place(); - - // GCC > 3.2 and all other compilers have the using declaration at function scope (FLC) + x.reset(*y); + y.reset(); + } + else if ( !!x && !y ) + { + y.reset(*x); + x.reset(); + } + else if ( !!x && !!y ) + { +// GCC > 3.2 and all other compilers have the using declaration at function scope (FLC) #ifndef BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE - // allow for Koenig lookup - using std::swap ; + // allow for Koenig lookup + using std::swap ; #endif - swap(*x,*y); - - if( !hasX ) - y = boost::none ; - else if( !hasY ) - x = boost::none ; - } - }; - - template<> - struct swap_selector - { - template - static void optional_swap ( optional& x, optional& y ) - { - if ( !x && !!y ) - { - x = *y; - y = boost::none ; - } - else if ( !!x && !y ) - { - y = *x ; - x = boost::none ; - } - else if ( !!x && !!y ) - { - // GCC > 3.2 and all other compilers have the using declaration at function scope (FLC) - #ifndef BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE - // allow for Koenig lookup - using std::swap ; - #endif - swap(*x,*y); - } - } - }; + swap(*x,*y); + } +} } // namespace optional_detail -template -struct optional_swap_should_use_default_constructor : has_nothrow_default_constructor {} ; - template inline void swap ( optional& x, optional& y ) { - optional_detail::swap_selector::value>::optional_swap(x, y); + optional_detail::optional_swap(x,y); } + } // namespace boost #endif diff --git a/include/boost/optional/optional_fwd.hpp b/include/boost/optional/optional_fwd.hpp index a74fe10..2cf4fa6 100644 --- a/include/boost/optional/optional_fwd.hpp +++ b/include/boost/optional/optional_fwd.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal. +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -9,9 +9,6 @@ // You are welcome to contact the author at: // fernando_cacciola@hotmail.com // -// Revisions: -// 10 May 2008 (added swap related forward declaration) Niels Dekker -// #ifndef BOOST_OPTIONAL_OPTIONAL_FWD_FLC_19NOV2002_HPP #define BOOST_OPTIONAL_OPTIONAL_FWD_FLC_19NOV2002_HPP @@ -19,10 +16,6 @@ namespace boost { template class optional ; -template void swap ( optional& , optional& ) ; - -template struct optional_swap_should_use_default_constructor ; - } // namespace boost #endif diff --git a/test/optional_test.cpp b/test/optional_test.cpp index e841194..02ed181 100644 --- a/test/optional_test.cpp +++ b/test/optional_test.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal. +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -9,9 +9,6 @@ // You are welcome to contact the author at: // fernando_cacciola@hotmail.com // -// Revisions: -// 12 May 2008 (added more swap tests) -// #include #include #include @@ -19,8 +16,6 @@ #define BOOST_ENABLE_ASSERT_HANDLER #include "boost/bind/apply.hpp" // Included just to test proper interaction with boost::apply<> as reported by Daniel Wallin -#include "boost/mpl/bool.hpp" -#include "boost/mpl/bool_fwd.hpp" // For mpl::true_ and mpl::false_ #include "boost/optional/optional.hpp" @@ -932,337 +927,6 @@ void test_conversions2() BOOST_CHECK(*get(&opt1) == static_cast(f)); } - -namespace optional_swap_test -{ - class default_ctor_exception : public std::exception {} ; - class copy_ctor_exception : public std::exception {} ; - class assignment_exception : public std::exception {} ; - - // - // Base class for swap test classes. Its assignment should not be called, when swapping - // optional objects. (The default std::swap would do so.) - // - class base_class_with_forbidden_assignment - { - public: - base_class_with_forbidden_assignment & operator=(const base_class_with_forbidden_assignment &) - { - BOOST_CHECK(!"The assignment should not be used while swapping!"); - throw assignment_exception(); - } - - virtual ~base_class_with_forbidden_assignment() {} - }; - - // - // Class without default constructor - // - class class_without_default_ctor : public base_class_with_forbidden_assignment - { - public: - char data; - explicit class_without_default_ctor(char arg) : data(arg) {} - }; - - // - // Class whose default constructor should not be used by optional::swap! - // - class class_whose_default_ctor_should_not_be_used : public base_class_with_forbidden_assignment - { - public: - char data; - explicit class_whose_default_ctor_should_not_be_used(char arg) : data(arg) {} - - class_whose_default_ctor_should_not_be_used() - { - BOOST_CHECK(!"This default constructor should not be used while swapping!"); - throw default_ctor_exception(); - } - }; - - // - // Class whose default constructor should be used by optional::swap. - // Its copy constructor should be avoided! - // - class class_whose_default_ctor_should_be_used : public base_class_with_forbidden_assignment - { - public: - char data; - explicit class_whose_default_ctor_should_be_used(char arg) : data(arg) { } - - class_whose_default_ctor_should_be_used() : data('\0') { } - - class_whose_default_ctor_should_be_used(const class_whose_default_ctor_should_be_used &) - { - BOOST_CHECK(!"This copy constructor should not be used while swapping!"); - throw copy_ctor_exception(); - } - }; - - // - // Class template whose default constructor should be used by optional::swap. - // Its copy constructor should be avoided! - // - template - class template_whose_default_ctor_should_be_used : public base_class_with_forbidden_assignment - { - public: - T data; - explicit template_whose_default_ctor_should_be_used(T arg) : data(arg) { } - - template_whose_default_ctor_should_be_used() : data('\0') { } - - template_whose_default_ctor_should_be_used(const template_whose_default_ctor_should_be_used &) - { - BOOST_CHECK(!"This copy constructor should not be used while swapping!"); - throw copy_ctor_exception(); - } - }; - - // - // Class whose explicit constructor should be used by optional::swap. - // Its other constructors should be avoided! - // - class class_whose_explicit_ctor_should_be_used : public base_class_with_forbidden_assignment - { - public: - char data; - explicit class_whose_explicit_ctor_should_be_used(char arg) : data(arg) { } - - class_whose_explicit_ctor_should_be_used() - { - BOOST_CHECK(!"This default constructor should not be used while swapping!"); - throw default_ctor_exception(); - } - - class_whose_explicit_ctor_should_be_used(const class_whose_explicit_ctor_should_be_used &) - { - BOOST_CHECK(!"This copy constructor should not be used while swapping!"); - throw copy_ctor_exception(); - } - }; - - void swap(class_whose_default_ctor_should_not_be_used & lhs, class_whose_default_ctor_should_not_be_used & rhs) - { - std::swap(lhs.data, rhs.data); - } - - void swap(class_whose_default_ctor_should_be_used & lhs, class_whose_default_ctor_should_be_used & rhs) - { - std::swap(lhs.data, rhs.data); - } - - void swap(class_without_default_ctor & lhs, class_without_default_ctor & rhs) - { - std::swap(lhs.data, rhs.data); - } - - void swap(class_whose_explicit_ctor_should_be_used & lhs, class_whose_explicit_ctor_should_be_used & rhs) - { - std::swap(lhs.data, rhs.data); - } - - template - void swap(template_whose_default_ctor_should_be_used & lhs, template_whose_default_ctor_should_be_used & rhs) - { - std::swap(lhs.data, rhs.data); - } - - // - // optional::swap should be customized when neither the copy constructor - // nor the default constructor of T are supposed to be used when swapping, e.g., - // for the following type T = class_whose_explicit_ctor_should_be_used. - // - void swap(boost::optional & x, boost::optional & y) - { - bool hasX = x; - bool hasY = y; - - if ( !hasX && !hasY ) - return; - - if( !hasX ) - x = boost::in_place('\0'); - else if ( !hasY ) - y = boost::in_place('\0'); - - optional_swap_test::swap(*x,*y); - - if( !hasX ) - y = boost::none ; - else if( !hasY ) - x = boost::none ; - } - - -} // End of namespace optional_swap_test. - - -namespace boost { - -// -// Compile time tweaking on whether or not swap should use the default constructor: -// - -template <> struct optional_swap_should_use_default_constructor< - optional_swap_test::class_whose_default_ctor_should_be_used> : mpl::true_ {} ; - -template <> struct optional_swap_should_use_default_constructor< - optional_swap_test::class_whose_default_ctor_should_not_be_used> : mpl::false_ {} ; - -template struct optional_swap_should_use_default_constructor< - optional_swap_test::template_whose_default_ctor_should_be_used > : mpl::true_ {} ; - - -// -// Specialization of boost::swap: -// -template <> -void swap(optional & x, optional & y) -{ - optional_swap_test::swap(x, y); -} - -} // namespace boost - - -namespace std { - -// -// Specializations of std::swap: -// - -template <> -void swap(optional_swap_test::class_whose_default_ctor_should_be_used & x, optional_swap_test::class_whose_default_ctor_should_be_used & y) -{ - optional_swap_test::swap(x, y); -} - -template <> -void swap(optional_swap_test::class_whose_default_ctor_should_not_be_used & x, optional_swap_test::class_whose_default_ctor_should_not_be_used & y) -{ - optional_swap_test::swap(x, y); -} - -template <> -void swap(optional_swap_test::class_without_default_ctor & x, optional_swap_test::class_without_default_ctor & y) -{ - optional_swap_test::swap(x, y); -} - -template <> -void swap(optional_swap_test::class_whose_explicit_ctor_should_be_used & x, optional_swap_test::class_whose_explicit_ctor_should_be_used & y) -{ - optional_swap_test::swap(x, y); -} - -} // namespace std - - -// -// Tests whether the swap function works properly for optional. -// Assumes that T has one data member, of type char. -// Returns true iff the test is passed. -// -template -bool test_swap_function( T const* ) -{ - const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter(); - try - { - optional obj1; - optional obj2('a'); - - // Self-swap should not have any effect. - swap(obj1, obj1); - swap(obj2, obj2); - BOOST_CHECK(!obj1); - BOOST_CHECK(!!obj2 && obj2->data == 'a'); - - // Call non-member swap. - swap(obj1, obj2); - - // Test if obj1 and obj2 are really swapped. - BOOST_CHECK(!!obj1 && obj1->data == 'a'); - BOOST_CHECK(!obj2); - - // Call non-member swap one more time. - swap(obj1, obj2); - - // Test if obj1 and obj2 are swapped back. - BOOST_CHECK(!obj1); - BOOST_CHECK(!!obj2 && obj2->data == 'a'); - } - catch(const std::exception &) - { - // The swap function should not throw, for our test cases. - return false ; - } - return boost::minimal_test::errors_counter() == counter_before_test ; -} - -// -// Tests whether the optional::swap member function works properly. -// Assumes that T has one data member, of type char. -// Returns true iff the test is passed. -// -template -bool test_swap_member_function( T const* ) -{ - const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter(); - try - { - optional obj1; - optional obj2('a'); - - // Self-swap should not have any effect. - obj1.swap(obj1); - obj2.swap(obj2); - BOOST_CHECK(!obj1); - BOOST_CHECK(!!obj2 && obj2->data == 'a'); - - // Call member swap. - obj1.swap(obj2); - - // Test if obj1 and obj2 are really swapped. - BOOST_CHECK(!!obj1 && obj1->data == 'a'); - BOOST_CHECK(!obj2); - - // Call member swap one more time. - obj1.swap(obj2); - - // Test if obj1 and obj2 are swapped back. - BOOST_CHECK(!obj1); - BOOST_CHECK(!!obj2 && obj2->data == 'a'); - } - catch(const std::exception &) - { - // The optional::swap member function should not throw, for our test cases. - return false ; - } - return boost::minimal_test::errors_counter() == counter_before_test ; -} - - -// -// Tests compile time tweaking of swap, by means of -// optional_swap_should_use_default_constructor. -// -void test_swap_tweaking() -{ - BOOST_CHECK( test_swap_function( ARG(optional_swap_test::class_without_default_ctor) ) ); - BOOST_CHECK( test_swap_function( ARG(optional_swap_test::class_whose_default_ctor_should_be_used) ) ); - BOOST_CHECK( test_swap_function( ARG(optional_swap_test::class_whose_default_ctor_should_not_be_used) ) ); - BOOST_CHECK( test_swap_function( ARG(optional_swap_test::class_whose_explicit_ctor_should_be_used) ) ); - BOOST_CHECK( test_swap_function( ARG(optional_swap_test::template_whose_default_ctor_should_be_used) ) ); - BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::class_without_default_ctor) ) ); - BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::class_whose_default_ctor_should_be_used) ) ); - BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::class_whose_default_ctor_should_not_be_used) ) ); - BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::class_whose_explicit_ctor_should_be_used) ) ); - BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::template_whose_default_ctor_should_be_used) ) ); -} - int test_main( int, char* [] ) { try @@ -1272,7 +936,6 @@ int test_main( int, char* [] ) test_no_implicit_conversions(); test_conversions1(); test_conversions2(); - test_swap_tweaking(); } catch ( ... ) {