diff --git a/doc/html/boost_optional/detailed_semantics.html b/doc/html/boost_optional/detailed_semantics.html
index 77b8815..b236179 100644
--- a/doc/html/boost_optional/detailed_semantics.html
+++ b/doc/html/boost_optional/detailed_semantics.html
@@ -1497,6 +1497,10 @@
y );
+-
+ Requires:
T
+ shall meet requirements of EqualityComparable
.
+
-
Returns: If both
x
and y
are initialized,
@@ -1553,6 +1557,10 @@
y );
+-
+ Requires:
T
+ shall meet requirements of LessThanComparable
.
+
-
Returns: If
y
is not initialized, false
.
@@ -1648,7 +1656,8 @@
-
Returns:
!(
- y<x );
+ y <
+ x );
-
Throws: Nothing.
@@ -1673,6 +1682,33 @@
Throws: Nothing.
+
+ bool operator
+ == ( optional<T> const& x, none_t
+ ) noexcept;
+
+
+-
+ Returns:
!x
.
+
+-
+ Notes:
T
+ need not meet requirements of EqualityComparable
.
+
+
+
+
+
+
+ bool operator
+ != ( optional<T> const& x, none_t
+ ) noexcept;
+
+-
+ Returns:
!(
+ x ==
+ y );
+
diff --git a/doc/html/boost_optional/synopsis.html b/doc/html/boost_optional/synopsis.html
index 8ce8e1f..95ffd46 100644
--- a/doc/html/boost_optional/synopsis.html
+++ b/doc/html/boost_optional/synopsis.html
@@ -122,6 +122,10 @@
template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ;
+template<class T> inline bool operator == ( optional<T> const& x, none_t ) noexcept ;
+
+template<class T> inline bool operator != ( optional<T> const& x, none_t ) noexcept ;
+
template<class T> inline optional<T> make_optional ( T const& v ) ;
diff --git a/doc/html/boost_optional/type_requirements.html b/doc/html/boost_optional/type_requirements.html
index 9723c4c..681d119 100644
--- a/doc/html/boost_optional/type_requirements.html
+++ b/doc/html/boost_optional/type_requirements.html
@@ -27,9 +27,9 @@
Type requirements
- In general, T
must be Copy Constructible and
- have a no-throw destructor. The copy-constructible requirement is not needed
- if InPlaceFactories are used.
+ In general, T
must be MoveConstructible
and have a no-throw destructor.
+ The MoveConstructible
requirement
+ is not needed if InPlaceFactories are used.
T
is
diff --git a/doc/html/index.html b/doc/html/index.html
index ba0c93f..13a38bc 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -163,7 +163,7 @@
-Last revised: April 28, 2014 at 23:21:56 GMT |
+Last revised: April 29, 2014 at 20:56:30 GMT |
|
diff --git a/doc/reference.qbk b/doc/reference.qbk
index 04b61aa..7ea348d 100644
--- a/doc/reference.qbk
+++ b/doc/reference.qbk
@@ -106,6 +106,10 @@
template inline bool operator <= ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_less_or_equal_optional_optional __GO_TO__]``
template inline bool operator >= ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_greater_or_equal_optional_optional __GO_TO__]``
+
+ template inline bool operator == ( optional const& x, none_t ) noexcept ; ``[link reference_operator_compare_equal_optional_none __GO_TO__]``
+
+ template inline bool operator != ( optional const& x, none_t ) noexcept ; ``[link reference_operator_compare_not_equal_optional_none __GO_TO__]``
// [new in 1.34]
template inline optional make_optional ( T const& v ) ; ``[link reference_make_optional_value __GO_TO__]``
@@ -972,6 +976,7 @@ __SPACE__
[: `bool operator == ( optional const& x, optional const& y );`]
+* [*Requires:] `T` shall meet requirements of `EqualityComparable`.
* [*Returns:] If both `x` and `y` are initialized, `(*x == *y)`. If only
`x` or `y` is initialized, `false`. If both are uninitialized, `true`.
* [*Throws:] Nothing.
@@ -1011,6 +1016,7 @@ __SPACE__
[: `bool operator < ( optional const& x, optional const& y );`]
+* [*Requires:] `T` shall meet requirements of `LessThanComparable`.
* [*Returns:] If `y` is not initialized, `false`. If `y` is initialized
and `x` is not initialized, `true`. If both `x` and `y` are initialized,
`(*x < *y)`.
@@ -1065,7 +1071,7 @@ __SPACE__
[: `bool operator <= ( optional const& x, optional const& y );`]
-* [*Returns: ] `!( y const& x, none_t ) noexcept;`]
+
+* [*Returns:] `!x`.
+* [*Notes:] `T` need not meet requirements of `EqualityComparable`.
+
+
+__SPACE__
+
+[#reference_operator_compare_not_equal_optional_none]
+
+[: `bool operator != ( optional const& x, none_t ) noexcept;`]
+
+* [*Returns: ] `!( x == y );`
+
+
__SPACE__
[#reference_swap_optional_optional]
diff --git a/doc/special_cases.qbk b/doc/special_cases.qbk
index 0f6f22b..0d7227c 100644
--- a/doc/special_cases.qbk
+++ b/doc/special_cases.qbk
@@ -369,8 +369,8 @@ since it is a no-op.
[section Type requirements]
-In general, `T` must be __COPY_CONSTRUCTIBLE__ and have a no-throw destructor.
-The copy-constructible requirement is not needed if [*InPlaceFactories] are used.
+In general, `T` must be `MoveConstructible` and have a no-throw destructor.
+The `MoveConstructible` requirement is not needed if [*InPlaceFactories] are used.
`T` [_is not] required to be __SGI_DEFAULT_CONSTRUCTIBLE__.
diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp
index c8752af..c5e73e1 100644
--- a/include/boost/optional/optional.hpp
+++ b/include/boost/optional/optional.hpp
@@ -1143,8 +1143,8 @@ bool operator >= ( T const& x, optional const& y )
template
inline
-bool operator == ( optional const& x, none_t )
-{ return equal_pointees(x, optional() ); }
+bool operator == ( optional const& x, none_t ) BOOST_NOEXCEPT
+{ return !x; }
template
inline
@@ -1153,8 +1153,8 @@ bool operator < ( optional const& x, none_t )
template
inline
-bool operator != ( optional const& x, none_t y )
-{ return !( x == y ) ; }
+bool operator != ( optional const& x, none_t ) BOOST_NOEXCEPT
+{ return bool(x); }
template
inline
@@ -1177,8 +1177,8 @@ bool operator >= ( optional const& x, none_t y )
template
inline
-bool operator == ( none_t , optional const& y )
-{ return equal_pointees(optional() ,y); }
+bool operator == ( none_t , optional const& y ) BOOST_NOEXCEPT
+{ return !y; }
template
inline
@@ -1187,8 +1187,8 @@ bool operator < ( none_t , optional const& y )
template
inline
-bool operator != ( none_t x, optional const& y )
-{ return !( x == y ) ; }
+bool operator != ( none_t, optional const& y ) BOOST_NOEXCEPT
+{ return bool(y); }
template
inline
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index c80b783..7218ffa 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -22,6 +22,7 @@ import testing ;
[ run optional_test_inplace.cpp ]
[ run optional_test_io.cpp ]
[ run optional_test_move.cpp ]
+ [ run optional_test_equals_none.cpp ]
[ compile-fail optional_test_fail1.cpp ]
[ compile-fail optional_test_fail3a.cpp ]
[ compile-fail optional_test_fail3b.cpp ]
diff --git a/test/optional_test_equals_none.cpp b/test/optional_test_equals_none.cpp
new file mode 100644
index 0000000..aed7771
--- /dev/null
+++ b/test/optional_test_equals_none.cpp
@@ -0,0 +1,68 @@
+// Copyright (C) 2014 Andrzej Krzemienski.
+//
+// Use, modification, and distribution is subject to 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)
+//
+// See http://www.boost.org/lib/optional for documentation.
+//
+// You are welcome to contact the author at:
+// akrzemi1@gmail.com
+//
+// Revisions:
+//
+#include
+#include
+#include
+
+#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"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#include "boost/none.hpp"
+
+#include "boost/test/minimal.hpp"
+
+#include "optional_test_common.cpp"
+
+struct SemiRegular // no operator==
+{
+private: void operator==(SemiRegular const&) const {}
+private: void operator!=(SemiRegular const&) const {}
+};
+
+void test_equal_to_none_of_noncomparable_T()
+{
+ optional i = SemiRegular();
+ optional o;
+
+ BOOST_CHECK(i != boost::none);
+ BOOST_CHECK(boost::none != i);
+ BOOST_CHECK(o == boost::none);
+ BOOST_CHECK(boost::none == o);
+}
+
+int test_main( int, char* [] )
+{
+ try
+ {
+ test_equal_to_none_of_noncomparable_T();
+
+ }
+ catch ( ... )
+ {
+ BOOST_ERROR("Unexpected Exception caught!");
+ }
+
+ return 0;
+}
+
+