From 5182f7f30fad87023ae5e5a4e1f660fb513fb469 Mon Sep 17 00:00:00 2001
From: Andrzej Krzemienski
Date: Sat, 24 Mar 2018 00:04:15 +0100
Subject: [PATCH] Added has_value()
---
doc/27_ref_optional_synopsis.qbk | 4 ++
doc/28_ref_optional_semantics.qbk | 2 +
doc/91_relnotes.qbk | 5 +++
doc/html/boost_optional/acknowledgements.html | 2 +-
.../dependencies_and_portability.html | 2 +-
...emplace_operations_in_older_compilers.html | 2 +-
.../optional_reference_binding.html | 2 +-
doc/html/boost_optional/quick_start.html | 2 +-
...sing_unnecessary_default_construction.html | 2 +-
.../optional_automatic_variables.html | 2 +-
.../quick_start/optional_data_members.html | 2 +-
.../quick_start/storage_in_containers.html | 2 +-
...ost_optional_bad_optional_access_hpp_.html | 2 +-
.../detailed_semantics.html | 2 +-
.../header__boost_optional_hpp_.html | 2 +-
...der__boost_optional_optional_fwd_hpp_.html | 2 +-
.../detailed_semantics___free_functions.html | 2 +-
...ailed_semantics___optional_references.html | 5 ++-
.../detailed_semantics___optional_values.html | 5 ++-
.../header_optional_in_place_init.html | 2 +-
.../header_optional_optional_refs.html | 4 +-
.../header_optional_optional_values.html | 4 +-
.../boost_optional/reference/io_header.html | 2 +-
.../reference/io_header/io_semantics.html | 2 +-
doc/html/boost_optional/relnotes.html | 41 +++++++++++++++----
.../tutorial/design_overview.html | 2 +-
.../design_overview/the_interface.html | 2 +-
.../design_overview/the_semantics.html | 2 +-
.../tutorial/exception_safety_guarantees.html | 2 +-
doc/html/boost_optional/tutorial/gotchas.html | 2 +-
...e_positive_with__wmaybe_uninitialized.html | 2 +-
.../gotchas/mixed_relational_comparisons.html | 2 +-
.../gotchas/moved_from__optional_.html | 2 +-
.../tutorial/in_place_factories.html | 2 +-
.../boost_optional/tutorial/io_operators.html | 2 +-
.../tutorial/optional_references.html | 2 +-
...for_assignment_of_optional_references.html | 2 +-
.../tutorial/performance_considerations.html | 15 +++----
.../tutorial/relational_operators.html | 2 +-
.../tutorial/type_requirements.html | 2 +-
.../tutorial/when_to_use_optional.html | 2 +-
doc/html/index.html | 4 +-
doc/html/optional/reference.html | 2 +-
.../header__boost_optional_optional_hpp_.html | 2 +-
doc/html/optional/tutorial.html | 2 +-
.../detail/optional_reference_spec.hpp | 1 +
include/boost/optional/optional.hpp | 4 +-
test/optional_test.cpp | 2 +-
...st_common.cpp => optional_test_common.hpp} | 12 ++++++
49 files changed, 119 insertions(+), 59 deletions(-)
rename test/{optional_test_common.cpp => optional_test_common.hpp} (94%)
diff --git a/doc/27_ref_optional_synopsis.qbk b/doc/27_ref_optional_synopsis.qbk
index f93076e..1a6a849 100644
--- a/doc/27_ref_optional_synopsis.qbk
+++ b/doc/27_ref_optional_synopsis.qbk
@@ -182,6 +182,8 @@ They are empty, trivially copyable classes with disabled default constructor.
T const* get_ptr() const ; ``[link reference_optional_get_ptr __GO_TO__]``
T* get_ptr() ; ``[link reference_optional_get_ptr __GO_TO__]``
+ bool has_value() const noexcept ; ``[link reference_optional_operator_bool __GO_TO__]``
+
explicit operator bool() const noexcept ; ``[link reference_optional_operator_bool __GO_TO__]``
bool operator!() const noexcept ; ``[link reference_optional_operator_not __GO_TO__]``
@@ -256,6 +258,8 @@ They are empty, trivially copyable classes with disabled default constructor.
T* get_ptr() const noexcept ; ``[link reference_optional_ref_get_ptr __GO_TO__]``
+ bool has_value() const noexcept ; ``[link reference_optional_ref_operator_bool __GO_TO__]``
+
explicit operator bool() const noexcept ; ``[link reference_optional_ref_operator_bool __GO_TO__]``
bool operator!() const noexcept ; ``[link reference_optional_ref_operator_not __GO_TO__]``
diff --git a/doc/28_ref_optional_semantics.qbk b/doc/28_ref_optional_semantics.qbk
index 7e2740c..8c1397f 100644
--- a/doc/28_ref_optional_semantics.qbk
+++ b/doc/28_ref_optional_semantics.qbk
@@ -754,6 +754,7 @@ __SPACE__
[#reference_optional_operator_bool]
[: `explicit optional::operator bool() const noexcept ;`]
+[: `bool optional::has_value() const noexcept ;`]
* [*Returns:] `get_ptr() != 0`.
* [*Notes:] On compilers that do not support explicit conversion operators this falls back to safe-bool idiom.
@@ -1040,6 +1041,7 @@ __SPACE__
__SPACE__
[#reference_optional_ref_operator_bool]
+[: `bool has_value() const noexcept;`]
[: `optional::operator bool () const noexcept;`]
* [*Returns:] `bool(ref)`.
diff --git a/doc/91_relnotes.qbk b/doc/91_relnotes.qbk
index d34861b..93e9799 100644
--- a/doc/91_relnotes.qbk
+++ b/doc/91_relnotes.qbk
@@ -11,6 +11,11 @@
[section:relnotes Release Notes]
+[heading Boost Release 1.68]
+
+* Added member function `has_value()` for compatibility with `std::optional` ([@https://github.com/boostorg/optional/issues/52 issue #52]).
+
+
[heading Boost Release 1.67]
* Fixed [@https://github.com/boostorg/optional/issues/46 issue #46].
diff --git a/doc/html/boost_optional/acknowledgements.html b/doc/html/boost_optional/acknowledgements.html
index 9d07002..f91a9f2 100644
--- a/doc/html/boost_optional/acknowledgements.html
+++ b/doc/html/boost_optional/acknowledgements.html
@@ -3,7 +3,7 @@
Acknowledgements
-
+
diff --git a/doc/html/boost_optional/dependencies_and_portability.html b/doc/html/boost_optional/dependencies_and_portability.html
index 24d0038..ca54b86 100644
--- a/doc/html/boost_optional/dependencies_and_portability.html
+++ b/doc/html/boost_optional/dependencies_and_portability.html
@@ -3,7 +3,7 @@
Dependencies and Portability
-
+
diff --git a/doc/html/boost_optional/dependencies_and_portability/emplace_operations_in_older_compilers.html b/doc/html/boost_optional/dependencies_and_portability/emplace_operations_in_older_compilers.html
index 2354e2e..afa139f 100644
--- a/doc/html/boost_optional/dependencies_and_portability/emplace_operations_in_older_compilers.html
+++ b/doc/html/boost_optional/dependencies_and_portability/emplace_operations_in_older_compilers.html
@@ -3,7 +3,7 @@
Emplace operations in older compilers
-
+
diff --git a/doc/html/boost_optional/dependencies_and_portability/optional_reference_binding.html b/doc/html/boost_optional/dependencies_and_portability/optional_reference_binding.html
index cffa160..9038cb2 100644
--- a/doc/html/boost_optional/dependencies_and_portability/optional_reference_binding.html
+++ b/doc/html/boost_optional/dependencies_and_portability/optional_reference_binding.html
@@ -3,7 +3,7 @@
Optional Reference Binding
-
+
diff --git a/doc/html/boost_optional/quick_start.html b/doc/html/boost_optional/quick_start.html
index d7dde63..18ea040 100644
--- a/doc/html/boost_optional/quick_start.html
+++ b/doc/html/boost_optional/quick_start.html
@@ -3,7 +3,7 @@
Quick Start
-
+
diff --git a/doc/html/boost_optional/quick_start/bypassing_unnecessary_default_construction.html b/doc/html/boost_optional/quick_start/bypassing_unnecessary_default_construction.html
index 7ccdb1b..2b38395 100644
--- a/doc/html/boost_optional/quick_start/bypassing_unnecessary_default_construction.html
+++ b/doc/html/boost_optional/quick_start/bypassing_unnecessary_default_construction.html
@@ -3,7 +3,7 @@
Bypassing unnecessary default construction
-
+
diff --git a/doc/html/boost_optional/quick_start/optional_automatic_variables.html b/doc/html/boost_optional/quick_start/optional_automatic_variables.html
index e135be1..b292f0a 100644
--- a/doc/html/boost_optional/quick_start/optional_automatic_variables.html
+++ b/doc/html/boost_optional/quick_start/optional_automatic_variables.html
@@ -3,7 +3,7 @@
Optional automatic variables
-
+
diff --git a/doc/html/boost_optional/quick_start/optional_data_members.html b/doc/html/boost_optional/quick_start/optional_data_members.html
index 93682f8..8402401 100644
--- a/doc/html/boost_optional/quick_start/optional_data_members.html
+++ b/doc/html/boost_optional/quick_start/optional_data_members.html
@@ -3,7 +3,7 @@
Optional data members
-
+
diff --git a/doc/html/boost_optional/quick_start/storage_in_containers.html b/doc/html/boost_optional/quick_start/storage_in_containers.html
index 4861178..36e3191 100644
--- a/doc/html/boost_optional/quick_start/storage_in_containers.html
+++ b/doc/html/boost_optional/quick_start/storage_in_containers.html
@@ -3,7 +3,7 @@
Storage in containers
-
+
diff --git a/doc/html/boost_optional/reference/header__boost_optional_bad_optional_access_hpp_.html b/doc/html/boost_optional/reference/header__boost_optional_bad_optional_access_hpp_.html
index 4269965..56d43fc 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_bad_optional_access_hpp_.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_bad_optional_access_hpp_.html
@@ -3,7 +3,7 @@
Header <boost/optional/bad_optional_access.hpp>
-
+
diff --git a/doc/html/boost_optional/reference/header__boost_optional_bad_optional_access_hpp_/detailed_semantics.html b/doc/html/boost_optional/reference/header__boost_optional_bad_optional_access_hpp_/detailed_semantics.html
index ba66f61..e85abc9 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_bad_optional_access_hpp_/detailed_semantics.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_bad_optional_access_hpp_/detailed_semantics.html
@@ -3,7 +3,7 @@
Detailed semantics
-
+
diff --git a/doc/html/boost_optional/reference/header__boost_optional_hpp_.html b/doc/html/boost_optional/reference/header__boost_optional_hpp_.html
index 2a81a82..f3a3649 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_hpp_.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_hpp_.html
@@ -3,7 +3,7 @@
Header <boost/optional.hpp>
-
+
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_fwd_hpp_.html b/doc/html/boost_optional/reference/header__boost_optional_optional_fwd_hpp_.html
index f053e06..96f41a2 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_fwd_hpp_.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_fwd_hpp_.html
@@ -3,7 +3,7 @@
Header <boost/optional/optional_fwd.hpp>
-
+
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html
index 1a48614..5b0780b 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html
@@ -3,7 +3,7 @@
Detailed Semantics - Free Functions
-
+
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html
index ffe1733..4400216 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html
@@ -3,7 +3,7 @@
Detailed Semantics - Optional References
-
+
@@ -422,6 +422,9 @@
+ bool has_value () const noexcept ;
+
+
optional < T &>:: operator bool
() const
noexcept ;
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html
index b18c618..fd94a67 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html
@@ -3,7 +3,7 @@
Detailed Semantics - Optional Values
-
+
@@ -1592,6 +1592,9 @@
const noexcept
;
+
+ bool optional < T >:: has_value () const noexcept ;
+
Returns: get_ptr () != 0
.
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_in_place_init.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_in_place_init.html
index 8f1560e..d94a2b2 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_in_place_init.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_in_place_init.html
@@ -3,7 +3,7 @@
Initialization tags
-
+
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html
index ee518a4..f02cdb5 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html
@@ -3,7 +3,7 @@
Optional References
-
+
@@ -75,6 +75,8 @@
T * get_ptr () const noexcept ;
+ bool has_value () const noexcept ;
+
explicit operator bool () const noexcept ;
bool operator !() const noexcept ;
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html
index 172da40..7780abd 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html
@@ -3,7 +3,7 @@
Optional Values
-
+
@@ -108,6 +108,8 @@
T const * get_ptr () const ;
T * get_ptr () ;
+ bool has_value () const noexcept ;
+
explicit operator bool () const noexcept ;
bool operator !() const noexcept ;
diff --git a/doc/html/boost_optional/reference/io_header.html b/doc/html/boost_optional/reference/io_header.html
index 675e598..78bcfd9 100644
--- a/doc/html/boost_optional/reference/io_header.html
+++ b/doc/html/boost_optional/reference/io_header.html
@@ -3,7 +3,7 @@
Header <boost/optional/optional_io.hpp>
-
+
diff --git a/doc/html/boost_optional/reference/io_header/io_semantics.html b/doc/html/boost_optional/reference/io_header/io_semantics.html
index d286c9d..13b7477 100644
--- a/doc/html/boost_optional/reference/io_header/io_semantics.html
+++ b/doc/html/boost_optional/reference/io_header/io_semantics.html
@@ -3,7 +3,7 @@
Detailed semantics
-
+
diff --git a/doc/html/boost_optional/relnotes.html b/doc/html/boost_optional/relnotes.html
index 9881def..7eb48e0 100644
--- a/doc/html/boost_optional/relnotes.html
+++ b/doc/html/boost_optional/relnotes.html
@@ -3,7 +3,7 @@
Release Notes
-
+
@@ -28,6 +28,29 @@
+
+ Added member function has_value ()
for compatibility with std :: optional
(issue
+ #52 ).
+
+
+
+
+ Fixed issue
+ #46 .
+
+
+ Fixed - Wzero - as - null - pointer - constant
warnings.
+
+
+
@@ -45,7 +68,7 @@
@@ -69,7 +92,7 @@
@@ -77,7 +100,7 @@
Fixed Trac #12179 .
@@ -120,7 +143,7 @@
@@ -131,7 +154,7 @@
#11203.
@@ -145,7 +168,7 @@
@@ -181,7 +204,7 @@
@@ -191,7 +214,7 @@
to fix C++03 compile error on logic_error ( "..." )
".
diff --git a/doc/html/boost_optional/tutorial/design_overview.html b/doc/html/boost_optional/tutorial/design_overview.html
index 5d2a7a0..fe959b6 100644
--- a/doc/html/boost_optional/tutorial/design_overview.html
+++ b/doc/html/boost_optional/tutorial/design_overview.html
@@ -3,7 +3,7 @@
Design Overview
-
+
diff --git a/doc/html/boost_optional/tutorial/design_overview/the_interface.html b/doc/html/boost_optional/tutorial/design_overview/the_interface.html
index 6b860a7..5c7d153 100644
--- a/doc/html/boost_optional/tutorial/design_overview/the_interface.html
+++ b/doc/html/boost_optional/tutorial/design_overview/the_interface.html
@@ -3,7 +3,7 @@
The Interface
-
+
diff --git a/doc/html/boost_optional/tutorial/design_overview/the_semantics.html b/doc/html/boost_optional/tutorial/design_overview/the_semantics.html
index d84118a..cdbd9e6 100644
--- a/doc/html/boost_optional/tutorial/design_overview/the_semantics.html
+++ b/doc/html/boost_optional/tutorial/design_overview/the_semantics.html
@@ -3,7 +3,7 @@
The semantics
-
+
diff --git a/doc/html/boost_optional/tutorial/exception_safety_guarantees.html b/doc/html/boost_optional/tutorial/exception_safety_guarantees.html
index 925eca6..6d57a52 100644
--- a/doc/html/boost_optional/tutorial/exception_safety_guarantees.html
+++ b/doc/html/boost_optional/tutorial/exception_safety_guarantees.html
@@ -3,7 +3,7 @@
Exception Safety Guarantees
-
+
diff --git a/doc/html/boost_optional/tutorial/gotchas.html b/doc/html/boost_optional/tutorial/gotchas.html
index fab4d53..45c9435 100644
--- a/doc/html/boost_optional/tutorial/gotchas.html
+++ b/doc/html/boost_optional/tutorial/gotchas.html
@@ -3,7 +3,7 @@
Gotchas
-
+
diff --git a/doc/html/boost_optional/tutorial/gotchas/false_positive_with__wmaybe_uninitialized.html b/doc/html/boost_optional/tutorial/gotchas/false_positive_with__wmaybe_uninitialized.html
index 299b211..2352db7 100644
--- a/doc/html/boost_optional/tutorial/gotchas/false_positive_with__wmaybe_uninitialized.html
+++ b/doc/html/boost_optional/tutorial/gotchas/false_positive_with__wmaybe_uninitialized.html
@@ -3,7 +3,7 @@
False positive with -Wmaybe-uninitialized
-
+
diff --git a/doc/html/boost_optional/tutorial/gotchas/mixed_relational_comparisons.html b/doc/html/boost_optional/tutorial/gotchas/mixed_relational_comparisons.html
index a0c4eb0..187e457 100644
--- a/doc/html/boost_optional/tutorial/gotchas/mixed_relational_comparisons.html
+++ b/doc/html/boost_optional/tutorial/gotchas/mixed_relational_comparisons.html
@@ -3,7 +3,7 @@
Mixed relational comparisons
-
+
diff --git a/doc/html/boost_optional/tutorial/gotchas/moved_from__optional_.html b/doc/html/boost_optional/tutorial/gotchas/moved_from__optional_.html
index 2be1f77..0e1b772 100644
--- a/doc/html/boost_optional/tutorial/gotchas/moved_from__optional_.html
+++ b/doc/html/boost_optional/tutorial/gotchas/moved_from__optional_.html
@@ -3,7 +3,7 @@
Moved-from optional
-
+
diff --git a/doc/html/boost_optional/tutorial/in_place_factories.html b/doc/html/boost_optional/tutorial/in_place_factories.html
index 1f4e145..f00e5ed 100644
--- a/doc/html/boost_optional/tutorial/in_place_factories.html
+++ b/doc/html/boost_optional/tutorial/in_place_factories.html
@@ -3,7 +3,7 @@
In-Place Factories
-
+
diff --git a/doc/html/boost_optional/tutorial/io_operators.html b/doc/html/boost_optional/tutorial/io_operators.html
index 874f5ac..bbfc1f7 100644
--- a/doc/html/boost_optional/tutorial/io_operators.html
+++ b/doc/html/boost_optional/tutorial/io_operators.html
@@ -3,7 +3,7 @@
IO operators
-
+
diff --git a/doc/html/boost_optional/tutorial/optional_references.html b/doc/html/boost_optional/tutorial/optional_references.html
index 702733c..417ff36 100644
--- a/doc/html/boost_optional/tutorial/optional_references.html
+++ b/doc/html/boost_optional/tutorial/optional_references.html
@@ -3,7 +3,7 @@
Optional references
-
+
diff --git a/doc/html/boost_optional/tutorial/optional_references/rebinding_semantics_for_assignment_of_optional_references.html b/doc/html/boost_optional/tutorial/optional_references/rebinding_semantics_for_assignment_of_optional_references.html
index 219fd61..f12fb59 100644
--- a/doc/html/boost_optional/tutorial/optional_references/rebinding_semantics_for_assignment_of_optional_references.html
+++ b/doc/html/boost_optional/tutorial/optional_references/rebinding_semantics_for_assignment_of_optional_references.html
@@ -3,7 +3,7 @@
Rebinding semantics for assignment of optional references
-
+
diff --git a/doc/html/boost_optional/tutorial/performance_considerations.html b/doc/html/boost_optional/tutorial/performance_considerations.html
index f54e49e..6a6667d 100644
--- a/doc/html/boost_optional/tutorial/performance_considerations.html
+++ b/doc/html/boost_optional/tutorial/performance_considerations.html
@@ -3,7 +3,7 @@
Performance considerations
-
+
@@ -56,12 +56,13 @@
We call it a direct storage. This makes optional < T >
a
trivially-copyable type for scalar T
s.
- This only works for compilers that support defaulted functions. On compilers
- without defaulted functions we still use the direct storage, but optional < T >
is
- no longer recognized as trivially-copyable. Apart from scalar types, we leave
- the programmer a way of customizing her type, so that it is reconized by
- optional
as candidate for
- optimized storage, by specializing type trait boost :: opitonal_config :: optional_uses_direct_storage_for
:
+ This only works for compilers that support defaulted functions (including
+ defaulted move assignment and constructor). On compilers without defaulted
+ functions we still use the direct storage, but optional < T >
+ is no longer recognized as trivially-copyable. Apart from scalar types, we
+ leave the programmer a way of customizing her type, so that it is reconized
+ by optional
as candidate
+ for optimized storage, by specializing type trait boost :: opitonal_config :: optional_uses_direct_storage_for
:
struct X
{
diff --git a/doc/html/boost_optional/tutorial/relational_operators.html b/doc/html/boost_optional/tutorial/relational_operators.html
index 744120d..8aa9234 100644
--- a/doc/html/boost_optional/tutorial/relational_operators.html
+++ b/doc/html/boost_optional/tutorial/relational_operators.html
@@ -3,7 +3,7 @@
Relational operators
-
+
diff --git a/doc/html/boost_optional/tutorial/type_requirements.html b/doc/html/boost_optional/tutorial/type_requirements.html
index 8a9eb7f..191f5fe 100644
--- a/doc/html/boost_optional/tutorial/type_requirements.html
+++ b/doc/html/boost_optional/tutorial/type_requirements.html
@@ -3,7 +3,7 @@
Type requirements
-
+
diff --git a/doc/html/boost_optional/tutorial/when_to_use_optional.html b/doc/html/boost_optional/tutorial/when_to_use_optional.html
index 675bd3f..b56a8c0 100644
--- a/doc/html/boost_optional/tutorial/when_to_use_optional.html
+++ b/doc/html/boost_optional/tutorial/when_to_use_optional.html
@@ -3,7 +3,7 @@
When to use Optional
-
+
diff --git a/doc/html/index.html b/doc/html/index.html
index 1429a21..b9ec32a 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -3,7 +3,7 @@
Boost.Optional
-
+
@@ -146,7 +146,7 @@
-Last revised: May 17, 2017 at 23:01:39 GMT
+Last revised: March 23, 2018 at 23:01:17 GMT
diff --git a/doc/html/optional/reference.html b/doc/html/optional/reference.html
index fe13339..da63269 100644
--- a/doc/html/optional/reference.html
+++ b/doc/html/optional/reference.html
@@ -3,7 +3,7 @@
Reference
-
+
diff --git a/doc/html/optional/reference/header__boost_optional_optional_hpp_.html b/doc/html/optional/reference/header__boost_optional_optional_hpp_.html
index 24626e3..fdfb029 100644
--- a/doc/html/optional/reference/header__boost_optional_optional_hpp_.html
+++ b/doc/html/optional/reference/header__boost_optional_optional_hpp_.html
@@ -3,7 +3,7 @@
Header <boost/optional/optional.hpp>
-
+
diff --git a/doc/html/optional/tutorial.html b/doc/html/optional/tutorial.html
index b3260b9..6d1122b 100644
--- a/doc/html/optional/tutorial.html
+++ b/doc/html/optional/tutorial.html
@@ -3,7 +3,7 @@
Tutorial
-
+
diff --git a/include/boost/optional/detail/optional_reference_spec.hpp b/include/boost/optional/detail/optional_reference_spec.hpp
index 012e91a..8e9974c 100644
--- a/include/boost/optional/detail/optional_reference_spec.hpp
+++ b/include/boost/optional/detail/optional_reference_spec.hpp
@@ -159,6 +159,7 @@ public:
void reset() BOOST_NOEXCEPT { ptr_ = 0; }
bool is_initialized() const BOOST_NOEXCEPT { return ptr_ != 0; }
+ bool has_value() const BOOST_NOEXCEPT { return ptr_ != 0; }
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp
index 74ef49c..17c8f89 100644
--- a/include/boost/optional/optional.hpp
+++ b/include/boost/optional/optional.hpp
@@ -375,7 +375,7 @@ class optional_base : public optional_tag
pointer_const_type get_ptr() const { return m_initialized ? get_ptr_impl() : 0 ; }
pointer_type get_ptr() { return m_initialized ? get_ptr_impl() : 0 ; }
- bool is_initialized() const { return m_initialized ; }
+ bool is_initialized() const BOOST_NOEXCEPT { return m_initialized ; }
protected :
@@ -1333,6 +1333,8 @@ class optional
}
#endif
+ bool has_value() const BOOST_NOEXCEPT { return this->is_initialized() ; }
+
bool operator!() const BOOST_NOEXCEPT { return !this->is_initialized() ; }
BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
diff --git a/test/optional_test.cpp b/test/optional_test.cpp
index 017d4ff..3354430 100644
--- a/test/optional_test.cpp
+++ b/test/optional_test.cpp
@@ -32,7 +32,7 @@
#include "boost/core/lightweight_test.hpp"
-#include "optional_test_common.cpp"
+#include "optional_test_common.hpp"
void test_implicit_construction ( optional opt, double v, double z )
{
diff --git a/test/optional_test_common.cpp b/test/optional_test_common.hpp
similarity index 94%
rename from test/optional_test_common.cpp
rename to test/optional_test_common.hpp
index acb935c..943e646 100644
--- a/test/optional_test_common.cpp
+++ b/test/optional_test_common.hpp
@@ -194,6 +194,9 @@ inline void check_uninitialized_const ( optional const& opt )
BOOST_TEST( !opt ) ;
BOOST_TEST( !get_pointer(opt) ) ;
BOOST_TEST( !opt.get_ptr() ) ;
+ BOOST_TEST( !opt.has_value() ) ;
+ BOOST_TEST( !opt.is_initialized() ) ;
+ BOOST_TEST( opt == boost::none ) ;
}
template
inline void check_uninitialized ( optional& opt )
@@ -204,6 +207,9 @@ inline void check_uninitialized ( optional& opt )
BOOST_TEST( !opt ) ;
BOOST_TEST( !get_pointer(opt) ) ;
BOOST_TEST( !opt.get_ptr() ) ;
+ BOOST_TEST( !opt.has_value() ) ;
+ BOOST_TEST( !opt.is_initialized() ) ;
+ BOOST_TEST( opt == boost::none ) ;
check_uninitialized_const(opt);
}
@@ -220,6 +226,9 @@ inline void check_initialized_const ( optional const& opt )
BOOST_TEST ( !!opt ) ;
BOOST_TEST ( get_pointer(opt) ) ;
BOOST_TEST ( opt.get_ptr() ) ;
+ BOOST_TEST ( opt.has_value() ) ;
+ BOOST_TEST ( opt.is_initialized() ) ;
+ BOOST_TEST ( opt != boost::none ) ;
}
template
@@ -234,6 +243,9 @@ inline void check_initialized ( optional& opt )
BOOST_TEST ( !!opt ) ;
BOOST_TEST ( get_pointer(opt) ) ;
BOOST_TEST ( opt.get_ptr() ) ;
+ BOOST_TEST ( opt.has_value() ) ;
+ BOOST_TEST ( opt.is_initialized() ) ;
+ BOOST_TEST ( opt != boost::none ) ;
check_initialized_const(opt);
}