diff -purN orig/boost/optional/optional.hpp boost_1_46_0_beta1/boost/optional/optional.hpp
|
old
|
new
|
struct types_when_isnt_ref
|
| 152 | 152 | { |
| 153 | 153 | typedef T const& reference_const_type ; |
| 154 | 154 | typedef T & reference_type ; |
| | 155 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 156 | typedef T && rreference_type ; |
| | 157 | #endif |
| 155 | 158 | typedef T const* pointer_const_type ; |
| 156 | 159 | typedef T * pointer_type ; |
| 157 | 160 | typedef T const& argument_type ; |
| … |
… |
struct types_when_is_ref
|
| 163 | 166 | |
| 164 | 167 | typedef raw_type& reference_const_type ; |
| 165 | 168 | typedef raw_type& reference_type ; |
| | 169 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 170 | typedef raw_type&& rreference_type ; |
| | 171 | #endif |
| 166 | 172 | typedef raw_type* pointer_const_type ; |
| 167 | 173 | typedef raw_type* pointer_type ; |
| 168 | 174 | typedef raw_type& argument_type ; |
| … |
… |
class optional_base : public optional_ta
|
| 205 | 211 | |
| 206 | 212 | typedef BOOST_DEDUCED_TYPENAME types::reference_type reference_type ; |
| 207 | 213 | typedef BOOST_DEDUCED_TYPENAME types::reference_const_type reference_const_type ; |
| | 214 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 215 | typedef BOOST_DEDUCED_TYPENAME types::rreference_type rreference_type ; |
| | 216 | #endif |
| 208 | 217 | typedef BOOST_DEDUCED_TYPENAME types::pointer_type pointer_type ; |
| 209 | 218 | typedef BOOST_DEDUCED_TYPENAME types::pointer_const_type pointer_const_type ; |
| 210 | 219 | typedef BOOST_DEDUCED_TYPENAME types::argument_type argument_type ; |
| … |
… |
class optional_base : public optional_ta
|
| 240 | 249 | construct(val); |
| 241 | 250 | } |
| 242 | 251 | |
| | 252 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 253 | // Creates an optional<T> move-constructed from 'val' |
| | 254 | // Can throw if T::T(T &&) does |
| | 255 | optional_base ( rreference_type val ) |
| | 256 | : |
| | 257 | m_initialized(false) |
| | 258 | { |
| | 259 | construct(std::forward<T>(val)); |
| | 260 | } |
| | 261 | |
| | 262 | // Creates an optional<T> move-constructed from 'val' IFF cond is true, otherwise creates an uninitialzed optional<T>. |
| | 263 | // Can throw if T::T(T &&) does |
| | 264 | optional_base ( bool cond, rreference_type val ) |
| | 265 | : |
| | 266 | m_initialized(false) |
| | 267 | { |
| | 268 | if ( cond ) |
| | 269 | construct(std::forward<T>(val)); |
| | 270 | } |
| | 271 | #endif |
| | 272 | |
| 243 | 273 | // Creates a deep copy of another optional<T> |
| 244 | 274 | // Can throw if T::T(T const&) does |
| 245 | 275 | optional_base ( optional_base const& rhs ) |
| … |
… |
class optional_base : public optional_ta
|
| 308 | 338 | else construct(val); |
| 309 | 339 | } |
| 310 | 340 | |
| | 341 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 342 | // Assigns from a T (moves the rhs value) |
| | 343 | void assign ( rreference_type val ) |
| | 344 | { |
| | 345 | if (is_initialized()) |
| | 346 | assign_value(std::forward<T>(val), is_reference_predicate() ); |
| | 347 | else construct(std::forward<T>(val)); |
| | 348 | } |
| | 349 | #endif |
| | 350 | |
| 311 | 351 | // Assigns from "none", destroying the current value, if any, leaving this UNINITIALIZED |
| 312 | 352 | // No-throw (assuming T::~T() doesn't) |
| 313 | 353 | void assign ( none_t ) { destroy(); } |
| … |
… |
class optional_base : public optional_ta
|
| 347 | 387 | m_initialized = true ; |
| 348 | 388 | } |
| 349 | 389 | |
| | 390 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 391 | void construct ( rreference_type val ) |
| | 392 | { |
| | 393 | new (m_storage.address()) internal_type(std::forward<T>(val)) ; |
| | 394 | m_initialized = true ; |
| | 395 | } |
| | 396 | #endif |
| | 397 | |
| 350 | 398 | #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT |
| 351 | 399 | // Constructs in-place using the given factory |
| 352 | 400 | template<class Expr> |
| … |
… |
class optional_base : public optional_ta
|
| 432 | 480 | |
| 433 | 481 | void assign_value ( argument_type val, is_not_reference_tag ) { get_impl() = val; } |
| 434 | 482 | void assign_value ( argument_type val, is_reference_tag ) { construct(val); } |
| | 483 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 484 | void assign_value ( rreference_type val, is_not_reference_tag ) { get_impl() = std::forward<T>(val); } |
| | 485 | void assign_value ( rreference_type val, is_reference_tag ) { construct(std::forward<T>(val)); } |
| | 486 | #endif |
| 435 | 487 | |
| 436 | 488 | void destroy() |
| 437 | 489 | { |
| … |
… |
class optional : public optional_detail:
|
| 509 | 561 | typedef BOOST_DEDUCED_TYPENAME base::value_type value_type ; |
| 510 | 562 | typedef BOOST_DEDUCED_TYPENAME base::reference_type reference_type ; |
| 511 | 563 | typedef BOOST_DEDUCED_TYPENAME base::reference_const_type reference_const_type ; |
| | 564 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 565 | typedef BOOST_DEDUCED_TYPENAME base::rreference_type rreference_type ; |
| | 566 | #endif |
| 512 | 567 | typedef BOOST_DEDUCED_TYPENAME base::pointer_type pointer_type ; |
| 513 | 568 | typedef BOOST_DEDUCED_TYPENAME base::pointer_const_type pointer_const_type ; |
| 514 | 569 | typedef BOOST_DEDUCED_TYPENAME base::argument_type argument_type ; |
| … |
… |
class optional : public optional_detail:
|
| 529 | 584 | // Can throw if T::T(T const&) does |
| 530 | 585 | optional ( bool cond, argument_type val ) : base(cond,val) {} |
| 531 | 586 | |
| | 587 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 588 | // Creates an optional<T> moved from 'val'. |
| | 589 | // Can throw if T::T(T &&) does |
| | 590 | optional ( rreference_type val ) : base(std::forward<value_type>(val)) {} |
| | 591 | |
| | 592 | // Creates an optional<T> moved from 'val' IFF cond is true, otherwise creates an uninitialized optional. |
| | 593 | // Can throw if T::T(T &&) does |
| | 594 | optional ( bool cond, rreference_type val ) : base(cond,std::forward<value_type>(val)) {} |
| | 595 | #endif |
| | 596 | |
| 532 | 597 | #ifndef BOOST_OPTIONAL_NO_CONVERTING_COPY_CTOR |
| 533 | 598 | // NOTE: MSVC needs templated versions first |
| 534 | 599 | |
| … |
… |
class optional : public optional_detail:
|
| 607 | 672 | return *this ; |
| 608 | 673 | } |
| 609 | 674 | |
| | 675 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 676 | // Assigns from a T (moves the rhs value) |
| | 677 | // Basic Guarantee: If T::( T && ) throws, this is left UNINITIALIZED |
| | 678 | optional& operator= ( rreference_type val ) |
| | 679 | { |
| | 680 | this->assign( std::forward<T>(val) ) ; |
| | 681 | return *this ; |
| | 682 | } |
| | 683 | #endif |
| | 684 | |
| 610 | 685 | // Assigns from a "none" |
| 611 | 686 | // Which destroys the current value, if any, leaving this UNINITIALIZED |
| 612 | 687 | // No-throw (assuming T::~T() doesn't) |
| … |
… |
optional<T> make_optional ( bool cond, T
|
| 671 | 746 | return optional<T>(cond,v); |
| 672 | 747 | } |
| 673 | 748 | |
| | 749 | #ifdef BOOST_HAS_RVALUE_REFS |
| | 750 | // Returns optional<T>(v) |
| | 751 | template<class T> |
| | 752 | inline |
| | 753 | optional<T> make_optional ( T && v ) |
| | 754 | { |
| | 755 | return optional<T>(std::forward<T>(v)); |
| | 756 | } |
| | 757 | |
| | 758 | // Returns optional<T>(cond,v) |
| | 759 | template<class T> |
| | 760 | inline |
| | 761 | optional<T> make_optional ( bool cond, T && v ) |
| | 762 | { |
| | 763 | return optional<T>(cond,std::forward<T>(v)); |
| | 764 | } |
| | 765 | #endif |
| | 766 | |
| 674 | 767 | // Returns a reference to the value if this is initialized, otherwise, the behaviour is UNDEFINED. |
| 675 | 768 | // No-throw |
| 676 | 769 | template<class T> |