diff --git a/doc/html/boost_optional/tutorial/relational_operators.html b/doc/html/boost_optional/tutorial/relational_operators.html
index bc97e7b..683fedc 100644
--- a/doc/html/boost_optional/tutorial/relational_operators.html
+++ b/doc/html/boost_optional/tutorial/relational_operators.html
@@ -30,7 +30,7 @@
Type optional<T>
is
EqualityComparable
whenever T
is EqualityComparable
. Two optional
- objects containing a value compare in the same as their contained values.
+ objects containing a value compare in the same way as their contained values.
The uninitialized state of optional<T>
is treated as a distinct value, equal to itself, and unequal to any value
of type T
:
diff --git a/doc/html/index.html b/doc/html/index.html
index 3e4f671..5826320 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -108,8 +108,9 @@
It is possible that this parameter is not specified; such situation is no error.
It is valid to not specify the parameter and in that case the program is supposed
to behave slightly differently. Also, suppose that any possible value of type
- int
is a valid value for "MaxValue"
, so we cannot jut use -1
to represent
- the absence of the parameter in the config file.
+ int
is a valid value for "MaxValue"
, so we cannot just use
+ -1
+ to represent the absence of the parameter in the config file.
@@ -133,7 +134,7 @@
-Last revised: September 12, 2014 at 09:54:26 GMT |
+Last revised: November 21, 2014 at 23:32:40 GMT |
|
diff --git a/include/boost/none.hpp b/include/boost/none.hpp
index e9fc062..87a6c70 100644
--- a/include/boost/none.hpp
+++ b/include/boost/none.hpp
@@ -1,4 +1,5 @@
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
+// Copyright (C) 2014 Andrzej Krzemienski.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -20,7 +21,31 @@
namespace boost {
+#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
none_t const none = (static_cast(0)) ;
+#else
+
+namespace detail { namespace optional_detail {
+
+ // the trick here is to make boost::none defined once as a global but in a header file
+ template
+ struct none_instance
+ {
+ static const T instance;
+ };
+
+ template
+ const T none_instance::instance = T(); // global, but because 'tis a template, no cpp file required
+
+} } // namespace detail::optional_detail
+
+
+namespace {
+ // TU-local
+ const none_t& none = detail::optional_detail::none_instance::instance;
+}
+
+#endif
} // namespace boost
diff --git a/include/boost/none_t.hpp b/include/boost/none_t.hpp
index 63ad926..13ce455 100644
--- a/include/boost/none_t.hpp
+++ b/include/boost/none_t.hpp
@@ -1,4 +1,5 @@
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
+// 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
@@ -14,9 +15,12 @@
namespace boost {
+#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
namespace detail { struct none_helper{}; }
-
typedef int detail::none_helper::*none_t ;
+#else
+class none_t {};
+#endif
} // namespace boost
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index aeb0900..aeaef2b 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -41,6 +41,7 @@ import testing ;
[ compile-fail optional_test_ref_fail_init_from_Urefref.cpp ]
[ compile-fail optional_test_ref_fail_assign_from_Trefref.cpp ]
[ compile-fail optional_test_ref_fail_assign_from_Urefref.cpp ]
+ [ compile-fail optional_test_fail_convert_from_null.cpp ]
[ compile-fail optional_test_fail_explicit_convert_in_value_or.cpp ]
[ compile-fail optional_test_fail_explicit_convert_in_value_or_call.cpp ]
;
diff --git a/test/optional_test_common.cpp b/test/optional_test_common.cpp
index 532b74e..a527bd7 100644
--- a/test/optional_test_common.cpp
+++ b/test/optional_test_common.cpp
@@ -51,6 +51,8 @@ using boost::get_pointer ;
// via the safe_bool operator.
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1300) ) // 1300 == VC++ 7.1
#define BOOST_OPTIONAL_NO_NULL_COMPARE
+#else
+#define BOOST_OPTIONAL_NO_NULL_COMPARE // Andrzej: I also disable 0 comparison everywhere
#endif
#define ARG(T) (static_cast< T const* >(0))
diff --git a/test/optional_test_fail_convert_from_null.cpp b/test/optional_test_fail_convert_from_null.cpp
new file mode 100644
index 0000000..a454615
--- /dev/null
+++ b/test/optional_test_fail_convert_from_null.cpp
@@ -0,0 +1,25 @@
+// 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
+//
+#include "boost/optional.hpp"
+
+//
+// THIS TEST SHOULD FAIL TO COMPILE
+//
+
+struct NoInitFromNull{};
+
+void test_conversion_from_null()
+{
+ boost::optional opt = 0;
+}
+
+