Compare commits

...

127 Commits

Author SHA1 Message Date
a119c02c03 glob headers 2022-07-05 10:48:26 +02:00
5188c31f9d Rework as esp-idf component 2022-07-04 20:17:21 +02:00
938806c876 relnotes: info about breaking change 2022-06-22 22:56:45 +02:00
85ebe0a2ed fix hash spec for C++17 2022-06-19 23:57:15 +02:00
ce5834add2 further docs fixes 2022-05-23 22:42:04 +02:00
a514ce627d fix docs build 2022-05-23 22:32:36 +02:00
ec677383dc Added docs for std::hash
But I do not know if they copile with QuickBook.
2022-05-23 21:00:00 +02:00
52abe4842e Add std::hash specialization 2022-05-21 01:13:10 +02:00
6117d08d79 Merge pull request #102 from glywk/develop
Update typography
2022-03-07 14:49:23 +01:00
916ca23572 Update typography 2022-03-07 13:55:57 +01:00
c300a8c517 Merge pull request #100 from boostorg/pr/aligned-storage-fix
Change aligned_storage::dummy::data to unsigned char[]
2022-03-01 16:17:09 -03:00
4f713acdf8 Merge pull request #101 from boostorg/pr/unqualified-value-type
Construct the unqualified value_type with placement new
2022-03-01 16:07:44 -03:00
1e6f838a90 added missing license info in one file 2022-02-26 14:15:28 +01:00
51b7053abf Construct the unqualified value_type with placement new 2022-02-18 22:03:05 +02:00
ec96129e9e Change aligned_storage::dummy::data to unsigned char[] 2022-02-18 21:55:13 +02:00
8e86559103 Fix convert-assign tests for C++98 2021-12-22 10:36:40 +01:00
56568445b9 Fix tests on C++03 2021-12-09 22:22:05 +01:00
7dd512a019 Fix issue #98 2021-11-20 02:00:30 +01:00
21253ea63a Merge pull request #93 from sdarwin/feature/gha_fix_1
Update GitHub Actions CI file
2021-08-03 16:07:09 +02:00
14d43d2e6e Update GitHub Actions CI file 2021-07-30 16:10:11 +00:00
0b159febf8 Update CMakeLists.txt 2021-06-10 00:53:07 +03:00
d0ab8004c0 Add support for BOOST_NO_IOSTREAM 2021-05-19 23:29:10 +02:00
a70c51eed1 Merge pull request #91 from sdarwin/githubactions
GitHub Actions config
2021-03-03 16:13:06 +01:00
9c9ff5e376 Add GitHub Actions config [ci skip] 2021-03-03 14:56:21 +00:00
708db7fe9a Merge pull request #88 from sdarwin/drone
Drone config
2021-01-21 21:18:22 +01:00
27971d8b11 add drone config [ci skip] 2021-01-21 19:42:29 +00:00
97da91f665 Merge pull request #89 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-21 19:50:03 +01:00
4a1a9c9cdd [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-20 23:02:52 -05:00
71feb7961b Merge branch 'gieseanw-patch-1' into develop 2020-12-19 00:00:58 +01:00
ead529af54 Address unreachable code warning
In MSVC optional<T&>::value() emits a warning C4702: unreachable code because throw_exception is marked BOOST_RETURN.
Otherwise the ternary code might have been preferable.
This change addresses the warning while preserving the functionality. It replicates optional<T>::value() for consistency.
2020-12-19 00:00:18 +01:00
a7f49cbec8 Merge branch 'citrusmoose-make_none_t_literal_type' into develop 2020-10-24 17:18:22 +02:00
7e0b8145b5 boost::none is constexpr-declared 2020-10-24 17:17:10 +02:00
2b08711ec6 Merge branch 'make_none_t_literal_type' of https://github.com/citrusmoose/optional into citrusmoose-make_none_t_literal_type 2020-10-24 17:05:51 +02:00
88e7d55bbc Merge pull request #85 from giomasce-throwaway/develop
Fix funny mistake in copyright headers.
2020-10-09 16:28:33 +02:00
9de55e6ffd Fix funny mistake in copyright headers. 2020-10-09 15:35:58 +02:00
409a225afe Merge pull request #84 from mbs-c/develop
Add explicit <string> include to make tests compile with MSVC
2020-08-11 16:11:59 +02:00
db5e156ebc Add explicit <string> include to make tests compile with MSVC 2020-08-11 10:36:12 +02:00
aeac95857e Merge branch 'eldiener-develop' into develop 2020-05-07 18:06:07 +02:00
d5b7791710 Merge branch 'develop' of https://github.com/eldiener/optional into cppbuilder 2020-04-17 05:55:24 -04:00
19b94c01f3 added release notes 2020-04-09 01:12:22 +02:00
404f40bcc1 Merge branch 'RobertLeahy-develop' into develop 2020-04-06 00:43:05 +02:00
9b1f8033eb Merge branch 'develop' of https://github.com/RobertLeahy/optional-2 into RobertLeahy-develop 2020-04-06 00:42:05 +02:00
e52d7d4a9e Merge branch 'Kojoley-suppress-weak-vtables-warning' into develop 2020-04-05 23:47:19 +02:00
ed9edd54e4 Merge branch 'suppress-weak-vtables-warning' of https://github.com/Kojoley/optional into Kojoley-suppress-weak-vtables-warning 2020-04-05 23:30:40 +02:00
78d6563bce Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. 2020-03-30 14:04:35 -04:00
d4a4a5b6ad fixed C++98-incompatible unit test 2020-01-16 22:31:23 +01:00
9581804efa GCC 4.4.7: boost::in_place & Assignment
Assigning a boost::in_place_factory to a boost::optional templated on a
type which was trivially copyable failed to compile under GCC 4.4.7.
2019-12-23 11:24:39 -05:00
d07ae78901 Tests Pass in GCC 4.4.7
Several tests either did not compile or failed upon running when using
GCC 4.4.7.
2019-12-23 11:24:39 -05:00
683dbe2412 .travis.yml: Specify Trusty for Trusty Addons
Previously .travis.yml didn't specify dist: trusty when using addons
which were specifically for Trusty. This led to the Clang 5 build
failing when trying to install Clang 5.
2019-12-23 11:24:39 -05:00
010ee00604 Update release notes 2019-12-20 00:30:37 +01:00
13bc27698e Add test case for fix to issue #78 2019-12-20 00:18:52 +01:00
0481b05d1f Merge branch 'cxx20_fix' of https://github.com/CaseyCarter/optional into CaseyCarter-cxx20_fix 2019-12-19 20:56:34 +01:00
4c863f5bf8 Merge branch 'master' into develop 2019-12-19 20:52:53 +01:00
9ed20cb085 Marked none instances as inline variables.
This should avoid duplicating none instances in all translation units.

Closes https://github.com/boostorg/optional/issues/33.
2019-12-19 20:22:16 +01:00
4fbb7582e1 Don't instantiate is_convertible_to_T_or_factory when is_optional_related
Fixes #78.
2019-12-18 17:51:51 -08:00
29dfc173c6 Merge pull request #71 from Mike-Devel/min_cmake
[CMake] Add minimal cmake support
2019-03-04 10:43:45 +01:00
f4d1107e86 [CMake] Add minimal cmake support
- CMake file only supports add_subdirectory workflow.
- Provides Boost::optional target,
  but no installation and no unit tests
2019-03-02 17:12:29 +01:00
324272fc0e Merge pull request #70 from Kojoley/patch-1
Fix unused argument warning
2019-02-27 21:22:08 -10:00
ee575b34c5 Fix unused argument warning
boost/optional/optional.hpp:970:5: warning: unused parameter 'rhs' [-Wunused-parameter]
2019-02-28 00:13:00 +03:00
a192204b41 Merge branch 'develop' 2018-11-08 18:49:34 +01:00
545fd9a72f docs and tests fixes 2018-11-08 18:46:03 +01:00
29b2dae630 Merge branch 'Lastique-fix_constructible_from_any' into develop 2018-11-05 18:18:05 +01:00
2f3cf1ca84 Added a test to verify that boost::optional copy constructor does not invoke T's template constructors. 2018-11-04 17:54:57 +03:00
24d29e5865 Fix for clang, when adapted type is convertible from other types.
The problem was with copy/move constructors of boost::optional<T>, which invoked
optional_base<T> constructors with a single argument. Since optional_base has
copy/move constructors along with initializing constructors taking a single
argument, the latter may be considered by the compiler for viability. While
doing so, the compiler may instantiate the template constructor of T with
an argument of optional_base<T>, which in turn may fail if the constructor
attempts to inspect the type of its argument (e.g. to constrain the set of
acceptable types). Specifically, this happens with clang in C++03 mode,
when boost::multiprecision::number is wrapped in boost::optional and
a copy constructor of boost::optional is invoked.

This commit fixes the problem by destinguishing copy/move constructors of
optional_base from initializing constructors with an additional tag argument.
2018-11-04 17:35:10 +03:00
eea107d9b5 Merge branch 'develop' 2018-10-29 22:24:28 +01:00
69e239530e docs: updated releasenotes 2018-10-29 22:06:47 +01:00
65bb040db8 tests: added two test cases from GitHub issues 2018-10-29 21:47:09 +01:00
fae2791f45 added test for swapping const opitonals 2018-10-25 00:37:13 +02:00
0f8e356bca rebuilt docs 2018-10-23 22:46:26 +02:00
59277bc31f Merge branch 'Kojoley-remove-deprecation-mark-from-reset' into develop 2018-10-23 22:35:55 +02:00
bebc606a4c Remove deprecation mark from reset()
The `std::optional` has `reset()` [optional.mod] and it is not deprecated.
2018-10-23 22:34:10 +02:00
106f9aee5e Merge pull request #60 from Kojoley/workaround-gcc-8-9-regression
Workaround GCC 8-9 regression
2018-10-15 16:36:17 +02:00
350ebab88a Workaround GCC 8-9 regression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87531
2018-10-05 18:47:16 +03:00
a3916b46a9 Merge pull request #58 from boostorg/pr/remove-mpl
Remove dependency on MPL
2018-09-12 22:39:53 +02:00
c52280bb78 Remove dependency on MPL 2018-09-12 20:02:47 +03:00
155ad5911e Merge branch 'develop' 2018-07-16 20:41:11 +02:00
228b20df82 fixed old implementation (issue #57) 2018-07-12 00:30:47 +02:00
2854383cf7 Merge branch 'develop' 2018-07-03 23:06:28 +02:00
d0b87d2f35 documented flat_map 2018-07-02 23:23:46 +02:00
71d797b9ee added implementation and tests of flat_map() 2018-06-28 23:30:47 +02:00
701afd43a4 fixed strange verisons of libstdc++ 2018-06-28 21:17:07 +02:00
d13623884a hopefully fixed the libstdc++ 4.9 problem (thanks Jonathan) 2018-06-28 02:10:57 +02:00
7320dd54e8 one more test hack macro to check 2018-06-27 22:23:57 +02:00
51a46f95c6 testing clang v. 2018-06-26 00:04:33 +02:00
35ca7c1ff1 added a hack test to check compiler setup 2018-06-25 23:59:19 +02:00
0169460194 fixed tests and maybe std::is_trivially_default_constructible 2018-06-25 22:50:00 +02:00
42445e94aa Fix for C++03 tests for .map() using result_of 2018-06-24 17:12:38 +02:00
250806d029 fixed >> int C++03 templates 2018-06-24 15:22:56 +02:00
51d1bc843d test and doc update for .map() 2018-06-23 20:53:16 +02:00
e47a017009 added o.map() 2018-06-23 18:27:14 +02:00
5182f7f30f Added has_value() 2018-03-24 00:04:15 +01:00
8f992acb94 Merge branch 'develop' 2018-03-01 01:53:37 +01:00
33c7a6aa2b docs: relnotes for 1.67 2018-03-01 01:10:42 +01:00
76ff82d191 Silenced warning -Wzero-as-null-pointer-constant 2018-02-15 22:51:08 +01:00
b1e29eb585 Merge pull request #50 from pkl97/develop
Fixed recurring typo
2018-02-12 08:44:23 +01:00
a5aaf4d8d0 Fixed recurring typo 2018-02-11 21:03:54 +01:00
1f6d8bc602 Merge pull request #47 from petamas/bugfix/member_T
Fix #46: optional<X> fails to compile with VS2015 if X has an embedded enum named T
2018-01-03 14:08:31 +01:00
e230bd83c6 Fix compilation of template parameter with member enum T on VS2015
Issue: https://github.com/boostorg/optional/issues/46
2018-01-03 10:46:31 +01:00
b832d4c54f Add test for template parameter with member enum T (fails by default on VS2015)
Issue: https://github.com/boostorg/optional/issues/46ű
2018-01-03 10:37:37 +01:00
fb54ee1741 Fixed spelling mistake in macros 2017-11-07 23:35:01 +01:00
5b6f4be434 Fix make_optional for rvalues 2017-11-07 23:34:56 +01:00
f9fdf42a17 fix for the previous partial commit 2017-11-07 23:34:52 +01:00
7541076cf1 fixed defaulted moves on older compilers 2017-11-07 23:34:41 +01:00
40f7c97292 Fixed -Wmaybe-uninitialized 2017-11-07 23:34:37 +01:00
06dea2cb9b Reverted specialization for trivial types
It caused too many problems. I left only specialiation for scalar types.
I will need to devise clever type traits for reconizing trivial types with working constructor.
2017-11-07 23:34:34 +01:00
cbf3cd05af Test case for #43 2017-11-07 23:34:31 +01:00
6e10173a44 Fixed silly && bug 2017-11-07 23:34:28 +01:00
69bf75ae6d Fix trivially-constructible bug with deleted functions 2017-11-07 23:34:26 +01:00
01ebd2ad7f Added tests for types with deleted default ctor 2017-11-07 23:34:23 +01:00
42c2377a0d Add tc_optional_base test 2017-11-07 23:34:20 +01:00
9d0ddc4709 fixed regression on compilers w/o type trait support 2017-11-07 23:34:18 +01:00
a7f33f5d6f more defensive checking for trivial types -- avoiding bugs 2017-11-07 23:34:15 +01:00
58f7c2f14a fix bug with defaulted move in msvc 12.0 2017-11-07 23:34:12 +01:00
ebef3ed6f7 Try to make the test closer to the failing case in Beast 2017-11-07 23:34:09 +01:00
9e0726cee1 Add test for a deleted default constructor 2017-11-07 23:34:07 +01:00
2d2c3c3f6f trivially-copyable optional<T> for trivial T 2017-11-07 23:34:05 +01:00
e95f9fc254 Convert tabs to spaces. 2017-11-07 23:34:02 +01:00
7e1beb473c Use BOOST_MAY_ALIAS from Boost.Config. 2017-11-07 23:33:59 +01:00
61bf382ffa Enable tests that doesn't requires rv-ref. 2017-11-07 23:33:57 +01:00
4fe57f57fa Fix make_optional for rvalues 2017-11-07 23:33:54 +01:00
c695be11b5 Adds forwarding make_optional helpers, resolves #30 2017-11-07 23:32:27 +01:00
e9f5641be3 Add .travis.yml 2017-10-29 19:10:06 +02:00
b709447922 r #12967 use BOOST_CONSTEXPR on none_t ctor 2017-08-16 13:52:46 -04:00
cd4e44f3dc r #12967 make none_t constructor constexpr 2017-04-13 09:13:26 -04:00
975a6aa92d Merge documentation fix from 'develop' 2017-03-22 22:59:32 +01:00
cb7641dc34 fixed wrong namespace in docs 2017-02-14 23:53:30 +01:00
c3abf83426 Suppress weak vtables warning 2016-08-31 17:37:50 +03:00
118 changed files with 4565 additions and 537 deletions

36
.drone.star Normal file
View File

@ -0,0 +1,36 @@
# Use, modification, and distribution are
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE.txt)
#
# Copyright Rene Rivera 2020.
# For Drone CI we use the Starlark scripting language to reduce duplication.
# As the yaml syntax for Drone CI is rather limited.
#
#
globalenv={}
linuxglobalimage="cppalliance/droneubuntu1604:1"
windowsglobalimage="cppalliance/dronevs2019"
def main(ctx):
return [
linux_cxx("TOOLSET=gcc COMPILER=g++ CXXSTD=03,11 Job 0", "g++", packages="", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'b6589fc6ab'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11 Job 1", "g++-4.7", packages="g++-4.7", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.7', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '356a192b79'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11 Job 2", "g++-4.8", packages="g++-4.8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.8', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'da4b9237ba'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11 Job 3", "g++-4.9", packages="g++-4.9", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.9', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '77de68daec'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z Job 4", "g++-5", packages="g++-5", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-5', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '1b64538924'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z Job 5", "g++-6", packages="g++-6", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-6', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'ac3478d69a'}, globalenv=globalenv),
linux_cxx("TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 Job 6", "g++-7", packages="g++-7", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-7', 'CXXSTD': '03,11,14,17', 'DRONE_JOB_UUID': 'c1dfd96eea'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 7", "clang++", packages="", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '902ba3cda1'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03, Job 8", "clang++-3.5", packages="clang-3.5 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.5", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.5', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'fe5dbbcea5'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03, Job 9", "clang++-3.6", packages="clang-3.6", llvm_os="precise", llvm_ver="3.6", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.6', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '0ade7c2cf9'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03, Job 10", "clang++-3.7", packages="clang-3.7", llvm_os="precise", llvm_ver="3.7", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.7', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'b1d5781111'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03, Job 11", "clang++-3.8", packages="clang-3.8 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.8', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '17ba079149'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03, Job 12", "clang++-3.9", packages="clang-3.9 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.9", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.9', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '7b52009b64'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 13", "clang++-4.0", packages="clang-4.0", llvm_os="trusty", llvm_ver="4.0", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-4.0', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'bd307a3ec3'}, globalenv=globalenv),
linux_cxx("TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 14", "clang++-5.0", packages="clang-5.0", llvm_os="trusty", llvm_ver="5.0", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-5.0', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'fa35e19212'}, globalenv=globalenv),
osx_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,1 Job 15", "clang++", packages="", buildtype="boost", buildscript="drone", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'f1abd67035'}, globalenv=globalenv),
]
# from https://github.com/boostorg/boost-ci
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")

37
.drone/drone.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
# Copyright 2020 Rene Rivera, Sam Darwin
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt)
set -e
export TRAVIS_BUILD_DIR=$(pwd)
export DRONE_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=$DRONE_BRANCH
export VCS_COMMIT_ID=$DRONE_COMMIT
export GIT_COMMIT=$DRONE_COMMIT
export REPO_NAME=$DRONE_REPO
export PATH=~/.local/bin:/usr/local/bin:$PATH
if [ "$DRONE_JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> INSTALL'
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/build
git submodule update --init libs/config
git submodule update --init tools/boostdep
cp -r $TRAVIS_BUILD_DIR/* libs/optional
python tools/boostdep/depinst/depinst.py optional
./bootstrap.sh
./b2 headers
echo '==================================> SCRIPT'
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
./b2 libs/optional/test toolset=$TOOLSET cxxstd=$CXXSTD
fi

391
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,391 @@
name: GitHub Actions CI
on:
pull_request:
push:
branches:
- master
- develop
- githubactions*
- feature/**
- fix/**
- pr/**
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- name: "TOOLSET=gcc COMPILER=g++ CXXSTD=03,11 Job 0"
buildtype: "boost"
packages: ""
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++"
cxxstd: "03,11"
- name: "TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11 Job 1"
buildtype: "boost"
packages: "g++-4.7"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "g++-4.7"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++-4.7"
cxxstd: "03,11"
- name: "TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11 Job 2"
buildtype: "boost"
packages: "g++-4.8"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "g++-4.8"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++-4.8"
cxxstd: "03,11"
- name: "TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11 Job 3"
buildtype: "boost"
packages: "g++-4.9"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "g++-4.9"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++-4.9"
cxxstd: "03,11"
- name: "TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z Job 4"
buildtype: "boost"
packages: "g++-5"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "g++-5"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++-5"
cxxstd: "03,11,14,1z"
- name: "TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z Job 5"
buildtype: "boost"
packages: "g++-6"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "g++-6"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++-6"
cxxstd: "03,11,14,1z"
- name: "TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 Job 6"
buildtype: "boost"
packages: "g++-7"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "g++-7"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++-7"
cxxstd: "03,11,14,17"
- name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 7"
buildtype: "boost"
packages: ""
packages_to_remove: ""
os: "ubuntu-18.04"
cxx: "clang++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang"
compiler: "clang++"
cxxstd: "03,11"
- name: "TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03, Job 8"
buildtype: "boost"
packages: "clang-3.5 libstdc++-4.9-dev"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "clang++-3.5"
sources: ""
llvm_os: "precise"
llvm_ver: "3.5"
toolset: "clang"
compiler: "clang++-3.5"
cxxstd: "03,11,14"
- name: "TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03, Job 9"
buildtype: "boost"
packages: "clang-3.6"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "clang++-3.6"
sources: ""
llvm_os: "precise"
llvm_ver: "3.6"
toolset: "clang"
compiler: "clang++-3.6"
cxxstd: "03,11,14"
- name: "TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03, Job 10"
buildtype: "boost"
packages: "clang-3.7"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "clang++-3.7"
sources: ""
llvm_os: "precise"
llvm_ver: "3.7"
toolset: "clang"
compiler: "clang++-3.7"
cxxstd: "03,11,14"
- name: "TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03, Job 11"
buildtype: "boost"
packages: "clang-3.8 libstdc++-4.9-dev"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "clang++-3.8"
sources: ""
llvm_os: "precise"
llvm_ver: "3.8"
toolset: "clang"
compiler: "clang++-3.8"
cxxstd: "03,11,14"
- name: "TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03, Job 12"
buildtype: "boost"
packages: "clang-3.9 libstdc++-4.9-dev"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:16.04"
cxx: "clang++-3.9"
sources: ""
llvm_os: "precise"
llvm_ver: "3.9"
toolset: "clang"
compiler: "clang++-3.9"
cxxstd: "03,11,14"
- name: "TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 13"
buildtype: "boost"
packages: "clang-4.0"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:14.04"
cxx: "clang++-4.0"
sources: ""
llvm_os: "trusty"
llvm_ver: "4.0"
toolset: "clang"
compiler: "clang++-4.0"
cxxstd: "03,11,14"
- name: "TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 14"
buildtype: "boost"
packages: "clang-5.0"
packages_to_remove: ""
os: "ubuntu-20.04"
container: "ubuntu:14.04"
cxx: "clang++-5.0"
sources: ""
llvm_os: "trusty"
llvm_ver: "5.0"
toolset: "clang"
compiler: "clang++-5.0"
cxxstd: "03,11,14,1z"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Check if running in container
if: matrix.container != ''
run: echo "GHA_CONTAINER=${{ matrix.container }}" >> $GITHUB_ENV
- name: If running in container, upgrade packages
if: matrix.container != ''
run: |
apt-get -o Acquire::Retries=3 update && DEBIAN_FRONTEND=noninteractive apt-get -y install tzdata && apt-get -o Acquire::Retries=3 install -y sudo software-properties-common wget curl apt-transport-https make apt-file sudo unzip libssl-dev build-essential autotools-dev autoconf automake g++ libc++-helpers python ruby cpio gcc-multilib g++-multilib pkgconf python3 ccache libpython-dev
sudo apt-add-repository ppa:git-core/ppa
sudo apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 -y install git
python_version=$(python3 -c 'import sys; print("{0.major}.{0.minor}".format(sys.version_info))')
sudo wget https://bootstrap.pypa.io/pip/$python_version/get-pip.py
sudo python3 get-pip.py
sudo /usr/local/bin/pip install cmake
- uses: actions/checkout@v2
- name: linux
shell: bash
env:
CXX: ${{ matrix.cxx }}
SOURCES: ${{ matrix.sources }}
LLVM_OS: ${{ matrix.llvm_os }}
LLVM_VER: ${{ matrix.llvm_ver }}
PACKAGES: ${{ matrix.packages }}
PACKAGES_TO_REMOVE: ${{ matrix.packages_to_remove }}
JOB_BUILDTYPE: ${{ matrix.buildtype }}
TOOLSET: ${{ matrix.toolset }}
COMPILER: ${{ matrix.compiler }}
CXXSTD: ${{ matrix.cxxstd }}
TRAVIS_BRANCH: ${{ github.base_ref }}
TRAVIS_OS_NAME: "linux"
run: |
echo '==================================> SETUP'
echo '==================================> PACKAGES'
set -e
if [ -n "$PACKAGES_TO_REMOVE" ]; then sudo apt-get purge -y $PACKAGES_TO_REMOVE; fi
echo ">>>>> APT: REPO.."
for i in {1..3}; do sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && break || sleep 2; done
if test -n "${LLVM_OS}" ; then
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
if test -n "${LLVM_VER}" ; then
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS}-${LLVM_VER} main"
else
# Snapshot (i.e. trunk) build of clang
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS} main"
fi
fi
echo ">>>>> APT: UPDATE.."
sudo -E apt-get -o Acquire::Retries=3 update
if test -n "${SOURCES}" ; then
echo ">>>>> APT: INSTALL SOURCES.."
for SOURCE in $SOURCES; do
sudo -E apt-add-repository ppa:$SOURCE
done
fi
echo ">>>>> APT: INSTALL ${PACKAGES}.."
sudo -E DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 -y --no-install-suggests --no-install-recommends install ${PACKAGES}
echo '==================================> INSTALL AND COMPILE'
set -e
export TRAVIS_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
export VCS_COMMIT_ID=$GITHUB_SHA
export GIT_COMMIT=$GITHUB_SHA
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
export USER=$(whoami)
export CC=${CC:-gcc}
export PATH=~/.local/bin:/usr/local/bin:$PATH
if [ "$JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> INSTALL'
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/build
git submodule update --init libs/config
git submodule update --init tools/boostdep
cp -r $TRAVIS_BUILD_DIR/* libs/optional
python tools/boostdep/depinst/depinst.py optional
./bootstrap.sh
./b2 headers
echo '==================================> SCRIPT'
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
./b2 libs/optional/test toolset=$TOOLSET cxxstd=$CXXSTD
fi
osx:
strategy:
fail-fast: false
matrix:
include:
- name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,1 Job 15"
buildtype: "boost"
packages: ""
os: "macos-10.15"
cxx: "clang++"
sources: ""
llvm_os: ""
llvm_ver: ""
xcode_version: 11.7
toolset: "clang"
compiler: "clang++"
cxxstd: "03,11,14,1z"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set DEVELOPER_DIR
if: matrix.xcode_version != ''
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" >> $GITHUB_ENV
- name: Test DEVELOPER_DIR
run: echo $DEVELOPER_DIR
- name: "osx"
shell: bash
env:
CXX: ${{ matrix.cxx }}
SOURCES: ${{ matrix.sources }}
LLVM_OS: ${{ matrix.llvm_os }}
LLVM_VER: ${{ matrix.llvm_ver }}
PACKAGES: ${{ matrix.packages }}
JOB_BUILDTYPE: ${{ matrix.buildtype }}
TOOLSET: ${{ matrix.toolset }}
COMPILER: ${{ matrix.compiler }}
CXXSTD: ${{ matrix.cxxstd }}
TRAVIS_BRANCH: ${{ github.base_ref }}
TRAVIS_OS_NAME: "osx"
run: |
echo '==================================> SETUP'
set -e
sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.bck
echo '==================================> PACKAGES'
echo '==================================> INSTALL AND COMPILE'
set -e
export TRAVIS_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
export VCS_COMMIT_ID=$GITHUB_SHA
export GIT_COMMIT=$GITHUB_SHA
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
export USER=$(whoami)
export CC=${CC:-gcc}
export PATH=~/.local/bin:/usr/local/bin:$PATH
if [ "$JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> INSTALL'
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/build
git submodule update --init libs/config
git submodule update --init tools/boostdep
cp -r $TRAVIS_BUILD_DIR/* libs/optional
python tools/boostdep/depinst/depinst.py optional
./bootstrap.sh
./b2 headers
echo '==================================> SCRIPT'
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
./b2 libs/optional/test toolset=$TOOLSET cxxstd=$CXXSTD
fi

201
.travis.yml Normal file
View File

@ -0,0 +1,201 @@
# Copyright 2016, 2017 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
sudo: false
python: "2.7"
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: linux
dist: trusty
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
dist: trusty
compiler: clang++-5.0
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/optional
- python tools/boostdep/depinst/depinst.py optional
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 libs/optional/test toolset=$TOOLSET cxxstd=$CXXSTD
notifications:
email:
on_success: always

52
CMakeLists.txt Normal file
View File

@ -0,0 +1,52 @@
# Copyright 2019 Mike Dev
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
if(NOT DEFINED IDF_TARGET)
cmake_minimum_required( VERSION 3.5...3.20 )
project( boost_optional VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX )
add_library( boost_optional INTERFACE )
add_library( Boost::optional ALIAS boost_optional )
target_include_directories( boost_optional INTERFACE include )
target_link_libraries( boost_optional
INTERFACE
Boost::assert
Boost::config
Boost::core
Boost::detail
Boost::move
Boost::predef
Boost::static_assert
Boost::throw_exception
Boost::type_traits
Boost::utility
)
else()
FILE(GLOB_RECURSE headers include/*.h include/*.hpp)
idf_component_register(
SRCS
${headers}
INCLUDE_DIRS
include
REQUIRES
boost_assert
boost_config
boost_core
boost_detail
boost_move
boost_predef
boost_static_assert
boost_throw_exception
boost_type_traits
boost_utility
)
endif()

View File

@ -2,7 +2,7 @@
[quickbook 1.4]
[authors [Cacciola Carballal, Fernando Luis]]
[copyright 2003-2007 Fernando Luis Cacciola Carballal]
[copyright 2014-2016 Andrzej Krzemie&#324;ski]
[copyright 2014-2022 Andrzej Krzemie&#324;ski]
[category miscellaneous]
[id optional]
[dirname optional]
@ -61,7 +61,7 @@ Suppose we want to read a parameter form a config file which represents some int
This is how you solve it with `boost::optional`:
#include <boost/optional.hpp>
boost::optional<int> getConfigParam(std::string name); // return either an int or a `not-an-int`
int main()
@ -71,7 +71,7 @@ This is how you solve it with `boost::optional`:
else
runWithNoMax();
}
[endsect]
[include 01_quick_start.qbk]
@ -102,5 +102,3 @@ This is how you solve it with `boost::optional`:
[include 90_dependencies.qbk]
[include 91_relnotes.qbk]
[include 92_acknowledgments.qbk]

View File

@ -61,12 +61,12 @@ When an optional object that contains a value is moved from (is a source of move
assert (opi);
assert (*opi == nullptr);
Quite a lot of people expect that when an object that contains a value is moved from, its contained value should be destroyed. This is not so, for performance reasons. Current semantics allow the implementation of `boost::opiotnal<T>` to be trivially copyable when `T` is trivial.
Quite a lot of people expect that when an object that contains a value is moved from, its contained value should be destroyed. This is not so, for performance reasons. Current semantics allow the implementation of `boost::optional<T>` to be trivially copyable when `T` is trivial.
[endsect]
[section Mixed relational comparisons]
Because `T` is convertible to `optional<T>` and because `opiotnal<T>` is __SGI_LESS_THAN_COMPARABLE__ when `T` is __SGI_LESS_THAN_COMPARABLE__,
Because `T` is convertible to `optional<T>` and because `optional<T>` is __SGI_LESS_THAN_COMPARABLE__ when `T` is __SGI_LESS_THAN_COMPARABLE__,
you can sometimes get an unexpected runtime result where you would rather expect a compiler error:
optional<double> Flight_plan::weight(); // sometimes no weight can be returned
@ -102,10 +102,10 @@ Sometimes on GCC compilers below version 5.1 you may get an -Wmaybe-uninitialize
This is a bug in the compiler. As a workaround (provided in [@http://stackoverflow.com/questions/21755206/how-to-get-around-gcc-void-b-4-may-be-used-uninitialized-in-this-funct this Stack Overflow question]) use the following way of initializing an optional containing no value:
boost::optional<int> b = std::make_optional(false, int());
boost::optional<int> b = boost::make_optional(false, int());
This is obviously redundant, but makes the warning disappear.
[endsect]
[endsect]
[endsect]

View File

@ -1,7 +1,7 @@

[section Performance considerations]
Technical details aside, the memory layout of `optional<T>` is more-less this:
Technical details aside, the memory layout of `optional<T>` for a generic `T` is more-less this:
template <typename T>
class optional
@ -9,8 +9,33 @@ Technical details aside, the memory layout of `optional<T>` is more-less this:
bool _initialized;
std::aligned_storage_t<sizeof(t), alignof(T)> _storage;
};
Lifetime of the `T` inside `_storage` is manually controlled with placement-`new`s and pseudo-destructor calls. However, for scalar `T`s we use a different way of storage, by simply holding a `T`:
But for the purpose of this analysis, considering memory layouts, we can think of it as:
template <typename T>
class optional
{
bool _initialized;
T _storage;
};
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 (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 // not trivial
{
X() {}
};
namespace boost { namespace optional_config {
template <> struct optional_uses_direct_storage_for<X> : boost::true_type {};
}}
[heading Controlling the size]
For the purpose of the following analysis, considering memory layouts, we can think of it as:
template <typename T>
class optional

View File

@ -17,8 +17,8 @@ namespace boost {
class none_t {/* see below */};
const none_t none (/* see below */);
inline constexpr none_t none (/* see below */);
} // namespace boost
```

View File

@ -26,11 +26,11 @@ template <class CharType, class CharTrait, class T>
template <class CharType, class CharTrait>
std::basic_ostream<CharType, CharTrait>&
operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t const&); ``[link reference_operator_ostream_none __GO_TO__]``
template<class CharType, class CharTrait, class T>
std::basic_istream<CharType, CharTrait>&
operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v); ``[link reference_operator_istream __GO_TO__]``
} // namespace boost
```
@ -43,8 +43,8 @@ template<class CharType, class CharTrait, class T>
`template <class CharType, class CharTrait, class T>` [br]
\u00A0\u00A0\u00A0\u00A0`std::basic_ostream<CharType, CharTrait>&` [br]
\u00A0\u00A0\u00A0\u00A0`operator<<(std::basic_ostream<CharType, CharTrait>& out, optional<T> const& v);`
std::basic_ostream<CharType, CharTrait>&` [br]
operator<<(std::basic_ostream<CharType, CharTrait>& out, optional<T> const& v);`
* [*Effect:] Outputs an implementation-defined string. The output contains the information about whether the optional object contains a value or not. If `v` contains a value, the output contains result of calling `out << *v`.
* [*Returns:] `out`.
@ -53,8 +53,8 @@ __SPACE__
[#reference_operator_ostream_none]
`template <class CharType, class CharTrait, class T>` [br]
\u00A0\u00A0\u00A0\u00A0`std::basic_ostream<CharType, CharTrait>&` [br]
\u00A0\u00A0\u00A0\u00A0`operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t);`
std::basic_ostream<CharType, CharTrait>&` [br]
operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t);`
* [*Effect:] Outputs an implementation-defined string.
* [*Returns:] `out`.
@ -63,11 +63,11 @@ __SPACE__
[#reference_operator_istream]
`template <class CharType, class CharTrait, class T>` [br]
\u00A0\u00A0\u00A0\u00A0`std::basic_ostream<CharType, CharTrait>&` [br]
\u00A0\u00A0\u00A0\u00A0`operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v);`
std::basic_ostream<CharType, CharTrait>&` [br]
operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v);`
* [*Requires:] `T` is __SGI_DEFAULT_CONSTRUCTIBLE__ and __MOVE_CONSTRUCTIBLE__.
* [*Effect:] Reads the value of optional object from `in`. If the string representation indicates that the optional object should contain a value, `v` contains a value and its contained value is obtained as if by default-constructing an object `o` of type `T` and then calling `in >> o`; otherwise `v` does not contain a value, and the previously contained value (if any) has been destroyed.
* [*Effect:] Reads the value of optional object from `in`. If the string representation indicates that the optional object should contain a value, `v` contains a value and its contained value is obtained as if by default-constructing an object `o` of type `T` and then calling `in >> o`; otherwise `v` does not contain a value, and the previously contained value (if any) has been destroyed.
* [*Returns:] `out`.
[endsect]

View File

@ -17,16 +17,16 @@
class in_place_init_t { /* see below */ } ; ``[link reference_in_place_init __GO_TO__]``
const in_place_init_t in_place_init ( /* see below */ ) ;
class in_place_init_if_t { /*see below*/ } ; ``[link reference_in_place_init_if __GO_TO__]``
const in_place_init_if_t in_place_init_if ( /*see below*/ ) ;
template <class T>
class optional ; ``[link reference_operator_template __GO_TO__]``
template <class T>
class optional<T&> ; ``[link reference_operator_template_spec __GO_TO__]``
template<class T> inline bool operator == ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_equal_optional_optional __GO_TO__]``
template<class T> inline bool operator != ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_not_equal_optional_optional __GO_TO__]``
@ -38,17 +38,21 @@
template<class T> inline bool operator <= ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_less_or_equal_optional_optional __GO_TO__]``
template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_greater_or_equal_optional_optional __GO_TO__]``
template<class T> inline bool operator == ( optional<T> const& x, none_t ) noexcept ; ``[link reference_operator_compare_equal_optional_none __GO_TO__]``
template<class T> inline bool operator != ( optional<T> const& x, none_t ) noexcept ; ``[link reference_operator_compare_not_equal_optional_none __GO_TO__]``
template<class T> inline optional<T> make_optional ( T const& v ) ; ``[link reference_make_optional_value __GO_TO__]``
template<class T> inline optional<std::decay_t<T>> make_optional ( T && v ) ; ``[link reference_make_optional_rvalue __GO_TO__]``
template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; ``[link reference_make_optional_bool_value __GO_TO__]``
template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_const_type def ) -> typename optional<T>::reference_const_type; ``[link reference_free_get_value_or __GO_TO__]``
template<class T> inline optional<std::decay_t<T>> make_optional ( bool condition, T && v ) ; ``[link reference_make_optional_bool_rvalue __GO_TO__]``
template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_const_type def ) -> typename optional<T>::reference_const_type; ``[link reference_free_get_value_or __GO_TO__]``
template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_type def ) -> typename optional<T>::reference_type ; ``[link reference_free_get_value_or __GO_TO__]``
template<class T> inline T const& get ( optional<T> const& opt ) ; ``[link reference_optional_get __GO_TO__]``
@ -64,11 +68,21 @@
template<class T> inline auto get_pointer ( optional<T> & opt ) -> ``['see below]``; ``[link reference_free_get_pointer __GO_TO__]``
template<class T> inline void swap( optional<T>& x, optional<T>& y ) ; ``[link reference_swap_optional_optional __GO_TO__]``
template<class T> inline void swap( optional<T&>& x, optional<T&>& y ) ; ``[link reference_swap_optional_reference __GO_TO__]``
} // namespace boost
namespace std {
template <typename T>
struct hash<boost::optional<T> > ; ``[link reference_std_hash_spec __GO_TO__]``
template <typename T>
struct hash<boost::optional<T&> > ; ``[link reference_std_hash_spec __GO_TO__]``
} // namespace std
[endsect]
@ -82,21 +96,21 @@
class in_place_init_t { /* see below */ } ;
const in_place_init_t in_place_init ( /* see below */ ) ;
class in_place_init_if_t { /*see below*/ } ;
const in_place_init_if_t in_place_init_if ( /*see below*/ ) ;
}
Classes `in_place_init_t` and `in_place_init_if_t` are empty clsses. Their purpose is to control overload resolution in the initialization of optional objects.
They are empty, trivially copyable classes with disabled default constructor.
Classes `in_place_init_t` and `in_place_init_if_t` are empty clsses. Their purpose is to control overload resolution in the initialization of optional objects.
They are empty, trivially copyable classes with disabled default constructor.
[endsect]
[section:header_optional_optional_values Optional Values]
[#reference_operator_template]
template <class T>
class optional
{
@ -108,27 +122,27 @@ They are empty, trivially copyable classes with disabled default constructor.
typedef T && rval_reference_type ;
typedef T * pointer_type ;
typedef T const* pointer_const_type ;
optional () noexcept ; ``[link reference_optional_constructor __GO_TO__]``
optional ( none_t ) noexcept ; ``[link reference_optional_constructor_none_t __GO_TO__]``
optional ( T const& v ) ; ``[link reference_optional_constructor_value __GO_TO__]``
optional ( T&& v ) ; ``[link reference_optional_constructor_move_value __GO_TO__]``
optional ( bool condition, T const& v ) ; ``[link reference_optional_constructor_bool_value __GO_TO__]``
optional ( bool condition, T const& v ) ; ``[link reference_optional_constructor_bool_value __GO_TO__]``
optional ( optional const& rhs ) ; ``[link reference_optional_constructor_optional __GO_TO__]``
optional ( optional&& rhs ) noexcept(``['see below]``) ; ``[link reference_optional_move_constructor_optional __GO_TO__]``
template<class U> explicit optional ( optional<U> const& rhs ) ; ``[link reference_optional_constructor_other_optional __GO_TO__]``
template<class U> explicit optional ( optional<U>&& rhs ) ; ``[link reference_optional_move_constructor_other_optional __GO_TO__]``
template<class... Args> explicit optional ( in_place_init_t, Args&&... args ) ; ``[link reference_optional_in_place_init __GO_TO__]``
template<class... Args> explicit optional ( in_place_init_if_t, bool condition, Args&&... args ) ; ``[link reference_optional_in_place_init_if __GO_TO__]``
template<class InPlaceFactory> explicit optional ( InPlaceFactory const& f ) ; ``[link reference_optional_constructor_factory __GO_TO__]``
@ -138,17 +152,17 @@ They are empty, trivially copyable classes with disabled default constructor.
optional& operator = ( none_t ) noexcept ; ``[link reference_optional_operator_equal_none_t __GO_TO__]``
optional& operator = ( T const& v ) ; ``[link reference_optional_operator_equal_value __GO_TO__]``
optional& operator = ( T&& v ) ; ``[link reference_optional_operator_move_equal_value __GO_TO__]``
optional& operator = ( optional const& rhs ) ; ``[link reference_optional_operator_equal_optional __GO_TO__]``
optional& operator = ( optional&& rhs ) noexcept(``['see below]``) ; ``[link reference_optional_operator_move_equal_optional __GO_TO__]``
template<class U> optional& operator = ( optional<U> const& rhs ) ; ``[link reference_optional_operator_equal_other_optional __GO_TO__]``
template<class U> optional& operator = ( optional<U>&& rhs ) ; ``[link reference_optional_operator_move_equal_other_optional __GO_TO__]``
template<class... Args> void emplace ( Args&&... args ) ; ``[link reference_optional_emplace __GO_TO__]``
template<class InPlaceFactory> optional& operator = ( InPlaceFactory const& f ) ; ``[link reference_optional_operator_equal_factory __GO_TO__]``
@ -164,29 +178,38 @@ They are empty, trivially copyable classes with disabled default constructor.
T const& operator *() const& ; ``[link reference_optional_operator_asterisk __GO_TO__]``
T& operator *() & ; ``[link reference_optional_operator_asterisk __GO_TO__]``
T&& operator *() && ; ``[link reference_optional_operator_asterisk_move __GO_TO__]``
T const& value() const& ; ``[link reference_optional_value __GO_TO__]``
T& value() & ; ``[link reference_optional_value __GO_TO__]``
T&& value() && ; ``[link reference_optional_value_move __GO_TO__]``
template<class U> T value_or( U && v ) const& ; ``[link reference_optional_value_or __GO_TO__]``
template<class U> T value_or( U && v ) && ; ``[link reference_optional_value_or_move __GO_TO__]``
template<class F> T value_or_eval( F f ) const& ; ``[link reference_optional_value_or_call __GO_TO__]``
template<class F> T value_or_eval( F f ) && ; ``[link reference_optional_value_or_call_move __GO_TO__]``
template<class F> auto map( F f ) const& -> ``['see below]``; ``[link reference_optional_map __GO_TO__]``
template<class F> auto map( F f ) & -> ``['see below]``; ``[link reference_optional_map __GO_TO__]``
template<class F> auto map( F f ) && -> ``['see below]``; ``[link reference_optional_map_move __GO_TO__]``
template<class F> auto flat_map( F f ) const& -> ``['see below]``; ``[link reference_optional_flat_map __GO_TO__]``
template<class F> auto flat_map( F f ) & -> ``['see below]``; ``[link reference_optional_flat_map __GO_TO__]``
template<class F> auto flat_map( F f ) && -> ``['see below]``; ``[link reference_optional_flat_map_move __GO_TO__]``
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__]``
// deprecated methods
// (deprecated)
void reset() noexcept ; ``[link reference_optional_reset __GO_TO__]``
// deprecated methods
// (deprecated)
void reset ( T const& ) ; ``[link reference_optional_reset_value __GO_TO__]``
@ -194,7 +217,7 @@ They are empty, trivially copyable classes with disabled default constructor.
bool is_initialized() const ; ``[link reference_optional_is_initialized __GO_TO__]``
// (deprecated)
T const& get_value_or( T const& default ) const ; ``[link reference_optional_get_value_or_value __GO_TO__]``
T const& get_value_or( T const& default ) const ; ``[link reference_optional_get_value_or_value __GO_TO__]``
};
@ -221,22 +244,21 @@ They are empty, trivially copyable classes with disabled default constructor.
optional ( none_t ) noexcept ; ``[link reference_optional_ref_default_ctor __GO_TO__]``
template<class R> optional(R&& r) noexcept ; ``[link reference_optional_ref_value_ctor __GO_TO__]``
template <class R> optional(bool cond, R&& r) noexcept ; ``[link reference_optional_ref_cond_value_ctor __GO_TO__]``
optional ( optional const& rhs ) noexcept ; ``[link reference_optional_ref_copy_ctor __GO_TO__]``
template<class U> explicit optional ( optional<U&> const& rhs ) noexcept ; ``[link reference_optional_ref_ctor_from_opt_U __GO_TO__]``
optional& operator = ( none_t ) noexcept ; ``[link reference_optional_ref_assign_none_t __GO_TO__]``
optional& operator = ( optional const& rhs ) noexcept; ``[link reference_optional_ref_copy_assign __GO_TO__]``
template<class U> optional& operator = ( optional<U&> const& rhs ) noexcept ; ``[link reference_optional_ref_assign_optional_U __GO_TO__]``
template<class R> optional& operator = (R&& r) noexcept ; ``[link reference_optional_ref_assign_R __GO_TO__]``
template<class R> optional& operator = (R&& r) noexcept ; ``[link reference_optional_ref_assign_R __GO_TO__]``
template<class R> void emplace ( R&& r ) noexcept ; ``[link reference_optional_ref_emplace_R __GO_TO__]``
T& get() const ; ``[link reference_optional_ref_get __GO_TO__]``
@ -245,22 +267,27 @@ They are empty, trivially copyable classes with disabled default constructor.
T* operator ->() const ; ``[link reference_optional_ref_arrow __GO_TO__]``
T& value() const& ; ``[link reference_optional_ref_value __GO_TO__]``
template<class R> T& value_or( R && r ) const noexcept ; ``[link reference_optional_ref_value_or __GO_TO__]``
template<class F> T& value_or_eval( F f ) const ; ``[link reference_optional_ref_value_or_eval __GO_TO__]``
template<class F> auto map( F f ) const -> ``['see below]``; ``[link reference_optional_ref_map __GO_TO__]``
template<class F> auto flat_map( F f ) const -> ``['see below]``; ``[link reference_optional_ref_flat_map __GO_TO__]``
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__]``
// deprecated methods
// (deprecated)
void reset() noexcept ; ``[link reference_optional_ref_reset __GO_TO__]``
// deprecated methods
// (deprecated)
template<class R> void reset ( R && r ) noexcept ; ``[link reference_optional_ref_reset_value __GO_TO__]``
@ -268,8 +295,8 @@ They are empty, trivially copyable classes with disabled default constructor.
bool is_initialized() const noexcept ; ``[link reference_optional_ref_is_initialized __GO_TO__]``
// (deprecated)
template<class R> T& get_value_or( R && r ) constnoexcept; ``[link reference_optional_ref_get_value_or_value __GO_TO__]``
template<class R> T& get_value_or( R && r ) constnoexcept; ``[link reference_optional_ref_get_value_or_value __GO_TO__]``
private:
T* ref; // exposition only
};

View File

@ -233,7 +233,7 @@ __SPACE__
arguments `std::forward<Args>(args)...`.
* [*Postconditions:] `*this` is initialized.
* [*Throws:] Any exception thrown by the selected constructor of `T`.
* [*Notes: ] `T` need not be __MOVE_CONSTRUCTIBLE__. On compilers that do not suppor variadic templates or rvalue references, this constuctor is available in limited functionality. For details [link optional_emplace_workaround see here].
* [*Notes: ] `T` need not be __MOVE_CONSTRUCTIBLE__. On compilers that do not suppor variadic templates or rvalue references, this constuctor is available in limited functionality. For details [link optional_emplace_workaround see here].
* [*Example:]
``
@ -257,7 +257,7 @@ __SPACE__
* [*Effect:] If `condition` is `true`, initializes the contained value as if direct-non-list-initializing an object of type `T` with the arguments `std::forward<Args>(args)...`.
* [*Postconditions:] `bool(*this) == condition`.
* [*Throws:] Any exception thrown by the selected constructor of `T`.
* [*Notes: ] `T` need not be __MOVE_CONSTRUCTIBLE__. On compilers that do not suppor variadic templates or rvalue references, this constuctor is available in limited functionality. For details [link optional_emplace_workaround see here].
* [*Notes: ] `T` need not be __MOVE_CONSTRUCTIBLE__. On compilers that do not suppor variadic templates or rvalue references, this constuctor is available in limited functionality. For details [link optional_emplace_workaround see here].
* [*Example:]
``
@ -376,13 +376,13 @@ __SPACE__
* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `CopyAssignable`.
* [*Effects:]
[table
[]
[]
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
[[[*`rhs` contains a value]][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
]
* [*Returns:] `*this`;
* [*Postconditions:] `bool(rhs) == bool(*this)`.
* [*Postconditions:] `bool(rhs) == bool(*this)`.
* [*Exception Safety:] If any exception is thrown, the initialization state of `*this` and `rhs` remains unchanged.
If an exception is thrown during the call to `T`'s copy constructor, no effect.
If an exception is thrown during the call to `T`'s copy assignment, the state of its contained value is as defined by the exception safety guarantee of `T`'s copy assignment.
@ -406,14 +406,14 @@ __SPACE__
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `MoveAssignable`.
* [*Effects:]
[table
[table
[]
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
[[[*`rhs` contains a value]][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
]
* [*Returns:] `*this`;
* [*Postconditions:] `bool(rhs) == bool(*this)`.
* [*Postconditions:] `bool(rhs) == bool(*this)`.
* [*Remarks:] The expression inside `noexcept` is equivalent to `is_nothrow_move_constructible<T>::value && is_nothrow_move_assignable<T>::value`.
* [*Exception Safety:] If any exception is thrown, the initialization state of `*this` and `rhs` remains unchanged. If an exception is
thrown during the call to `T`'s move constructor, the state of `*rhs` is determined by the exception safety guarantee
@ -437,15 +437,15 @@ __SPACE__
[: `template<U> optional& optional<T>::operator= ( optional<U> const& rhs ) ;`]
* [*Effect:]
[table
* [*Effect:]
[table
[]
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
[[[*`rhs` contains a value]][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
]
* [*Returns:] `*this`.
* [*Postconditions:] `bool(rhs) == bool(*this)`.
* [*Postconditions:] `bool(rhs) == bool(*this)`.
* [*Exception Safety:] If any exception is thrown, the result of the expression `bool(*this)` remains unchanged.
If an exception is thrown during the call to `T`'s constructor, no effect.
If an exception is thrown during the call to `T`'s assignment, the state of its contained value is as defined by the exception safety guarantee of `T`'s copy assignment.
@ -467,13 +467,13 @@ __SPACE__
* [*Effect:]
[table
[]
[]
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
[[[*`rhs` contains a value]][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
]
* [*Returns:] `*this`.
* [*Postconditions:] `bool(rhs) == bool(*this)`.
* [*Postconditions:] `bool(rhs) == bool(*this)`.
* [*Exception Safety:] If any exception is thrown, the result of the expression `bool(*this)` remains unchanged.
If an exception is thrown during the call to `T`'s constructor, no effect.
If an exception is thrown during the call to `T`'s assignment, the state of its contained value is as defined by the exception safety guarantee of `T`'s copy assignment.
@ -485,7 +485,7 @@ optional<U> opt1;
opt1 = std::move(opt0) ;
assert ( opt0 );
assert ( opt1 )
assert ( opt1 )
assert ( *opt1 == static_cast<U>(v) ) ;
``
@ -498,11 +498,11 @@ __SPACE__
* [*Requires:] The compiler supports rvalue references and variadic templates.
* [*Effect:] If `*this` is initialized calls `*this = none`.
Then initializes in-place the contained value as if direct-initializing an object
of type `T` with `std::forward<Args>(args)...`.
of type `T` with `std::forward<Args>(args)...`.
* [*Postconditions: ] `*this` is [_initialized].
* [*Throws:] Whatever the selected `T`'s constructor throws.
* [*Exception Safety:] If an exception is thrown during the initialization of `T`, `*this` is ['uninitialized].
* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`. On compilers that do not suppor variadic templates or rvalue references, this function is available in limited functionality. For details [link optional_emplace_workaround see here].
* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`. On compilers that do not suppor variadic templates or rvalue references, this function is available in limited functionality. For details [link optional_emplace_workaround see here].
* [*Example:]
``
T v;
@ -541,7 +541,7 @@ __SPACE__
[#reference_optional_reset]
[: `void optional<T>::reset() noexcept ;`]
* [*Deprecated:] Same as `operator=( none_t );`
* [*Effects:] Same as `operator=( none_t );`
__SPACE__
@ -685,6 +685,65 @@ __SPACE__
__SPACE__
[#reference_optional_map]
[: `template<class F> auto optional<T>::map(F f) const& -> `['see below]` ;`]
[: `template<class F> auto optional<T>::map(F f) & -> `['see below]` ;`]
* [*Effects:] `if (*this) return f(**this); else return none;`
* [*Notes:] The return type of these overloads is `optional<decltype(f(**this))>`. On compilers that do not support ref-qualifiers on member functions, these two (as well as the next one) overloads are replaced with good old const and non-const overloads.
* [*Example:]
``
auto length = [](const string& s){ return s.size(); };
optional<string> o1 {}, o2 {"cat"};
optional<size_t> os1 = o1.map(length), os2 = o2.map(length);
assert ( !os1 ) ;
assert ( os2 ) ;
assert ( *os2 == 3 ) ;
``
__SPACE__
[#reference_optional_map_move]
[: `template<class F> auto optional<T>::map(F f) && -> `['see below]` ;`]
* [*Effects:] `if (*this) return f(std::move(**this)); else return none;`
* [*Notes:] The return type of this overload is `optional<decltype(f(istd::move(**this)))>`.
__SPACE__
[#reference_optional_flat_map]
[: `template<class F> auto optional<T>::flat_map(F f) const& -> `['see below]` ;`]
[: `template<class F> auto optional<T>::flat_map(F f) & -> `['see below]` ;`]
* [*Requires:] The return type of expression `f(**this)` is `optional<U>` for some object or reference type `U`.
* [*Effects:] `if (*this) return f(**this); else return none;`
* [*Notes:] The return type of these overloads is `optional<U>`. On compilers that do not support ref-qualifiers on member functions, these two (as well as the next one) overloads are replaced with good old const and non-const overloads.
* [*Example:]
``
optional<char> first_char(const string& s) {
return s.empty() ? none : optional<char>(s[0]);
};
optional<string> o1 {}, o2 {"cat"};
optional<char> os1 = o1.flat_map(first_char), os2 = o2.flat_map(first_char);
assert ( !os1 ) ;
assert ( os2 ) ;
assert ( *os2 == 'c' ) ;
``
__SPACE__
[#reference_optional_flat_map_move]
[: `template<class F> auto optional<T>::flat_map(F f) && -> `['see below]` ;`]
* [*Requires:] The return type of expression `f(std::move(**this))` is `optional<U>` for some object or reference type `U`.
* [*Effects:] `if (*this) return f(std::move(**this)); else return none;`
* [*Notes:] The return type of this overload is `optional<U>`.
__SPACE__
[#reference_optional_get_value_or_value]
[: `T const& optional<T>::get_value_or( T const& default) const ;`]
@ -754,6 +813,7 @@ __SPACE__
[#reference_optional_operator_bool]
[: `explicit optional<T>::operator bool() const noexcept ;`]
[: `bool optional<T>::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.
@ -815,7 +875,7 @@ __SPACE__
[: `template<class R> optional<T&>::optional(R&& r) noexcept;`]
* [*Postconditions:] `bool(*this) == true`; `addressof(**this) == addressof(r)`.
* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed. This constructor does not participate in overload resolution if `decay<R>` is an instance of `boost::optional`.
* [*Notes:] This constructor is declared `explicit` on compilers that do not correctly suport binding to const lvalues of integral types. For more details [link optional_reference_binding see here].
* [*Notes:] This constructor is declared `explicit` on compilers that do not correctly suport binding to const lvalues of integral types. For more details [link optional_reference_binding see here].
* [*Example:]
``
T v;
@ -842,7 +902,7 @@ __SPACE__
[: `optional<T&>::optional ( optional const& rhs ) noexcept ;`]
* [*Effects: ] Initializes `ref` with expression `rhs.ref`.
* [*Postconditions:] `bool(*this) == bool(rhs)`.
* [*Example:]
@ -875,7 +935,7 @@ __SPACE__
* [*Requires:] `is_convertible<U&, T&>::value` is `true`.
* [*Effects: ] Initializes `ref` with expression `rhs.ref`.
* [*Postconditions:] `bool(*this) == bool(rhs)`.
@ -891,7 +951,7 @@ __SPACE__
* [*Postconditions:] `bool(*this) == false`.
[#reference_optional_ref_copy_assign]
@ -939,7 +999,7 @@ assert ( *ora == 4 ) ;
* [*returns:] `*this`.
* [*Postconditions:] `bool(*this) == bool(rhs)`.
__SPACE__
@ -950,7 +1010,7 @@ __SPACE__
* [*Effects: ] Assigns `ref` with expression `r`.
* [*returns:] `*this`.
* [*Postconditions:] `bool(*this) == true`.
* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed. This function does not participate in overload resolution if `decay<R>` is an instance of `boost::optional`.
@ -1015,13 +1075,13 @@ __SPACE__
[#reference_optional_ref_value]
[: `T& optional<T&>::value() const ;`]
* [*Effects:] Equivalent to `return bool(*this) ? *val : throw bad_optional_access();`.
* [*Effects:] Equivalent to `return bool(*this) ? *val : throw bad_optional_access();`.
__SPACE__
[#reference_optional_ref_value_or]
[: `template<class R> T& optional<T&>::value_or( R&& r ) const noexcept;`]
* [*Effects:] Equivalent to `if (*this) return **this; else return r;`.
* [*Effects:] Equivalent to `if (*this) return **this; else return r;`.
* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed.
__SPACE__
@ -1033,6 +1093,21 @@ __SPACE__
__SPACE__
[#reference_optional_ref_map]
[: `template<class F> auto optional<T&>::map( F f ) const -> `['see below]`;`]
* [*Effects:] Equivalent to `if (*this) return f(**this); else return none;`.
* [*Remarks:] The return type of this function is `optional<decltype(f(**this))>`.
__SPACE__
[#reference_optional_ref_flat_map]
[: `template<class F> auto optional<T&>::flat_map( F f ) const -> `['see below]`;`]
* [*Requires:] The return type of expression `f(**this)` is `optional<U>` for some object or reference type `U`.
* [*Effects:] Equivalent to `if (*this) return f(**this); else return none;`.
* [*Remarks:] The return type of this function is `optional<U>`.
__SPACE__
[#reference_optional_ref_get_ptr]
[: `T* optional<T&>::get_ptr () const noexcept;`]
* [*Returns:] `ref`.
@ -1040,6 +1115,7 @@ __SPACE__
__SPACE__
[#reference_optional_ref_operator_bool]
[: `bool has_value() const noexcept;`]
[: `optional<T&>::operator bool () const noexcept;`]
* [*Returns:] `bool(ref)`.
@ -1053,8 +1129,7 @@ __SPACE__
[#reference_optional_ref_reset]
[: `void optional<T&>::reset() noexcept;`]
* [*Effects:] Use `*this = none` instead.
* [*Remarks:] This function is depprecated.
* [*Effects:] Same as `*this = none`.
__SPACE__
@ -1074,9 +1149,9 @@ __SPACE__
[#reference_optional_ref_get_value_or_value]
[: `template<class R> T& optional<T&>::get_value_or( R&& r ) const noexcept;`]
* [*Effects:] Equivalent to `return value_or(std::forward<R>(r);`.
* [*Effects:] Equivalent to `return value_or(std::forward<R>(r);`.
* [*Remarks:] This function is depprecated.
[endsect]
@ -1097,6 +1172,15 @@ template<class T> void foo ( optional<T> const& opt ) ;
foo ( make_optional(1+1) ) ; // Creates an optional<int>
``
__SPACE__
[#reference_make_optional_rvalue]
[: `optional<std::decay_t<T>> make_optional( T && v )`]
* [*Returns: ] `optional<std::decay_t<T>>(std::move(v))` for the ['deduced] type `T` of `v`.
__SPACE__
[#reference_make_optional_bool_value]
@ -1117,6 +1201,15 @@ if ( !v )
error("foo wasn't computed");
``
__SPACE__
[#reference_make_optional_bool_rvalue]
[: `optional<std::decay_t<T>> make_optional( bool condition, T && v )`]
* [*Returns: ] `optional<std::decay_t<T>>(condition, std::move(v))` for the ['deduced] type `T` of `v`.
__SPACE__
[#reference_operator_compare_equal_optional_optional]
@ -1257,7 +1350,7 @@ __SPACE__
* [*Requires:] Lvalues of type `T` shall be swappable and `T` shall be __MOVE_CONSTRUCTIBLE__.
* [*Effects:]
[table
[table
[]
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
[[[*`rhs` contains a value]][calls `swap(*(*this), *rhs)`][initializes the contained value of `*this` as if direct-initializing an object of type `T` with the expression `std::move(*rhs)`, followed by `rhs.val->T::~T()`, `*this` contains a value and `rhs` does not contain a value]]
@ -1315,3 +1408,37 @@ assert (addressof(*opt0) == addressof(y));
``
[endsect]
[section Detailed Semantics - std::hash Specializations]
__SPACE__
[#reference_std_hash_spec]
``
namespace std {
template <typename T>
struct hash<boost::optional<T> > ;
template <typename T>
struct hash<boost::optional<T&> > ;
} // namespace std
``
The specialization `hash<optional<T>>` is enabled if and only if
`hash<remove_­const_­t<T>>` is enabled. When enabled, for an object `o`
of type `optional<T>`, if `o.has_­value() == true`, then `hash<optional<T>>()(o)`
evaluates to the same value as `hash<remove_­const_­t<T>>()(*o)`; otherwise it
evaluates to an unspecified value.
The member functions are not guaranteed to be `noexcept`.
[caution
You may get compiler errors when your program provides specializations for
`std::hash<boost::optional<T>>`. If this happens, define macro
`BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH` to suppress the specializations
of `std::hash` in this library.
]
[endsect]

View File

@ -1,7 +1,7 @@
[/
Boost.Optional
Copyright (c) 2015, 2016 Andrzej Krzemienski
Copyright (c) 2015 - 2022 Andrzej Krzemienski
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
@ -11,6 +11,59 @@
[section:relnotes Release Notes]
[heading Boost Release 1.80]
* [*Breaking change:] Added specializations for `std::hash<boost::opitonal<T>>`. This fixes [@https://github.com/boostorg/optional/issues/55 issue #55]. You may get compiler errors when your program provides specializations for `std::hash<boost::optional<T>>`. If this happens, define macro `BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH` to suppress the specializations of `std::hash` in this library.
[heading Boost Release 1.79]
* Fixed [@https://github.com/boostorg/optional/issues/98 issue #98].
[heading Boost Release 1.77]
* Fixed [@https://github.com/boostorg/optional/issues/92 issue #92].
[heading Boost Release 1.76]
* Fixed MSVC warning C4702.
[heading Boost Release 1.75]
* `boost::none` is `constexpr`-declared.
* Fixed [@https://github.com/boostorg/optional/issues/78 issue #78].
[heading Boost Release 1.73]
* Fixed [@https://github.com/boostorg/optional/issues/78 issue #78].
* `boost::none` is now declared as an inline variable (on compilers taht support it): there is only one instance of `boost::none` across all translation units.
* Fixed a number of compilation errors in GCC 4.4.7 in `optional<T>` for trivial `T`s. Thanks to Robert Leahy for the fix. For details see [@https://github.com/boostorg/optional/pull/80 pr #78].
* Now surpressing warning `-Wweak-vtables`.
[heading Boost Release 1.69]
* Remove deprecation mark from `reset()` method (without arguments).
* Fixed [@https://github.com/boostorg/optional/issues/59 issue #59].
* Fixed bug with initialization of certain wrapper types in clang with -std=c++03. See [@https://github.com/boostorg/optional/pull/64 pr #64].
[heading Boost Release 1.68]
* Added member function `has_value()` for compatibility with `std::optional` ([@https://github.com/boostorg/optional/issues/52 issue #52]).
* Added member function `map()` for transforming `optional<T>` into `optional<U>` using a function of type `T -> U`.
* Added member function `flat_map()` for transforming `optional<T>` into `optional<U>` using a function of type `T -> optonal<U>`.
[heading Boost Release 1.67]
* Fixed [@https://github.com/boostorg/optional/issues/46 issue #46].
* Fixed `-Wzero-as-null-pointer-constant` warnings.
[heading Boost Release 1.66]
* On newer compilers `optional` is now trivially-copyable for scalar `T`s. This uses a different storage (just `T` rather than `aligned_storage`). We require the compiler to support defaulted functions.
* Changed the implementation of `operator==` to get rid of the `-Wmaybe-uninitialized` false-positive warning from GCC.
[heading Boost Release 1.63]
* Added two new in-place constructors. They work similarly to `emplace()` functions: they initialize the contained value by perfect-forwarding the obtained arguments. One constructor always initializes the contained value, the other based on a boolean condition.
* Syntax `o = {}` now correctly un-initializes optional, just like in `std::optional`.
@ -53,7 +106,7 @@
* IOStream operators are now mentioned in documentation.
* Added a way to manually disable move semantics: just define macro `BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES`. This can be used to work around [@https://svn.boost.org/trac/boost/ticket/10399 Trac #10399].
* It is no longer possible to assign `optional<U>` to `optional<T>` when `U` is not assignable or convertible to `T` ([@https://svn.boost.org/trac/boost/ticket/11087 Trac #11087]).
* Value accessors now work correctly on rvalues of `optional<T&>` ([@https://svn.boost.org/trac/boost/ticket/10839 Trac #10839]).
* Value accessors now work correctly on rvalues of `optional<T&>` ([@https://svn.boost.org/trac/boost/ticket/10839 Trac #10839]).
[heading Boost Release 1.57]

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Acknowledgements</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../index.html" title="Boost.Optional">
<link rel="up" href="../index.html" title="Boost.Optional">
<link rel="prev" href="relnotes.html" title="Release Notes">
@ -116,7 +116,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Dependencies and Portability</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../index.html" title="Boost.Optional">
<link rel="up" href="../index.html" title="Boost.Optional">
<link rel="prev" href="reference/header__boost_optional_hpp_.html" title="Header &lt;boost/optional.hpp&gt;">
@ -77,7 +77,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Emplace operations in older compilers</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../dependencies_and_portability.html" title="Dependencies and Portability">
<link rel="prev" href="../dependencies_and_portability.html" title="Dependencies and Portability">
@ -76,7 +76,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Optional Reference Binding</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../dependencies_and_portability.html" title="Dependencies and Portability">
<link rel="prev" href="emplace_operations_in_older_compilers.html" title="Emplace operations in older compilers">
@ -93,7 +93,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quick Start</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../index.html" title="Boost.Optional">
<link rel="up" href="../index.html" title="Boost.Optional">
<link rel="prev" href="../index.html" title="Boost.Optional">
@ -155,7 +155,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bypassing unnecessary default construction</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../quick_start.html" title="Quick Start">
<link rel="prev" href="optional_data_members.html" title="Optional data members">
@ -61,7 +61,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Optional automatic variables</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../quick_start.html" title="Quick Start">
<link rel="prev" href="../quick_start.html" title="Quick Start">
@ -61,7 +61,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Optional data members</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../quick_start.html" title="Quick Start">
<link rel="prev" href="optional_automatic_variables.html" title="Optional automatic variables">
@ -80,7 +80,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Storage in containers</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../quick_start.html" title="Quick Start">
<link rel="prev" href="bypassing_unnecessary_default_construction.html" title="Bypassing unnecessary default construction">
@ -50,7 +50,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Header &lt;boost/optional/bad_optional_access.hpp&gt;</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/reference.html" title="Reference">
<link rel="prev" href="../../optional/reference.html" title="Reference">
@ -49,7 +49,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Detailed semantics</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../header__boost_optional_bad_optional_access_hpp_.html" title="Header &lt;boost/optional/bad_optional_access.hpp&gt;">
<link rel="prev" href="../header__boost_optional_bad_optional_access_hpp_.html" title="Header &lt;boost/optional/bad_optional_access.hpp&gt;">
@ -46,7 +46,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Header &lt;boost/optional.hpp&gt;</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/reference.html" title="Reference">
<link rel="prev" href="header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html" title="Detailed Semantics - Free Functions">
@ -33,7 +33,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Header &lt;boost/optional/optional_fwd.hpp&gt;</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/reference.html" title="Reference">
<link rel="prev" href="io_header/io_semantics.html" title="Detailed semantics">
@ -52,7 +52,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Detailed Semantics - Free Functions</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header &lt;boost/optional/optional.hpp&gt;">
<link rel="prev" href="detailed_semantics___optional_references.html" title="Detailed Semantics - Optional References">
@ -47,6 +47,19 @@
</pre>
</li>
</ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
<a name="reference_make_optional_rvalue"></a><div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span>
<span class="identifier">make_optional</span><span class="special">(</span>
<span class="identifier">T</span> <span class="special">&amp;&amp;</span>
<span class="identifier">v</span> <span class="special">)</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
<span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">v</span><span class="special">))</span></code> for the <span class="emphasis"><em>deduced</em></span>
type <code class="computeroutput"><span class="identifier">T</span></code> of <code class="computeroutput"><span class="identifier">v</span></code>.
</li></ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
@ -73,6 +86,19 @@
</pre>
</li>
</ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
<a name="reference_make_optional_bool_rvalue"></a><div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span>
<span class="identifier">make_optional</span><span class="special">(</span>
<span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="special">&amp;&amp;</span> <span class="identifier">v</span>
<span class="special">)</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
<span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;(</span><span class="identifier">condition</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">v</span><span class="special">))</span></code> for the <span class="emphasis"><em>deduced</em></span>
type <code class="computeroutput"><span class="identifier">T</span></code> of <code class="computeroutput"><span class="identifier">v</span></code>.
</li></ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
@ -481,7 +507,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Detailed Semantics - Optional References</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header &lt;boost/optional/optional.hpp&gt;">
<link rel="prev" href="detailed_semantics___optional_values.html" title="Detailed Semantics - Optional Values">
@ -407,6 +407,45 @@
is ill-formed.
</li>
</ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
<a name="reference_optional_ref_map"></a><div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="identifier">map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">-&gt;</span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput"><span class="special">;</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><span class="keyword">if</span> <span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">);</span> <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">none</span><span class="special">;</span></code>.
</li>
<li class="listitem">
<span class="bold"><strong>Remarks:</strong></span> The return type of this function
is <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">))&gt;</span></code>.
</li>
</ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
<a name="reference_optional_ref_flat_map"></a><div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="identifier">flat_map</span><span class="special">(</span>
<span class="identifier">F</span> <span class="identifier">f</span>
<span class="special">)</span> <span class="keyword">const</span>
<span class="special">-&gt;</span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput"><span class="special">;</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Requires:</strong></span> The return type of expression
<code class="computeroutput"><span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">)</span></code>
is <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code>
for some object or reference type <code class="computeroutput"><span class="identifier">U</span></code>.
</li>
<li class="listitem">
<span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><span class="keyword">if</span> <span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">);</span> <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">none</span><span class="special">;</span></code>.
</li>
<li class="listitem">
<span class="bold"><strong>Remarks:</strong></span> The return type of this function
is <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code>.
</li>
</ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
@ -422,6 +461,9 @@
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
<a name="reference_optional_ref_operator_bool"></a><div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">bool</span> <span class="identifier">has_value</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></code>
</p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="keyword">operator</span> <span class="keyword">bool</span>
<span class="special">()</span> <span class="keyword">const</span>
<span class="keyword">noexcept</span><span class="special">;</span></code>
@ -444,14 +486,9 @@
<a name="reference_optional_ref_reset"></a><div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">void</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="identifier">reset</span><span class="special">()</span> <span class="keyword">noexcept</span><span class="special">;</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Effects:</strong></span> Use <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span> <span class="special">=</span> <span class="identifier">none</span></code> instead.
</li>
<li class="listitem">
<span class="bold"><strong>Remarks:</strong></span> This function is depprecated.
</li>
</ul></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
<span class="bold"><strong>Effects:</strong></span> Same as <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span> <span class="special">=</span> <span class="identifier">none</span></code>.
</li></ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
@ -501,7 +538,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Detailed Semantics - Optional Values</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header &lt;boost/optional/optional.hpp&gt;">
<link rel="prev" href="header_optional_optional_refs.html" title="Optional References">
@ -1199,8 +1199,8 @@
<span class="special">;</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
<span class="bold"><strong>Deprecated:</strong></span> Same as <code class="computeroutput"><span class="keyword">operator</span><span class="special">=(</span>
<span class="identifier">none_t</span> <span class="special">);</span></code>
<span class="bold"><strong>Effects:</strong></span> Same as <code class="computeroutput"><span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">none_t</span>
<span class="special">);</span></code>
</li></ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
@ -1471,6 +1471,126 @@
ref-qualifiers on member functions this overload is not present.
</li>
</ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
<a name="reference_optional_map"></a><div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">-&gt;</span>
</code><span class="emphasis"><em>see below</em></span><code class="computeroutput"> <span class="special">;</span></code>
</p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">&amp;</span> <span class="special">-&gt;</span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput">
<span class="special">;</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">);</span> <span class="keyword">else</span> <span class="keyword">return</span>
<span class="identifier">none</span><span class="special">;</span></code>
</li>
<li class="listitem">
<span class="bold"><strong>Notes:</strong></span> The return type of these overloads
is <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">))&gt;</span></code>.
On compilers that do not support ref-qualifiers on member functions,
these two (as well as the next one) overloads are replaced with good
old const and non-const overloads.
</li>
<li class="listitem">
<span class="bold"><strong>Example:</strong></span>
<pre class="programlisting"><span class="keyword">auto</span> <span class="identifier">length</span> <span class="special">=</span> <span class="special">[](</span><span class="keyword">const</span> <span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">s</span><span class="special">){</span> <span class="keyword">return</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">};</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span> <span class="identifier">o1</span> <span class="special">{},</span> <span class="identifier">o2</span> <span class="special">{</span><span class="string">"cat"</span><span class="special">};</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">size_t</span><span class="special">&gt;</span> <span class="identifier">os1</span> <span class="special">=</span> <span class="identifier">o1</span><span class="special">.</span><span class="identifier">map</span><span class="special">(</span><span class="identifier">length</span><span class="special">),</span> <span class="identifier">os2</span> <span class="special">=</span> <span class="identifier">o2</span><span class="special">.</span><span class="identifier">map</span><span class="special">(</span><span class="identifier">length</span><span class="special">);</span>
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">os1</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">os2</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">os2</span> <span class="special">==</span> <span class="number">3</span> <span class="special">)</span> <span class="special">;</span>
</pre>
</li>
</ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
<a name="reference_optional_map_move"></a><div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">&amp;&amp;</span>
<span class="special">-&gt;</span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput">
<span class="special">;</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(**</span><span class="keyword">this</span><span class="special">));</span> <span class="keyword">else</span> <span class="keyword">return</span>
<span class="identifier">none</span><span class="special">;</span></code>
</li>
<li class="listitem">
<span class="bold"><strong>Notes:</strong></span> The return type of this overload
is <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="identifier">istd</span><span class="special">::</span><span class="identifier">move</span><span class="special">(**</span><span class="keyword">this</span><span class="special">)))&gt;</span></code>.
</li>
</ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
<a name="reference_optional_flat_map"></a><div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">flat_map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">-&gt;</span>
</code><span class="emphasis"><em>see below</em></span><code class="computeroutput"> <span class="special">;</span></code>
</p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">flat_map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">&amp;</span> <span class="special">-&gt;</span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput">
<span class="special">;</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Requires:</strong></span> The return type of expression
<code class="computeroutput"><span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">)</span></code>
is <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code>
for some object or reference type <code class="computeroutput"><span class="identifier">U</span></code>.
</li>
<li class="listitem">
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">);</span> <span class="keyword">else</span> <span class="keyword">return</span>
<span class="identifier">none</span><span class="special">;</span></code>
</li>
<li class="listitem">
<span class="bold"><strong>Notes:</strong></span> The return type of these overloads
is <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code>.
On compilers that do not support ref-qualifiers on member functions,
these two (as well as the next one) overloads are replaced with good
old const and non-const overloads.
</li>
<li class="listitem">
<span class="bold"><strong>Example:</strong></span>
<pre class="programlisting"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt;</span> <span class="identifier">first_char</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">s</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">?</span> <span class="identifier">none</span> <span class="special">:</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt;(</span><span class="identifier">s</span><span class="special">[</span><span class="number">0</span><span class="special">]);</span>
<span class="special">};</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span> <span class="identifier">o1</span> <span class="special">{},</span> <span class="identifier">o2</span> <span class="special">{</span><span class="string">"cat"</span><span class="special">};</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt;</span> <span class="identifier">os1</span> <span class="special">=</span> <span class="identifier">o1</span><span class="special">.</span><span class="identifier">flat_map</span><span class="special">(</span><span class="identifier">first_char</span><span class="special">),</span> <span class="identifier">os2</span> <span class="special">=</span> <span class="identifier">o2</span><span class="special">.</span><span class="identifier">flat_map</span><span class="special">(</span><span class="identifier">first_char</span><span class="special">);</span>
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">os1</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">os2</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">os2</span> <span class="special">==</span> <span class="char">'c'</span> <span class="special">)</span> <span class="special">;</span>
</pre>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</li>
</ul></div>
<a name="reference_optional_flat_map_move"></a><div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">flat_map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">&amp;&amp;</span>
<span class="special">-&gt;</span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput">
<span class="special">;</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Requires:</strong></span> The return type of expression
<code class="computeroutput"><span class="identifier">f</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(**</span><span class="keyword">this</span><span class="special">))</span></code>
is <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code>
for some object or reference type <code class="computeroutput"><span class="identifier">U</span></code>.
</li>
<li class="listitem">
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(**</span><span class="keyword">this</span><span class="special">));</span> <span class="keyword">else</span> <span class="keyword">return</span>
<span class="identifier">none</span><span class="special">;</span></code>
</li>
<li class="listitem">
<span class="bold"><strong>Notes:</strong></span> The return type of this overload
is <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code>.
</li>
</ul></div>
<p>
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
</p>
@ -1592,6 +1712,9 @@
<span class="keyword">const</span> <span class="keyword">noexcept</span>
<span class="special">;</span></code>
</p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="keyword">bool</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">has_value</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span></code>
</p></blockquote></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="identifier">get_ptr</span><span class="special">()</span> <span class="special">!=</span> <span class="number">0</span></code>.
@ -1651,7 +1774,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Initialization tags</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header &lt;boost/optional/optional.hpp&gt;">
<link rel="prev" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header &lt;boost/optional/optional.hpp&gt;">
@ -47,7 +47,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Optional References</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header &lt;boost/optional/optional.hpp&gt;">
<link rel="prev" href="header_optional_optional_values.html" title="Optional Values">
@ -53,7 +53,6 @@
<span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">none_t</span> <span class="special">)</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_assign_none_t"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_copy_assign"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&amp;&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_assign_optional_U"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
@ -73,17 +72,22 @@
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">value_or_eval</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_value_or_eval"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">-&gt;</span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">flat_map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">-&gt;</span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_flat_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span><span class="special">*</span> <span class="identifier">get_ptr</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_get_ptr"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">bool</span> <span class="identifier">has_value</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_operator_bool"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">explicit</span> <span class="keyword">operator</span> <span class="keyword">bool</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_operator_bool"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_operator_not"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="comment">// deprecated methods</span>
<span class="comment">// (deprecated)</span>
<span class="keyword">void</span> <span class="identifier">reset</span><span class="special">()</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_reset"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="comment">// deprecated methods</span>
<span class="comment">// (deprecated)</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">&gt;</span> <span class="keyword">void</span> <span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">R</span> <span class="special">&amp;&amp;</span> <span class="identifier">r</span> <span class="special">)</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_reset_value"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
@ -100,7 +104,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Optional Values</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header &lt;boost/optional/optional.hpp&gt;">
<link rel="prev" href="header_optional_in_place_init.html" title="Initialization tags">
@ -105,18 +105,27 @@
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="identifier">T</span> <span class="identifier">value_or_eval</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_value_or_call"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="identifier">T</span> <span class="identifier">value_or_eval</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">&amp;&amp;</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_value_or_call_move"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">-&gt;</span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">&amp;</span> <span class="special">-&gt;</span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">&amp;&amp;</span> <span class="special">-&gt;</span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_map_move"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">flat_map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">-&gt;</span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_flat_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">flat_map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">&amp;</span> <span class="special">-&gt;</span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_flat_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span> <span class="keyword">auto</span> <span class="identifier">flat_map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">&amp;&amp;</span> <span class="special">-&gt;</span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_flat_map_move"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">get_ptr</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span><span class="special">*</span> <span class="identifier">get_ptr</span><span class="special">()</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">bool</span> <span class="identifier">has_value</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_operator_bool"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">explicit</span> <span class="keyword">operator</span> <span class="keyword">bool</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_operator_bool"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_operator_not"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="comment">// deprecated methods</span>
<span class="comment">// (deprecated)</span>
<span class="keyword">void</span> <span class="identifier">reset</span><span class="special">()</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_reset"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
<span class="comment">// deprecated methods</span>
<span class="comment">// (deprecated)</span>
<span class="keyword">void</span> <span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_reset_value"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
@ -130,7 +139,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Header &lt;boost/optional/optional_io.hpp&gt;</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/reference.html" title="Reference">
<link rel="prev" href="header__boost_optional_bad_optional_access_hpp_/detailed_semantics.html" title="Detailed semantics">
@ -58,7 +58,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Detailed semantics</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../io_header.html" title="Header &lt;boost/optional/optional_io.hpp&gt;">
<link rel="prev" href="../io_header.html" title="Header &lt;boost/optional/optional_io.hpp&gt;">
@ -32,7 +32,7 @@
<span class="special">&lt;</span><span class="keyword">class</span>
<span class="identifier">CharType</span><span class="special">,</span>
<span class="keyword">class</span> <span class="identifier">CharTrait</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span></code>
<br> &#160;&#160;&#160;&#160;<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span></code> <br> &#160;&#160;&#160;&#160;<code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;&lt;(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span>
<br>     <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span></code> <br>     <code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;&lt;(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span>
<span class="identifier">out</span><span class="special">,</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span><span class="special">);</span></code>
</p>
@ -53,8 +53,8 @@
</p>
<p>
<code class="computeroutput"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">CharType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">CharTrait</span><span class="special">,</span>
<span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span></code> <br> &#160;&#160;&#160;&#160;<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span></code>
<br> &#160;&#160;&#160;&#160;<code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;&lt;(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span> <span class="identifier">out</span><span class="special">,</span> <span class="identifier">none_t</span><span class="special">);</span></code>
<span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span></code> <br>     <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span></code>
<br>     <code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;&lt;(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span> <span class="identifier">out</span><span class="special">,</span> <span class="identifier">none_t</span><span class="special">);</span></code>
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
@ -70,8 +70,8 @@
</p>
<p>
<code class="computeroutput"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">CharType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">CharTrait</span><span class="special">,</span>
<span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span></code> <br> &#160;&#160;&#160;&#160;<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span></code>
<br> &#160;&#160;&#160;&#160;<code class="computeroutput"><span class="keyword">operator</span><span class="special">&gt;&gt;(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_istream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span> <span class="identifier">in</span><span class="special">,</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;</span> <span class="identifier">v</span><span class="special">);</span></code>
<span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span></code> <br>     <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span></code>
<br>     <code class="computeroutput"><span class="keyword">operator</span><span class="special">&gt;&gt;(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_istream</span><span class="special">&lt;</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">&gt;&amp;</span> <span class="identifier">in</span><span class="special">,</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;</span> <span class="identifier">v</span><span class="special">);</span></code>
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
@ -98,7 +98,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Release Notes</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../index.html" title="Boost.Optional">
<link rel="up" href="../index.html" title="Boost.Optional">
<link rel="prev" href="dependencies_and_portability/optional_reference_binding.html" title="Optional Reference Binding">
@ -28,6 +28,136 @@
</h2></div></div></div>
<h4>
<a name="boost_optional.relnotes.h0"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_79"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_79">Boost
Release 1.79</a>
</h4>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Fixed <a href="https://github.com/boostorg/optional/issues/98" target="_top">issue
#98</a>.
</li></ul></div>
<h4>
<a name="boost_optional.relnotes.h1"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_77"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_77">Boost
Release 1.77</a>
</h4>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Fixed <a href="https://github.com/boostorg/optional/issues/92" target="_top">issue
#92</a>.
</li></ul></div>
<h4>
<a name="boost_optional.relnotes.h2"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_76"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_76">Boost
Release 1.76</a>
</h4>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Fixed MSVC warning C4702.
</li></ul></div>
<h4>
<a name="boost_optional.relnotes.h3"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_75"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_75">Boost
Release 1.75</a>
</h4>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code> is <code class="computeroutput"><span class="keyword">constexpr</span></code>-declared.
</li>
<li class="listitem">
Fixed <a href="https://github.com/boostorg/optional/issues/78" target="_top">issue
#78</a>.
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h4"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_73"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_73">Boost
Release 1.73</a>
</h4>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Fixed <a href="https://github.com/boostorg/optional/issues/78" target="_top">issue
#78</a>.
</li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code> is now declared as an inline variable
(on compilers taht support it): there is only one instance of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code> across all translation units.
</li>
<li class="listitem">
Fixed a number of compilation errors in GCC 4.4.7 in <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> for trivial <code class="computeroutput"><span class="identifier">T</span></code>s.
Thanks to Robert Leahy for the fix. For details see <a href="https://github.com/boostorg/optional/pull/80" target="_top">pr
#78</a>.
</li>
<li class="listitem">
Now surpressing warning <code class="computeroutput"><span class="special">-</span><span class="identifier">Wweak</span><span class="special">-</span><span class="identifier">vtables</span></code>.
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h5"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_69"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_69">Boost
Release 1.69</a>
</h4>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Remove deprecation mark from <code class="computeroutput"><span class="identifier">reset</span><span class="special">()</span></code> method (without arguments).
</li>
<li class="listitem">
Fixed <a href="https://github.com/boostorg/optional/issues/59" target="_top">issue
#59</a>.
</li>
<li class="listitem">
Fixed bug with initialization of certain wrapper types in clang with -std=c++03.
See <a href="https://github.com/boostorg/optional/pull/64" target="_top">pr #64</a>.
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h6"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_68"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_68">Boost
Release 1.68</a>
</h4>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Added member function <code class="computeroutput"><span class="identifier">has_value</span><span class="special">()</span></code> for compatibility with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">optional</span></code> (<a href="https://github.com/boostorg/optional/issues/52" target="_top">issue
#52</a>).
</li>
<li class="listitem">
Added member function <code class="computeroutput"><span class="identifier">map</span><span class="special">()</span></code> for transforming <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> into <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code> using a function of type <code class="computeroutput"><span class="identifier">T</span> <span class="special">-&gt;</span> <span class="identifier">U</span></code>.
</li>
<li class="listitem">
Added member function <code class="computeroutput"><span class="identifier">flat_map</span><span class="special">()</span></code> for transforming <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> into <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code> using a function of type <code class="computeroutput"><span class="identifier">T</span> <span class="special">-&gt;</span> <span class="identifier">optonal</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code>.
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h7"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_67"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_67">Boost
Release 1.67</a>
</h4>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Fixed <a href="https://github.com/boostorg/optional/issues/46" target="_top">issue
#46</a>.
</li>
<li class="listitem">
Fixed <code class="computeroutput"><span class="special">-</span><span class="identifier">Wzero</span><span class="special">-</span><span class="identifier">as</span><span class="special">-</span><span class="identifier">null</span><span class="special">-</span><span class="identifier">pointer</span><span class="special">-</span><span class="identifier">constant</span></code> warnings.
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h8"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_66"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_66">Boost
Release 1.66</a>
</h4>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
On newer compilers <code class="computeroutput"><span class="identifier">optional</span></code>
is now trivially-copyable for scalar <code class="computeroutput"><span class="identifier">T</span></code>s.
This uses a different storage (just <code class="computeroutput"><span class="identifier">T</span></code>
rather than <code class="computeroutput"><span class="identifier">aligned_storage</span></code>).
We require the compiler to support defaulted functions.
</li>
<li class="listitem">
Changed the implementation of <code class="computeroutput"><span class="keyword">operator</span><span class="special">==</span></code> to get rid of the <code class="computeroutput"><span class="special">-</span><span class="identifier">Wmaybe</span><span class="special">-</span><span class="identifier">uninitialized</span></code> false-positive warning
from GCC.
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h9"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_63"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_63">Boost
Release 1.63</a>
</h4>
@ -51,7 +181,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h1"></a>
<a name="boost_optional.relnotes.h10"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_62"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_62">Boost
Release 1.62</a>
</h4>
@ -59,7 +189,7 @@
Fixed <a href="https://svn.boost.org/trac/boost/ticket/12179" target="_top">Trac #12179</a>.
</li></ul></div>
<h4>
<a name="boost_optional.relnotes.h2"></a>
<a name="boost_optional.relnotes.h11"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_61"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_61">Boost
Release 1.61</a>
</h4>
@ -102,7 +232,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h3"></a>
<a name="boost_optional.relnotes.h12"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_60"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_60">Boost
Release 1.60</a>
</h4>
@ -113,7 +243,7 @@
#11203</a>.
</li></ul></div>
<h4>
<a name="boost_optional.relnotes.h4"></a>
<a name="boost_optional.relnotes.h13"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_59"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_59">Boost
Release 1.59</a>
</h4>
@ -127,7 +257,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h5"></a>
<a name="boost_optional.relnotes.h14"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_58"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_58">Boost
Release 1.58</a>
</h4>
@ -163,7 +293,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h6"></a>
<a name="boost_optional.relnotes.h15"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_57"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_57">Boost
Release 1.57</a>
</h4>
@ -173,7 +303,7 @@
to fix C++03 compile error on <code class="computeroutput"><span class="identifier">logic_error</span><span class="special">(</span><span class="string">"..."</span><span class="special">)</span></code>"</em></span>.
</li></ul></div>
<h4>
<a name="boost_optional.relnotes.h7"></a>
<a name="boost_optional.relnotes.h16"></a>
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_56"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_56">Boost
Release 1.56</a>
</h4>
@ -230,7 +360,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Design Overview</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
<link rel="prev" href="../../optional/tutorial.html" title="Tutorial">
@ -65,8 +65,8 @@
<code class="computeroutput"><span class="identifier">npos</span></code>, -1, etc... This is
equivalent to adding the special value to the set of possible values of
a given type. This super set of <code class="computeroutput"><span class="identifier">T</span></code>
plus some <span class="emphasis"><em>nil_t</em></span>&#8212;where <code class="computeroutput"><span class="identifier">nil_t</span></code>
is some stateless POD&#8212;can be modeled in modern languages as a <span class="bold"><strong>discriminated union</strong></span> of T and nil_t. Discriminated
plus some <span class="emphasis"><em>nil_t</em></span>where <code class="computeroutput"><span class="identifier">nil_t</span></code>
is some stateless PODcan be modeled in modern languages as a <span class="bold"><strong>discriminated union</strong></span> of T and nil_t. Discriminated
unions are often called <span class="emphasis"><em>variants</em></span>. A variant has a
<span class="emphasis"><em>current type</em></span>, which in our case is either <code class="computeroutput"><span class="identifier">T</span></code> or <code class="computeroutput"><span class="identifier">nil_t</span></code>.
Using the <a href="../../../../../variant/index.html" target="_top">Boost.Variant</a>
@ -100,8 +100,8 @@
</p>
<p>
In any event, both the discriminated-union or the single-element container
models serve as a conceptual ground for a class representing optional&#8212;i.e.
possibly uninitialized&#8212;objects. For instance, these models show the
models serve as a conceptual ground for a class representing optionali.e.
possibly uninitializedobjects. For instance, these models show the
<span class="emphasis"><em>exact</em></span> semantics required for a wrapper of optional
values:
</p>
@ -170,7 +170,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>The Interface</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../design_overview.html" title="Design Overview">
<link rel="prev" href="the_semantics.html" title="The semantics">
@ -79,7 +79,7 @@
facto</em></span> standard for handling optional objects because all you
have to do to refer to a value which you don't really have is to use a
null pointer value of the appropriate type. Pointers have been used for
decades&#8212;from the days of C APIs to modern C++ libraries&#8212;to <span class="emphasis"><em>refer</em></span>
decadesfrom the days of C APIs to modern C++ librariesto <span class="emphasis"><em>refer</em></span>
to optional (that is, possibly nonexistent) objects; particularly as optional
arguments to a function, but also quite often as optional data members.
</p>
@ -93,7 +93,7 @@
and this information is tied to the <span class="emphasis"><em>syntax</em></span> of the
expressions. That is, the presence of operators <code class="computeroutput"><span class="special">*</span></code>
and <code class="computeroutput"><span class="special">-&gt;</span></code> tell by themselves
&#8212;without any additional context&#8212; that the expression will be undefined
without any additional context that the expression will be undefined
unless the implied pointee actually exist.
</p>
<p>
@ -173,7 +173,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>The semantics</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../design_overview.html" title="Design Overview">
<link rel="prev" href="../design_overview.html" title="Design Overview">
@ -107,7 +107,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Exception Safety Guarantees</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
<link rel="prev" href="gotchas/false_positive_with__wmaybe_uninitialized.html" title="False positive with -Wmaybe-uninitialized">
@ -161,7 +161,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Gotchas</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
<link rel="prev" href="in_place_factories.html" title="In-Place Factories">
@ -37,7 +37,7 @@
</p>
<p>
First, it is functionally similar to a tristate boolean (false, maybe,
true) &#8212;such as <a href="../../../../../../doc/html/tribool.html" target="_top">boost::tribool</a>&#8212;
true) such as <a href="../../../../../../doc/html/tribool.html" target="_top">boost::tribool</a>
except that in a tristate boolean, the maybe state <span class="underline">represents
a valid value</span>, unlike the corresponding state of an uninitialized
<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code>.
@ -98,7 +98,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>False positive with -Wmaybe-uninitialized</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../gotchas.html" title="Gotchas">
<link rel="prev" href="mixed_relational_comparisons.html" title="Mixed relational comparisons">
@ -55,7 +55,7 @@
Stack Overflow question</a>) use the following way of initializing
an optional containing no value:
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">b</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">make_optional</span><span class="special">(</span><span class="keyword">false</span><span class="special">,</span> <span class="keyword">int</span><span class="special">());</span>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">b</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_optional</span><span class="special">(</span><span class="keyword">false</span><span class="special">,</span> <span class="keyword">int</span><span class="special">());</span>
</pre>
<p>
This is obviously redundant, but makes the warning disappear.
@ -63,7 +63,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Mixed relational comparisons</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../gotchas.html" title="Gotchas">
<link rel="prev" href="moved_from__optional_.html" title="Moved-from optional">
@ -45,7 +45,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Moved-from optional</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../gotchas.html" title="Gotchas">
<link rel="prev" href="../gotchas.html" title="Gotchas">
@ -49,7 +49,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>In-Place Factories</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
<link rel="prev" href="optional_references/rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references">
@ -183,7 +183,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>IO operators</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
<link rel="prev" href="relational_operators.html" title="Relational operators">
@ -73,7 +73,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Optional references</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
<link rel="prev" href="io_operators.html" title="IO operators">
@ -103,7 +103,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Rebinding semantics for assignment of optional references</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../../index.html" title="Boost.Optional">
<link rel="up" href="../optional_references.html" title="Optional references">
<link rel="prev" href="../optional_references.html" title="Optional references">
@ -133,7 +133,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Performance considerations</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
<link rel="prev" href="type_requirements.html" title="Type requirements">
@ -29,7 +29,8 @@
</h3></div></div></div>
<p>
Technical details aside, the memory layout of <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>
is more-less this:
for a generic <code class="computeroutput"><span class="identifier">T</span></code> is more-less
this:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">optional</span>
@ -39,8 +40,49 @@
<span class="special">};</span>
</pre>
<p>
But for the purpose of this analysis, considering memory layouts, we can
think of it as:
Lifetime of the <code class="computeroutput"><span class="identifier">T</span></code> inside
<code class="computeroutput"><span class="identifier">_storage</span></code> is manually controlled
with placement-<code class="computeroutput"><span class="keyword">new</span></code>s and pseudo-destructor
calls. However, for scalar <code class="computeroutput"><span class="identifier">T</span></code>s
we use a different way of storage, by simply holding a <code class="computeroutput"><span class="identifier">T</span></code>:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">optional</span>
<span class="special">{</span>
<span class="keyword">bool</span> <span class="identifier">_initialized</span><span class="special">;</span>
<span class="identifier">T</span> <span class="identifier">_storage</span><span class="special">;</span>
<span class="special">};</span>
</pre>
<p>
We call it a <span class="emphasis"><em>direct</em></span> storage. This makes <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> a
trivially-copyable type for scalar <code class="computeroutput"><span class="identifier">T</span></code>s.
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 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>
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 <code class="computeroutput"><span class="identifier">optional</span></code> as candidate
for optimized storage, by specializing type trait <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">opitonal_config</span><span class="special">::</span><span class="identifier">optional_uses_direct_storage_for</span></code>:
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">X</span> <span class="comment">// not trivial</span>
<span class="special">{</span>
<span class="identifier">X</span><span class="special">()</span> <span class="special">{}</span>
<span class="special">};</span>
<span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">optional_config</span> <span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;&gt;</span> <span class="keyword">struct</span> <span class="identifier">optional_uses_direct_storage_for</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;</span> <span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">true_type</span> <span class="special">{};</span>
<span class="special">}}</span>
</pre>
<h5>
<a name="boost_optional.tutorial.performance_considerations.h0"></a>
<span class="phrase"><a name="boost_optional.tutorial.performance_considerations.controlling_the_size"></a></span><a class="link" href="performance_considerations.html#boost_optional.tutorial.performance_considerations.controlling_the_size">Controlling
the size</a>
</h5>
<p>
For the purpose of the following analysis, considering memory layouts, we
can think of it as:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">optional</span>
@ -143,7 +185,7 @@
<span class="inlinemediaobject"><img src="../../images/opt_align4.png" alt="opt_align4"></span>
</p>
<h5>
<a name="boost_optional.tutorial.performance_considerations.h0"></a>
<a name="boost_optional.tutorial.performance_considerations.h1"></a>
<span class="phrase"><a name="boost_optional.tutorial.performance_considerations.optional_function_parameters"></a></span><a class="link" href="performance_considerations.html#boost_optional.tutorial.performance_considerations.optional_function_parameters">Optional
function parameters</a>
</h5>
@ -209,7 +251,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Relational operators</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
<link rel="prev" href="when_to_use_optional.html" title="When to use Optional">
@ -99,7 +99,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Type requirements</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
<link rel="prev" href="exception_safety_guarantees.html" title="Exception Safety Guarantees">
@ -95,7 +95,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>When to use Optional</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
<link rel="prev" href="design_overview/the_interface.html" title="The Interface">
@ -128,7 +128,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Boost.Optional</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="Boost.Optional">
<link rel="next" href="boost_optional/quick_start.html" title="Quick Start">
</head>
@ -25,8 +25,8 @@
<div><div class="author"><h3 class="author">
<span class="firstname">Fernando Luis</span> <span class="surname">Cacciola Carballal</span>
</h3></div></div>
<div><p class="copyright">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal</p></div>
<div><p class="copyright">Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski</p></div>
<div><p class="copyright">Copyright © 2003-2007 Fernando Luis Cacciola Carballal</p></div>
<div><p class="copyright">Copyright © 2014-2021 Andrzej Krzemieński</p></div>
<div><div class="legalnotice">
<a name="optional.legal"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
@ -145,7 +145,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: November 24, 2016 at 22:27:48 GMT</small></p></td>
<td align="left"><p><small>Last revised: November 20, 2021 at 00:57:52 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Reference</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../index.html" title="Boost.Optional">
<link rel="up" href="../index.html" title="Boost.Optional">
<link rel="prev" href="../boost_optional/tutorial/performance_considerations.html" title="Performance considerations">
@ -54,7 +54,7 @@
<span class="keyword">class</span> <span class="identifier">none_t</span> <span class="special">{/*</span> <span class="identifier">see</span> <span class="identifier">below</span> <span class="special">*/};</span>
<span class="keyword">const</span> <span class="identifier">none_t</span> <span class="identifier">none</span> <span class="special">(/*</span> <span class="identifier">see</span> <span class="identifier">below</span> <span class="special">*/);</span>
<span class="keyword">inline</span> <span class="keyword">constexpr</span> <span class="identifier">none_t</span> <span class="identifier">none</span> <span class="special">(/*</span> <span class="identifier">see</span> <span class="identifier">below</span> <span class="special">*/);</span>
<span class="special">}</span> <span class="comment">// namespace boost</span>
</pre>
@ -75,7 +75,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Header &lt;boost/optional/optional.hpp&gt;</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../../index.html" title="Boost.Optional">
<link rel="up" href="../reference.html" title="Reference">
<link rel="prev" href="../../boost_optional/reference/header__boost_optional_optional_fwd_hpp_.html" title="Header &lt;boost/optional/optional_fwd.hpp&gt;">
@ -65,8 +65,12 @@
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_make_optional_value"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="special">&amp;&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_make_optional_rvalue"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_make_optional_bool_value"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="special">&amp;&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_make_optional_bool_rvalue"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="keyword">auto</span> <span class="identifier">get_optional_value_or</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">opt</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reference_const_type</span> <span class="identifier">def</span> <span class="special">)</span> <span class="special">-&gt;</span> <span class="keyword">typename</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reference_const_type</span><span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_free_get_value_or"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="keyword">auto</span> <span class="identifier">get_optional_value_or</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">opt</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reference_type</span> <span class="identifier">def</span> <span class="special">)</span> <span class="special">-&gt;</span> <span class="keyword">typename</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reference_type</span> <span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_free_get_value_or"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
@ -93,7 +97,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -1,9 +1,9 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Tutorial</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="../index.html" title="Boost.Optional">
<link rel="up" href="../index.html" title="Boost.Optional">
<link rel="prev" href="../boost_optional/quick_start/storage_in_containers.html" title="Storage in containers">
@ -139,7 +139,7 @@
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright &#169; 2014-2016 Andrzej Krzemie&#324;ski<p>
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2021 Andrzej Krzemieński<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>

View File

@ -13,6 +13,7 @@
#ifndef BOOST_NONE_17SEP2003_HPP
#define BOOST_NONE_17SEP2003_HPP
#include "boost/config.hpp"
#include "boost/none_t.hpp"
// NOTE: Borland users have to include this header outside any precompiled headers
@ -23,7 +24,7 @@ namespace boost {
#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
none_t const none = (static_cast<none_t>(0)) ;
BOOST_INLINE_VARIABLE none_t BOOST_CONSTEXPR_OR_CONST none = (static_cast<none_t>(0)) ;
#elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE
@ -35,7 +36,7 @@ namespace detail { namespace optional_detail {
{
static const T instance;
};
template <typename T>
const T none_instance<T>::instance = T(); // global, but because 'tis a template, no cpp file required
@ -44,16 +45,15 @@ namespace detail { namespace optional_detail {
namespace {
// TU-local
const none_t& none = detail::optional_detail::none_instance<none_t>::instance;
const none_t& none = detail::optional_detail::none_instance<none_t>::instance;
}
#else
const none_t none ((none_t::init_tag()));
BOOST_INLINE_VARIABLE BOOST_CONSTEXPR_OR_CONST none_t none ((none_t::init_tag()));
#endif // older definitions
} // namespace boost
#endif // header guard

View File

@ -13,6 +13,8 @@
#ifndef BOOST_NONE_T_17SEP2003_HPP
#define BOOST_NONE_T_17SEP2003_HPP
#include <boost/config.hpp>
namespace boost {
#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
@ -29,7 +31,7 @@ class none_t {};
struct none_t
{
struct init_tag{};
explicit none_t(init_tag){} // to disable default constructor
explicit BOOST_CONSTEXPR none_t(init_tag){} // to disable default constructor
};
#endif // old implementation workarounds

View File

@ -19,6 +19,11 @@
namespace boost {
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wweak-vtables"
#endif
class bad_optional_access : public std::logic_error
{
public:
@ -27,6 +32,10 @@ public:
{}
};
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
} // namespace boost
#endif

View File

@ -0,0 +1,104 @@
// Copyright (C) 2017 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/libs/optional for documentation.
//
// You are welcome to contact the author at:
// akrzemi1@gmail.com
#ifndef BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP
#define BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/predef.h>
#include <boost/type_traits.hpp>
// The condition to use POD implementation
#ifdef BOOST_OPTIONAL_CONFIG_NO_POD_SPEC
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#elif defined BOOST_OPTIONAL_CONFIG_NO_SPEC_FOR_TRIVIAL_TYPES
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#elif !defined BOOST_HAS_TRIVIAL_CONSTRUCTOR
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#elif !defined BOOST_HAS_TRIVIAL_MOVE_ASSIGN
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#elif !defined BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#elif !defined BOOST_HAS_TRIVIAL_COPY
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#elif !defined BOOST_HAS_TRIVIAL_ASSIGN
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#elif !defined BOOST_HAS_TRIVIAL_DESTRUCTOR
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#elif BOOST_WORKAROUND(BOOST_GCC, < 50000)
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#endif
// GCC 5 or higher, or clang with libc++ or clang with libstdc++ 5 or higher
#if __cplusplus >= 201103L
# if BOOST_WORKAROUND(BOOST_GCC, >= 50000)
# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
# elif (defined BOOST_CLANG)
# if BOOST_LIB_STD_CXX > 0
# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
# elif BOOST_LIB_STD_GNU >= 441200023 && BOOST_LIB_STD_GNU != 450600023 && BOOST_LIB_STD_GNU != 450600026 && BOOST_LIB_STD_GNU != 460800003 && BOOST_LIB_STD_GNU != 450400026 && BOOST_LIB_STD_GNU != 460700026
# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
# endif
# endif
#endif
#ifndef BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) BOOST_HAS_TRIVIAL_CONSTRUCTOR(T)
#else
# include <type_traits>
# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) std::is_trivially_default_constructible<T>::value
#endif
namespace boost { namespace optional_detail {
#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
template <typename T>
struct is_type_trivially_copyable
: boost::conditional<(boost::has_trivial_copy_constructor<T>::value &&
boost::has_trivial_move_constructor<T>::value &&
boost::has_trivial_destructor<T>::value &&
boost::has_trivial_move_assign<T>::value &&
boost::has_trivial_assign<T>::value),
boost::true_type, boost::false_type>::type
{};
#else
template <typename T>
struct is_type_trivially_copyable
: boost::conditional<(boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value),
boost::true_type, boost::false_type>::type
{};
#endif
#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
template <typename T>
struct optional_uses_direct_storage_for_
: boost::conditional< (is_type_trivially_copyable<T>::value && BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T)) ||
(boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value)
, boost::true_type, boost::false_type>::type
{};
#else
template <typename T>
struct optional_uses_direct_storage_for_
: boost::conditional<(boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value)
, boost::true_type, boost::false_type>::type
{};
#endif
}} // boost::optional_detail
#endif

View File

@ -14,10 +14,9 @@
#define BOOST_OPTIONAL_DETAIL_OLD_OPTIONAL_IMPLEMENTATION_AJK_28JAN2015_HPP
#include <boost/detail/reference_content.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/not.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/conditional.hpp>
namespace boost {
@ -80,7 +79,7 @@ class optional_base : public optional_tag
private :
typedef
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
BOOST_DEDUCED_TYPENAME
#endif
::boost::detail::make_reference_content<T>::type internal_type ;
@ -96,13 +95,13 @@ class optional_base : public optional_tag
typedef T value_type ;
typedef mpl::true_ is_reference_tag ;
typedef mpl::false_ is_not_reference_tag ;
typedef true_type is_reference_tag ;
typedef false_type is_not_reference_tag ;
typedef BOOST_DEDUCED_TYPENAME is_reference<T>::type is_reference_predicate ;
public:
typedef BOOST_DEDUCED_TYPENAME mpl::if_<is_reference_predicate,types_when_ref,types_when_not_ref>::type types ;
typedef BOOST_DEDUCED_TYPENAME conditional<is_reference_predicate::value,types_when_ref,types_when_not_ref>::type types ;
protected:
typedef BOOST_DEDUCED_TYPENAME types::reference_type reference_type ;
@ -147,7 +146,7 @@ class optional_base : public optional_tag
}
#endif
// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialzed optional<T>.
// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional<T>.
// Can throw if T::T(T const&) does
optional_base ( bool cond, argument_type val )
:
@ -333,7 +332,7 @@ class optional_base : public optional_tag
public :
// **DEPPRECATED** Destroys the current value, if any, leaving this UNINITIALIZED
// Destroys the current value, if any, leaving this UNINITIALIZED
// No-throw (assuming T::~T() doesn't)
void reset() BOOST_NOEXCEPT { destroy(); }
@ -422,7 +421,7 @@ class optional_base : public optional_tag
template<class Expr>
void construct ( Expr&& factory, in_place_factory_base const* )
{
BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ;
BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
boost_optional_detail::construct<value_type>(factory, m_storage.address());
m_initialized = true ;
}
@ -431,7 +430,7 @@ class optional_base : public optional_tag
template<class Expr>
void construct ( Expr&& factory, typed_in_place_factory_base const* )
{
BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ;
BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
factory.apply(m_storage.address()) ;
m_initialized = true ;
}
@ -456,7 +455,7 @@ class optional_base : public optional_tag
template<class Expr>
void construct ( Expr const& factory, in_place_factory_base const* )
{
BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ;
BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
boost_optional_detail::construct<value_type>(factory, m_storage.address());
m_initialized = true ;
}
@ -465,7 +464,7 @@ class optional_base : public optional_tag
template<class Expr>
void construct ( Expr const& factory, typed_in_place_factory_base const* )
{
BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ;
BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
factory.apply(m_storage.address()) ;
m_initialized = true ;
}
@ -620,7 +619,7 @@ class optional_base : public optional_tag
reference_const_type dereference( internal_type const* p, is_reference_tag ) const { return p->get() ; }
reference_type dereference( internal_type* p, is_reference_tag ) { return p->get() ; }
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581))
void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->internal_type::~internal_type() ; m_initialized = false ; }
#else
void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->~T() ; m_initialized = false ; }
@ -730,7 +729,7 @@ class optional : public optional_detail::optional_base<T>
explicit optional ( Expr&& expr,
BOOST_DEDUCED_TYPENAME boost::disable_if_c<
(boost::is_base_of<optional_detail::optional_tag, BOOST_DEDUCED_TYPENAME boost::decay<Expr>::type>::value) ||
boost::is_same<BOOST_DEDUCED_TYPENAME boost::decay<Expr>::type, none_t>::value >::type* = 0
boost::is_same<BOOST_DEDUCED_TYPENAME boost::decay<Expr>::type, none_t>::value, bool >::type = true
)
: base(boost::forward<Expr>(expr),boost::addressof(expr))
{optional_detail::prevent_binding_rvalue_ref_to_optional_lvalue_ref<T, Expr&&>();}
@ -746,12 +745,12 @@ class optional : public optional_detail::optional_base<T>
optional ( optional const& rhs ) : base( static_cast<base const&>(rhs) ) {}
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Creates a deep move of another optional<T>
// Can throw if T::T(T&&) does
optional ( optional && rhs )
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value)
: base( boost::move(rhs) )
{}
// Creates a deep move of another optional<T>
// Can throw if T::T(T&&) does
optional ( optional && rhs )
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value)
: base( boost::move(rhs) )
{}
#endif
// No-throw (assuming T::~T() doesn't)
@ -819,7 +818,7 @@ class optional : public optional_detail::optional_base<T>
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Assigns from another optional<T> (deep-moves the rhs value)
optional& operator= ( optional && rhs )
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
{
this->assign( static_cast<base &&>(rhs) ) ;
return *this ;
@ -892,7 +891,7 @@ class optional : public optional_detail::optional_base<T>
#endif
void swap( optional & arg )
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
{
// allow for Koenig lookup
boost::swap(*this, arg);

View File

@ -25,14 +25,10 @@ template <class T>
class aligned_storage
{
// Borland ICEs if unnamed unions are used for this!
union
// This works around GCC warnings about breaking strict aliasing rules when casting storage address to T*
#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
__attribute__((__may_alias__))
#endif
dummy_u
// BOOST_MAY_ALIAS works around GCC warnings about breaking strict aliasing rules when casting storage address to T*
union BOOST_MAY_ALIAS dummy_u
{
char data[ sizeof(T) ];
unsigned char data[ sizeof(T) ];
BOOST_DEDUCED_TYPENAME type_with_alignment<
::boost::alignment_of<T>::value >::type aligner_;
} dummy_ ;
@ -48,24 +44,24 @@ class aligned_storage
#endif
#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
// This workaround is supposed to silence GCC warnings about broken strict aliasing rules
T const* ptr_ref() const
{
union { void const* ap_pvoid; T const* as_ptype; } caster = { address() };
return caster.as_ptype;
}
T * ptr_ref()
{
union { void* ap_pvoid; T* as_ptype; } caster = { address() };
return caster.as_ptype;
}
// This workaround is supposed to silence GCC warnings about broken strict aliasing rules
T const* ptr_ref() const
{
union { void const* ap_pvoid; T const* as_ptype; } caster = { address() };
return caster.as_ptype;
}
T * ptr_ref()
{
union { void* ap_pvoid; T* as_ptype; } caster = { address() };
return caster.as_ptype;
}
#else
T const* ptr_ref() const { return static_cast<T const*>(address()); }
T * ptr_ref() { return static_cast<T *> (address()); }
T const* ptr_ref() const { return static_cast<T const*>(address()); }
T * ptr_ref() { return static_cast<T *> (address()); }
#endif
T const& ref() const { return *ptr_ref(); }
T & ref() { return *ptr_ref(); }
T const& ref() const { return *ptr_ref(); }
T & ref() { return *ptr_ref(); }
} ;

View File

@ -1,5 +1,5 @@
// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
// Copyright (C) 2015 Andrzej Krzemienski.
// Copyright (C) 2015 - 2017 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
@ -28,7 +28,7 @@
# define BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#endif
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551)
#if BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x551)
// BCB (5.5.1) cannot parse the nested template struct in an inplace factory.
# define BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#endif
@ -44,11 +44,11 @@
# define BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
#endif
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
// GCC since 3.3 has may_alias attribute that helps to alleviate optimizer issues with
// regard to violation of the strict aliasing rules. The optional< T > storage type is marked
// with this attribute in order to let the compiler know that it will alias objects of type T
// and silence compilation warnings.
#if !defined(BOOST_NO_MAY_ALIAS)
// GCC since 3.3 and some other compilers have may_alias attribute that helps to alleviate
// optimizer issues with regard to violation of the strict aliasing rules. The optional< T >
// storage type is marked with this attribute in order to let the compiler know that it will
// alias objects of type T and silence compilation warnings.
# define BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS
#endif
@ -113,4 +113,23 @@
# define BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS
#endif
// Detect suport for defaulting move operations
// (some older compilers implement rvalue references,
// defaulted funcitons but move operations are not special members and cannot be defaulted)
#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
# define BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
#elif BOOST_WORKAROUND(BOOST_MSVC, < 1900)
# define BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
#elif BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40600)
# define BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
#endif
#ifdef BOOST_OPTIONAL_CONFIG_NO_DIRECT_STORAGE_SPEC
# define BOOST_OPTIONAL_DETAIL_NO_DIRECT_STORAGE_SPEC
#endif
#endif // header guard

View File

@ -0,0 +1,49 @@
// Copyright (C) 2022 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/libs/optional for documentation.
//
// You are welcome to contact the author at:
// akrzemi1@gmail.com
#ifndef BOOST_OPTIONAL_DETAIL_OPTIONAL_HASH_AJK_20MAY2022_HPP
#define BOOST_OPTIONAL_DETAIL_OPTIONAL_HASH_AJK_20MAY2022_HPP
#include <boost/optional/optional_fwd.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
#include <functional>
namespace std
{
template <typename T>
struct hash<boost::optional<T> >
{
typedef std::size_t result_type;
typedef boost::optional<T> argument_type;
BOOST_CONSTEXPR result_type operator()(const argument_type& arg) const {
return arg ? std::hash<T>()(*arg) : result_type();
}
};
template <typename T>
struct hash<boost::optional<T&> >
{
typedef std::size_t result_type;
typedef boost::optional<T&> argument_type;
BOOST_CONSTEXPR result_type operator()(const argument_type& arg) const {
return arg ? std::hash<T>()(*arg) : result_type();
}
};
}
#endif // !defined(BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
#endif // header guard

View File

@ -1,4 +1,4 @@
// Copyright (C) 2015-2016 Andrzej Krzemienski.
// Copyright (C) 2015-2018 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
@ -132,11 +132,11 @@ public:
// the following two implement a 'conditionally explicit' constructor: condition is a hack for buggy compilers with srewed conversion construction from const int
template <class U>
explicit optional(U& rhs, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::is_same_decayed<T, U>::value && detail::is_const_integral_bad_for_conversion<U>::value>::type* = 0) BOOST_NOEXCEPT
explicit optional(U& rhs, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::is_same_decayed<T, U>::value && detail::is_const_integral_bad_for_conversion<U>::value, bool>::type = true) BOOST_NOEXCEPT
: ptr_(boost::addressof(rhs)) {}
template <class U>
optional(U& rhs, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::is_same_decayed<T, U>::value && !detail::is_const_integral_bad_for_conversion<U>::value>::type* = 0) BOOST_NOEXCEPT
optional(U& rhs, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::is_same_decayed<T, U>::value && !detail::is_const_integral_bad_for_conversion<U>::value, bool>::type = true) BOOST_NOEXCEPT
: ptr_(boost::addressof(rhs)) {}
optional& operator=(const optional& rhs) BOOST_NOEXCEPT { ptr_ = rhs.get_ptr(); return *this; }
@ -151,7 +151,14 @@ public:
T* get_ptr() const BOOST_NOEXCEPT { return ptr_; }
T* operator->() const { BOOST_ASSERT(ptr_); return ptr_; }
T& operator*() const { BOOST_ASSERT(ptr_); return *ptr_; }
T& value() const { return ptr_ ? *ptr_ : (throw_exception(bad_optional_access()), *ptr_); }
T& value() const
{
if (this->is_initialized())
return this->get();
else
throw_exception(bad_optional_access());
}
bool operator!() const BOOST_NOEXCEPT { return ptr_ == 0; }
BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
@ -159,17 +166,36 @@ 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; }
template <typename F>
optional<typename boost::result_of<F(T&)>::type> map(F f) const
{
if (this->has_value())
return f(this->get());
else
return none;
}
template <typename F>
optional<typename optional_detail::optional_value_type<typename boost::result_of<F(T&)>::type>::type> flat_map(F f) const
{
if (this->has_value())
return f(get());
else
return none;
}
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
optional(T&& /* rhs */) BOOST_NOEXCEPT { detail::prevent_binding_rvalue<T&&>(); }
template <class R>
optional(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::no_unboxing_cond<T, R> >::type* = 0) BOOST_NOEXCEPT
optional(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::no_unboxing_cond<T, R>, bool>::type = true) BOOST_NOEXCEPT
: ptr_(boost::addressof(r)) { detail::prevent_binding_rvalue<R>(); }
template <class R>
optional(bool cond, R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) BOOST_NOEXCEPT
optional(bool cond, R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, bool>::type = true) BOOST_NOEXCEPT
: ptr_(cond ? boost::addressof(r) : 0) { detail::prevent_binding_rvalue<R>(); }
template <class R>
@ -177,19 +203,19 @@ public:
operator=(R&& r) BOOST_NOEXCEPT { detail::prevent_binding_rvalue<R>(); ptr_ = boost::addressof(r); return *this; }
template <class R>
void emplace(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) BOOST_NOEXCEPT
void emplace(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, bool>::type = true) BOOST_NOEXCEPT
{ detail::prevent_binding_rvalue<R>(); ptr_ = boost::addressof(r); }
template <class R>
T& get_value_or(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) const BOOST_NOEXCEPT
T& get_value_or(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, bool>::type = true) const BOOST_NOEXCEPT
{ detail::prevent_binding_rvalue<R>(); return ptr_ ? *ptr_ : r; }
template <class R>
T& value_or(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) const BOOST_NOEXCEPT
T& value_or(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, bool>::type = true) const BOOST_NOEXCEPT
{ detail::prevent_binding_rvalue<R>(); return ptr_ ? *ptr_ : r; }
template <class R>
void reset(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) BOOST_NOEXCEPT
void reset(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, bool>::type = true) BOOST_NOEXCEPT
{ detail::prevent_binding_rvalue<R>(); ptr_ = boost::addressof(r); }
template <class F>
@ -200,15 +226,15 @@ public:
// the following two implement a 'conditionally explicit' constructor
template <class U>
explicit optional(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::no_unboxing_cond<T, U>::value && detail::is_const_integral_bad_for_conversion<U>::value >::type* = 0) BOOST_NOEXCEPT
explicit optional(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::no_unboxing_cond<T, U>::value && detail::is_const_integral_bad_for_conversion<U>::value, bool>::type = true) BOOST_NOEXCEPT
: ptr_(boost::addressof(v)) { }
template <class U>
optional(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::no_unboxing_cond<T, U>::value && !detail::is_const_integral_bad_for_conversion<U>::value >::type* = 0) BOOST_NOEXCEPT
optional(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::no_unboxing_cond<T, U>::value && !detail::is_const_integral_bad_for_conversion<U>::value, bool>::type = true) BOOST_NOEXCEPT
: ptr_(boost::addressof(v)) { }
template <class U>
optional(bool cond, U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT : ptr_(cond ? boost::addressof(v) : 0) {}
optional(bool cond, U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, bool>::type = true) BOOST_NOEXCEPT : ptr_(cond ? boost::addressof(v) : 0) {}
template <class U>
BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, optional<T&>&>::type
@ -219,19 +245,19 @@ public:
}
template <class U>
void emplace(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT
void emplace(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, bool>::type = true) BOOST_NOEXCEPT
{ ptr_ = boost::addressof(v); }
template <class U>
T& get_value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) const BOOST_NOEXCEPT
T& get_value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, bool>::type = true) const BOOST_NOEXCEPT
{ return ptr_ ? *ptr_ : v; }
template <class U>
T& value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) const BOOST_NOEXCEPT
T& value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, bool>::type = true) const BOOST_NOEXCEPT
{ return ptr_ ? *ptr_ : v; }
template <class U>
void reset(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT
void reset(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, bool>::type = true) BOOST_NOEXCEPT
{ ptr_ = boost::addressof(v); }
template <class F>

View File

@ -26,7 +26,7 @@ namespace boost {
template<class T>
inline
bool operator == ( optional<T> const& x, optional<T> const& y )
{ return equal_pointees(x,y); }
{ return bool(x) && bool(y) ? *x == *y : bool(x) == bool(y); }
template<class T>
inline

View File

@ -0,0 +1,510 @@
// Copyright (C) 2017 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/libs/optional for documentation.
//
// You are welcome to contact the author at:
// akrzemi1@gmail.com
// trivilally-copyable version of the storage
template<class T>
class tc_optional_base : public optional_tag
{
private :
typedef tc_optional_base<T> this_type ;
protected :
typedef T value_type ;
protected:
typedef T & reference_type ;
typedef T const& reference_const_type ;
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
typedef T && rval_reference_type ;
typedef T && reference_type_of_temporary_wrapper ;
#endif
typedef T * pointer_type ;
typedef T const* pointer_const_type ;
typedef T const& argument_type ;
tc_optional_base()
:
m_initialized(false) {}
tc_optional_base ( none_t )
:
m_initialized(false) {}
tc_optional_base ( init_value_tag, argument_type val )
:
m_initialized(true), m_storage(val) {}
tc_optional_base ( bool cond, argument_type val )
:
m_initialized(cond), m_storage(val) {}
// tc_optional_base ( tc_optional_base const& ) = default;
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
template<class Expr, class PtrExpr>
explicit tc_optional_base ( Expr&& expr, PtrExpr const* tag )
:
m_initialized(false)
{
construct(boost::forward<Expr>(expr),tag);
}
#else
// This is used for both converting and in-place constructions.
// Derived classes use the 'tag' to select the appropriate
// implementation (the correct 'construct()' overload)
template<class Expr>
explicit tc_optional_base ( Expr const& expr, Expr const* tag )
:
m_initialized(false)
{
construct(expr,tag);
}
#endif
// tc_optional_base& operator= ( tc_optional_base const& ) = default;
// ~tc_optional_base() = default;
// Assigns from another optional<T> (deep-copies the rhs value)
void assign ( tc_optional_base const& rhs )
{
*this = rhs;
}
// Assigns from another _convertible_ optional<U> (deep-copies the rhs value)
template<class U>
void assign ( optional<U> const& rhs )
{
if ( rhs.is_initialized() )
#ifndef BOOST_OPTIONAL_CONFIG_RESTORE_ASSIGNMENT_OF_NONCONVERTIBLE_TYPES
m_storage = rhs.get();
#else
m_storage = static_cast<value_type>(rhs.get());
#endif
m_initialized = rhs.is_initialized();
}
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// move-assigns from another _convertible_ optional<U> (deep-moves from the rhs value)
template<class U>
void assign ( optional<U>&& rhs )
{
typedef BOOST_DEDUCED_TYPENAME optional<U>::rval_reference_type ref_type;
if ( rhs.is_initialized() )
m_storage = static_cast<ref_type>(rhs.get());
m_initialized = rhs.is_initialized();
}
#endif
void assign ( argument_type val )
{
construct(val);
}
void assign ( none_t ) { destroy(); }
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
template<class Expr, class ExprPtr>
void assign_expr ( Expr&& expr, ExprPtr const* tag )
{
construct(boost::forward<Expr>(expr),tag);
}
#else
template<class Expr>
void assign_expr ( Expr const& expr, Expr const* tag )
{
construct(expr,tag);
}
#endif
#endif
public :
// Destroys the current value, if any, leaving this UNINITIALIZED
// No-throw (assuming T::~T() doesn't)
void reset() BOOST_NOEXCEPT { destroy(); }
// **DEPPRECATED** Replaces the current value -if any- with 'val'
void reset ( argument_type val ) BOOST_NOEXCEPT { assign(val); }
// Returns a pointer to the value if this is initialized, otherwise,
// returns NULL.
// No-throw
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 ; }
protected :
void construct ( argument_type val )
{
m_storage = val ;
m_initialized = true ;
}
#if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES)
// Constructs in-place
// upon exception *this is always uninitialized
template<class... Args>
void construct ( in_place_init_t, Args&&... args )
{
m_storage = value_type( boost::forward<Args>(args)... ) ;
m_initialized = true ;
}
template<class... Args>
void emplace_assign ( Args&&... args )
{
construct(in_place_init, boost::forward<Args>(args)...);
}
template<class... Args>
explicit tc_optional_base ( in_place_init_t, Args&&... args )
:
m_initialized(false)
{
construct(in_place_init, boost::forward<Args>(args)...);
}
template<class... Args>
explicit tc_optional_base ( in_place_init_if_t, bool cond, Args&&... args )
:
m_initialized(false)
{
if ( cond )
construct(in_place_init, boost::forward<Args>(args)...);
}
#elif (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
template<class Arg>
void construct ( in_place_init_t, Arg&& arg )
{
m_storage = value_type( boost::forward<Arg>(arg) );
m_initialized = true ;
}
void construct ( in_place_init_t )
{
m_storage = value_type();
m_initialized = true ;
}
template<class Arg>
void emplace_assign ( Arg&& arg )
{
construct(in_place_init, boost::forward<Arg>(arg)) ;
}
void emplace_assign ()
{
construct(in_place_init) ;
}
template<class Arg>
explicit tc_optional_base ( in_place_init_t, Arg&& arg )
:
m_initialized(false)
{
construct(in_place_init, boost::forward<Arg>(arg));
}
explicit tc_optional_base ( in_place_init_t )
:
m_initialized(false), m_storage() {}
template<class Arg>
explicit tc_optional_base ( in_place_init_if_t, bool cond, Arg&& arg )
:
m_initialized(false)
{
if ( cond )
construct(in_place_init, boost::forward<Arg>(arg));
}
explicit tc_optional_base ( in_place_init_if_t, bool cond )
:
m_initialized(false)
{
if ( cond )
construct(in_place_init);
}
#else
template<class Arg>
void construct ( in_place_init_t, const Arg& arg )
{
m_storage = value_type( arg );
m_initialized = true ;
}
template<class Arg>
void construct ( in_place_init_t, Arg& arg )
{
m_storage = value_type( arg );
m_initialized = true ;
}
void construct ( in_place_init_t )
{
m_storage = value_type();
m_initialized = true ;
}
template<class Arg>
void emplace_assign ( const Arg& arg )
{
construct(in_place_init, arg);
}
template<class Arg>
void emplace_assign ( Arg& arg )
{
construct(in_place_init, arg);
}
void emplace_assign ()
{
construct(in_place_init);
}
template<class Arg>
explicit tc_optional_base ( in_place_init_t, const Arg& arg )
: m_initialized(false)
{
construct(in_place_init, arg);
}
template<class Arg>
explicit tc_optional_base ( in_place_init_t, Arg& arg )
: m_initialized(false)
{
construct(in_place_init, arg);
}
explicit tc_optional_base ( in_place_init_t )
: m_initialized(false)
{
construct(in_place_init);
}
template<class Arg>
explicit tc_optional_base ( in_place_init_if_t, bool cond, const Arg& arg )
: m_initialized(false)
{
if ( cond )
construct(in_place_init, arg);
}
template<class Arg>
explicit tc_optional_base ( in_place_init_if_t, bool cond, Arg& arg )
: m_initialized(false)
{
if ( cond )
construct(in_place_init, arg);
}
explicit tc_optional_base ( in_place_init_if_t, bool cond )
: m_initialized(false)
{
if ( cond )
construct(in_place_init);
}
#endif
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Constructs in-place using the given factory
template<class Expr>
void construct ( Expr&& factory, in_place_factory_base const* )
{
boost_optional_detail::construct<value_type>(factory, boost::addressof(m_storage));
m_initialized = true ;
}
// Constructs in-place using the given typed factory
template<class Expr>
void construct ( Expr&& factory, typed_in_place_factory_base const* )
{
factory.apply(boost::addressof(m_storage)) ;
m_initialized = true ;
}
template<class Expr>
void assign_expr_to_initialized ( Expr&& factory, in_place_factory_base const* tag )
{
destroy();
construct(factory,tag);
}
// Constructs in-place using the given typed factory
template<class Expr>
void assign_expr_to_initialized ( Expr&& factory, typed_in_place_factory_base const* tag )
{
destroy();
construct(factory,tag);
}
#else
// Constructs in-place using the given factory
template<class Expr>
void construct ( Expr const& factory, in_place_factory_base const* )
{
boost_optional_detail::construct<value_type>(factory, boost::addressof(m_storage));
m_initialized = true ;
}
// Constructs in-place using the given typed factory
template<class Expr>
void construct ( Expr const& factory, typed_in_place_factory_base const* )
{
factory.apply(boost::addressof(m_storage)) ;
m_initialized = true ;
}
template<class Expr>
void assign_expr_to_initialized ( Expr const& factory, in_place_factory_base const* tag )
{
destroy();
construct(factory,tag);
}
// Constructs in-place using the given typed factory
template<class Expr>
void assign_expr_to_initialized ( Expr const& factory, typed_in_place_factory_base const* tag )
{
destroy();
construct(factory,tag);
}
#endif
#endif
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Constructs using any expression implicitly convertible to the single argument
// of a one-argument T constructor.
// Converting constructions of optional<T> from optional<U> uses this function with
// 'Expr' being of type 'U' and relying on a converting constructor of T from U.
template<class Expr>
void construct ( Expr&& expr, void const* )
{
m_storage = value_type(boost::forward<Expr>(expr)) ;
m_initialized = true ;
}
// Assigns using a form any expression implicitly convertible to the single argument
// of a T's assignment operator.
// Converting assignments of optional<T> from optional<U> uses this function with
// 'Expr' being of type 'U' and relying on a converting assignment of T from U.
template<class Expr>
void assign_expr_to_initialized ( Expr&& expr, void const* )
{
assign_value( boost::forward<Expr>(expr) );
}
#else
// Constructs using any expression implicitly convertible to the single argument
// of a one-argument T constructor.
// Converting constructions of optional<T> from optional<U> uses this function with
// 'Expr' being of type 'U' and relying on a converting constructor of T from U.
template<class Expr>
void construct ( Expr const& expr, void const* )
{
m_storage = value_type(expr) ;
m_initialized = true ;
}
// Assigns using a form any expression implicitly convertible to the single argument
// of a T's assignment operator.
// Converting assignments of optional<T> from optional<U> uses this function with
// 'Expr' being of type 'U' and relying on a converting assignment of T from U.
template<class Expr>
void assign_expr_to_initialized ( Expr const& expr, void const* )
{
assign_value(expr);
}
#endif
#ifdef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
// BCB5.64 (and probably lower versions) workaround.
// The in-place factories are supported by means of catch-all constructors
// and assignment operators (the functions are parameterized in terms of
// an arbitrary 'Expr' type)
// This compiler incorrectly resolves the overload set and sinks optional<T> and optional<U>
// to the 'Expr'-taking functions even though explicit overloads are present for them.
// Thus, the following overload is needed to properly handle the case when the 'lhs'
// is another optional.
//
// For VC<=70 compilers this workaround dosen't work becasue the comnpiler issues and error
// instead of choosing the wrong overload
//
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Notice that 'Expr' will be optional<T> or optional<U> (but not tc_optional_base<..>)
template<class Expr>
void construct ( Expr&& expr, optional_tag const* )
{
if ( expr.is_initialized() )
{
// An exception can be thrown here.
// It it happens, THIS will be left uninitialized.
m_storage = value_type(boost::move(expr.get())) ;
m_initialized = true ;
}
}
#else
// Notice that 'Expr' will be optional<T> or optional<U> (but not tc_optional_base<..>)
template<class Expr>
void construct ( Expr const& expr, optional_tag const* )
{
if ( expr.is_initialized() )
{
// An exception can be thrown here.
// It it happens, THIS will be left uninitialized.
m_storage = value_type(expr.get()) ;
m_initialized = true ;
}
}
#endif
#endif // defined BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
void assign_value ( argument_type val ) { m_storage = val; }
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
void assign_value ( rval_reference_type val ) { m_storage = static_cast<rval_reference_type>(val); }
#endif
void destroy()
{
m_initialized = false;
}
reference_const_type get_impl() const { return m_storage ; }
reference_type get_impl() { return m_storage ; }
pointer_const_type get_ptr_impl() const { return boost::addressof(m_storage); }
pointer_type get_ptr_impl() { return boost::addressof(m_storage); }
private :
bool m_initialized ;
T m_storage ;
} ;

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@
#ifndef BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP
#define BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP
#ifndef BOOST_NO_IOSTREAM
#include <istream>
#include <ostream>
@ -31,7 +32,7 @@ operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t)
{
out << "--";
}
return out;
}
@ -90,5 +91,5 @@ operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v)
} // namespace boost
#endif // BOOST_NO_IOSTREAM
#endif

View File

@ -12,5 +12,6 @@
"maintainers": [
"Fernando Cacciola <fernando_cacciola -at- ciudad.com.ar>",
"Andrzej Krzemienski <akrzemi1 -at- gmail.com>"
]
],
"cxxstd": "03"
}

View File

@ -1,7 +1,7 @@
# Boost.Optional Library test Jamfile
#
# Copyright (C) 2003, Fernando Luis Cacciola Carballal.
# Copyright (C) 2014 - 2016 Andrzej Krzemienski
# Copyright (C) 2014 - 2017 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
@ -18,10 +18,16 @@ import testing ;
{
test-suite optional :
[ run optional_test.cpp ]
[ run optional_test_assign.cpp ]
[ run optional_test_swap.cpp ]
[ run optional_test_conversions_from_U.cpp ]
[ run optional_test_convert_from_T.cpp ]
[ run optional_test_convert_assign.cpp ]
[ run optional_test_empty_braces.cpp ]
[ run optional_test_make_optional.cpp ]
[ run optional_test_flat_map.cpp ]
[ run optional_test_hash.cpp ]
[ run optional_test_map.cpp ]
[ run optional_test_tie.cpp ]
[ run optional_test_ref_assign_portable_minimum.cpp ]
[ run optional_test_ref_assign_mutable_int.cpp ]
@ -37,12 +43,17 @@ import testing ;
[ run optional_test_io.cpp ]
[ run optional_test_move.cpp ]
[ run optional_test_noexcept_move.cpp ]
[ run optional_test_old_impl.cpp ]
[ run optional_test_equals_none.cpp ]
[ run optional_test_value_access.cpp ]
[ run optional_test_emplace.cpp ]
[ run optional_test_minimum_requirements.cpp ]
[ run optional_test_msvc_bug_workaround.cpp ]
[ run optional_test_member_T.cpp ]
[ run optional_test_tc_base.cpp ]
[ compile optional_test_sfinae_friendly_ctor.cpp ]
[ compile optional_test_path_assignment.cpp ]
[ compile-fail optional_test_fail_const_swap.cpp ]
[ compile-fail optional_test_ref_convert_assign_const_int_prevented.cpp ]
[ compile-fail optional_test_fail1.cpp ]
[ compile-fail optional_test_fail3a.cpp ]
@ -65,6 +76,11 @@ import testing ;
[ compile-fail optional_test_fail_io_without_io.cpp ]
[ compile-fail optional_test_fail_none_io_without_io.cpp ]
[ compile-fail optional_test_fail_convert_assign_of_enums.cpp ]
[ run optional_test_static_properties.cpp ]
[ compile optional_test_maybe_uninitialized_warning.cpp ]
[ compile optional_test_deleted_default_ctor.cpp ]
[ compile optional_test_constructible_from_other.cpp ]
#[ run optional_xconfig_HACK_TO_LIST_PREDEFINED_MACROS.cpp ]
[ run optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_pass.cpp ]
[ run-fail optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_fail.cpp ]
[ run optional_xconfig_NO_PROPER_CONVERT_FROM_CONST_INT_pass.cpp ]

View File

@ -13,7 +13,7 @@
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@ -12,7 +12,9 @@
// Revisions:
// 12 May 2008 (added more swap tests)
//
#ifndef BOOST_NO_IOSTREAM
#include<iostream>
#endif // BOOST_NO_IOSTREAM
#include<stdexcept>
#include<string>
@ -24,7 +26,7 @@
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
@ -32,7 +34,7 @@
#include "boost/core/lightweight_test.hpp"
#include "optional_test_common.cpp"
#include "optional_test_common.hpp"
void test_implicit_construction ( optional<double> opt, double v, double z )
{
@ -908,7 +910,7 @@ void test_no_implicit_conversions()
// Test for support for classes with overridden operator&
class CustomAddressOfClass
class CustomAddressOfClass
{
int n;
@ -950,5 +952,3 @@ int main()
return boost::report_errors();
}

View File

@ -0,0 +1,30 @@
// Copyright (C) 2018 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/core/lightweight_test.hpp"
#include "boost/optional/optional.hpp"
void test_assignment_to_empty()
{
// this test used to fail on GCC 8.1.0/8.2.0/9.0.0 with -std=c++98
boost::optional<int> oa, ob(1);
BOOST_TEST(!oa);
BOOST_TEST(ob);
oa = ob;
BOOST_TEST(oa);
}
int main()
{
test_assignment_to_empty();
return boost::report_errors();
}

View File

@ -194,6 +194,9 @@ inline void check_uninitialized_const ( optional<T> 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<class T>
inline void check_uninitialized ( optional<T>& opt )
@ -204,6 +207,9 @@ inline void check_uninitialized ( optional<T>& 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<T> 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<class T>
@ -234,6 +243,9 @@ inline void check_initialized ( optional<T>& 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);
}

View File

@ -0,0 +1,59 @@
// Copyright (c) 2018 Andrey Semashev
//
// 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)
// The test verifies that Boost.Optional copy constructors do not attempt to invoke
// the element type initializing constructors from templated arguments
#include <boost/optional/optional.hpp>
#include <boost/core/enable_if.hpp>
struct no_type
{
char data;
};
struct yes_type
{
char data[2];
};
template< unsigned int Size >
struct size_tag {};
template< typename T, typename U >
struct is_constructible
{
static U& get();
template< typename T1 >
static yes_type check_helper(size_tag< sizeof(static_cast< T1 >(get())) >*);
template< typename T1 >
static no_type check_helper(...);
static const bool value = sizeof(check_helper< T >(0)) == sizeof(yes_type);
};
template< typename T >
class wrapper
{
public:
wrapper() {}
wrapper(wrapper const&) {}
template< typename U >
wrapper(U const&, typename boost::enable_if_c< is_constructible< T, U >::value, int >::type = 0) {}
};
inline boost::optional< wrapper< int > > foo()
{
return boost::optional< wrapper< int > >();
}
int main()
{
// Invokes boost::optional copy constructor. Should not invoke wrapper constructor from U.
boost::optional< wrapper< int > > res = foo();
return 0;
}

View File

@ -11,7 +11,7 @@
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@ -0,0 +1,57 @@
// Copyright (C) 2021 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/optional.hpp"
#include "boost/core/lightweight_test.hpp"
#include "boost/none.hpp"
//#ifndef BOOST_OPTIONAL_NO_CONVERTING_COPY_CTOR
using boost::optional;
struct implicit_bool_conv
{
operator bool() const { return false; }
};
struct explicit_bool_conv
{
bool operator!() const BOOST_NOEXCEPT { return false; }
BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
};
template <typename To, typename From>
void test_convert_assign()
{
optional<To> oi;
oi = From();
BOOST_TEST(oi);
}
void test_no_bad_assignment()
{
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800)
// this means that type trait `boost::is_assignable` works.
BOOST_STATIC_ASSERT((boost::is_assignable<optional<bool>&, bool>::value));
BOOST_STATIC_ASSERT((boost::is_assignable<optional<bool>&, implicit_bool_conv>::value));
BOOST_STATIC_ASSERT((! boost::is_assignable<optional<bool>&, explicit_bool_conv>::value));
#endif
}
int main()
{
test_convert_assign<int, short>();
test_convert_assign<bool, implicit_bool_conv>();
test_no_bad_assignment();
return boost::report_errors();
}

View File

@ -11,7 +11,7 @@
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@ -0,0 +1,66 @@
// Copyright 2017 Peter Dimov
// Copyright 2017 Vinnie Falco
// Copyright 2018 Andrzej Krzemienski
//
// Distributed under the Boost Software License, Version 1.0.
//
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
int main()
{
}
#else
#include <boost/optional.hpp>
#include <utility>
class basic_multi_buffer;
class const_buffers_type // a similar declaration in boost.beast had problem
{ // with boost opitonal
basic_multi_buffer const* b_;
friend class basic_multi_buffer;
explicit
const_buffers_type(basic_multi_buffer const& b);
public:
const_buffers_type() = delete;
const_buffers_type(const_buffers_type const&) = default;
const_buffers_type& operator=(const_buffers_type const&) = default;
};
void test_beast_example()
{
// test if it even compiles
boost::optional< std::pair<const_buffers_type, int> > opt, opt2;
opt = opt2;
(void)opt;
}
struct NotDefaultConstructible // minimal class exposing the problem
{
NotDefaultConstructible() = delete;
};
void test_assign_for_non_default_constructible()
{
// test if it even compiles
boost::optional<NotDefaultConstructible> opt, opt2;
opt = opt2;
(void)opt;
}
int main()
{
test_beast_example();
test_assign_for_non_default_constructible();
}
#endif

View File

@ -11,10 +11,11 @@
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include <string>
#include "boost/core/lightweight_test.hpp"
#include "boost/none.hpp"

View File

@ -11,7 +11,7 @@
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@ -11,7 +11,7 @@
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@ -0,0 +1,152 @@
// Copyright (C) 2017 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/optional.hpp"
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/core/lightweight_test.hpp"
#include "boost/core/lightweight_test_trait.hpp"
#include "boost/type_traits/is_base_of.hpp"
#include "boost/optional/detail/experimental_traits.hpp"
#ifndef BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
struct PrivDefault
{
private: PrivDefault() {}
};
struct CustDefault
{
CustDefault() {}
};
struct CustomizedTrivial
{
CustomizedTrivial() {}
};
struct DeletedDefault
{
BOOST_DELETED_FUNCTION(DeletedDefault())
};
namespace boost { namespace optional_config {
template <> struct optional_uses_direct_storage_for<CustomizedTrivial> : boost::true_type {};
}}
struct CustDtor
{
~CustDtor() {}
};
struct NoDefault
{
explicit NoDefault(int) {}
};
struct Empty {};
template <typename T, typename U>
struct Aggregate { T t; U u; };
struct CustAssign
{
CustAssign& operator=(CustAssign const&) { return *this; }
};
struct CustMove
{
CustMove(CustMove &&) {}
};
void test_type_traits()
{
// this only tests if type traits are implemented correctly
BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for<int> ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for<double> ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for<CustomizedTrivial> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for<PrivDefault> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for<NoDefault> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for<CustDefault> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for<Aggregate<int, CustDefault> > ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for<CustDtor> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for<CustAssign> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for<CustMove> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for<Aggregate<int, CustMove> > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<int> ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<double> ));
#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for<Empty> ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for<Aggregate<int, double> > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for<Aggregate<Aggregate<Empty, int>, double> > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<Empty> ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<Aggregate<int, double> > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<Aggregate<Aggregate<Empty, int>, double> > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<PrivDefault> ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<NoDefault> ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<CustDefault> ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<Aggregate<int, CustDefault> > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<DeletedDefault> ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<Aggregate<int, DeletedDefault> > ));
#endif
BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for<DeletedDefault> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for<Aggregate<int, DeletedDefault> > ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable<CustDtor> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable<CustAssign> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable<CustMove> ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable<Aggregate<int, CustMove> > ));
}
void test_trivial_copyability()
{
BOOST_TEST_TRAIT_TRUE((boost::is_base_of<boost::optional_detail::tc_optional_base<int>, boost::optional<int> > ));
BOOST_TEST_TRAIT_TRUE((boost::is_base_of<boost::optional_detail::tc_optional_base<double>, boost::optional<double> > ));
BOOST_TEST_TRAIT_TRUE((boost::is_base_of<boost::optional_detail::tc_optional_base<CustomizedTrivial>, boost::optional<CustomizedTrivial> > ));
BOOST_TEST_TRAIT_FALSE((boost::is_base_of<boost::optional_detail::tc_optional_base<DeletedDefault>, boost::optional<DeletedDefault> > ));
#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<boost::optional<int> > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<boost::optional<double> > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<boost::optional<CustomizedTrivial> > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<boost::optional<Empty> > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<boost::optional<Aggregate<int, double> > > ));
BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable<boost::optional<Aggregate<Aggregate<Empty, int>, double> > > ));
BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable<boost::optional<DeletedDefault> > ));
#endif
}
#endif
int main()
{
#ifndef BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
test_type_traits();
test_trivial_copyability();
#endif
return boost::report_errors();
}

View File

@ -0,0 +1,26 @@
// Copyright (C) 2018, 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
void test_converitng_assignment_of_different_enums()
{
const boost::optional<int> o1(1);
const boost::optional<int> o2(2);
swap(o1, o2); // no swap on const objects should compile
}
int main()
{
test_converitng_assignment_of_different_enums();
}

View File

@ -0,0 +1,275 @@
// Copyright (C) 2018 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/optional.hpp"
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/core/ignore_unused.hpp"
#include "boost/core/is_same.hpp"
#include "boost/core/lightweight_test.hpp"
#include "boost/core/lightweight_test_trait.hpp"
using boost::optional;
using boost::make_optional;
using boost::core::is_same;
template <typename Expected, typename Deduced>
void verify_type(Deduced)
{
BOOST_TEST_TRAIT_TRUE(( is_same<Expected, Deduced> ));
}
struct Int
{
int i;
explicit Int(int i_) : i(i_) {}
};
struct convert_t
{
typedef optional<Int> result_type;
optional<Int> operator()(int i) { if (i != 0) return Int(i); else return boost::none; }
};
void test_flat_map_on_mutable_optional_with_function_object()
{
{
optional<int> oi (1);
verify_type< optional<Int> >(oi.flat_map(convert_t()));
optional<Int> oI = oi.flat_map(convert_t());
BOOST_TEST(bool(oI));
BOOST_TEST_EQ(1, oI->i);
}
{
optional<int> oi (0);
optional<Int> oI = oi.flat_map(convert_t());
BOOST_TEST(!oI);
}
{
optional<int> oi;
optional<Int> oI = oi.flat_map(convert_t());
BOOST_TEST(!oI);
}
}
void test_flat_map_on_const_optional_with_function_object()
{
{
const optional<int> oi (1);
verify_type< optional<Int> >(oi.flat_map(convert_t()));
optional<Int> oI = oi.flat_map(convert_t());
BOOST_TEST(bool(oI));
BOOST_TEST_EQ(1, oI->i);
}
{
const optional<int> oi (0);
optional<Int> oI = oi.flat_map(convert_t());
BOOST_TEST(!oI);
}
{
const optional<int> oi;
optional<Int> oI = oi.flat_map(convert_t());
BOOST_TEST(!oI);
}
}
void test_flat_map_with_lambda()
{
#if !defined BOOST_NO_CXX11_LAMBDAS && !defined BOOST_NO_CXX11_DECLTYPE_N3276
{
optional<int> oi (1);
verify_type< optional<Int> >(oi.flat_map([](int i){ return optional<Int>(i == 0, Int(i)); }));
optional<Int> oI = oi.flat_map([](int i){ return optional<Int>(i != 0, Int(i)); });
BOOST_TEST(bool(oI));
BOOST_TEST_EQ(1, oI->i);
}
{
optional<int> oi (0);
optional<Int> oI = oi.flat_map([](int i){ return optional<Int>(i != 0, Int(i)); });
BOOST_TEST(!oI);
}
{
optional<int> oi;
optional<Int> oI = oi.flat_map([](int i){ return optional<Int>(i != 0, Int(i)); });
BOOST_TEST(!oI);
}
#endif // lambdas
}
struct get_opt_ref
{
typedef optional<int&> result_type;
optional<int&> operator()(int& i) { return i != 0 ? optional<int&>(i) : optional<int&>(); }
};
void test_flat_map_obj_to_ref()
{
{
optional<int> oi (2);
verify_type< optional<int&> >(oi.flat_map(get_opt_ref()));
optional<int&> ori = oi.flat_map(get_opt_ref());
BOOST_TEST(bool(ori));
BOOST_TEST_EQ(2, *ori);
*ori = 3;
BOOST_TEST(bool(oi));
BOOST_TEST_EQ(3, *oi);
BOOST_TEST_EQ(3, *ori);
}
{
optional<int> oi (0);
optional<int&> ori = oi.flat_map(get_opt_ref());
BOOST_TEST(!ori);
}
{
optional<int> oi;
optional<int&> ori = oi.flat_map(get_opt_ref());
BOOST_TEST(!ori);
}
}
optional<int&> get_opt_int_ref(Int& i)
{
return i.i ? optional<int&>(i.i) : optional<int&>();
}
void test_flat_map_ref_to_ref()
{
{
Int I (5);
optional<Int&> orI (I);
verify_type< optional<int&> >(orI.flat_map(get_opt_int_ref));
optional<int&> ori = orI.flat_map(get_opt_int_ref);
BOOST_TEST(bool(ori));
BOOST_TEST_EQ(5, *ori);
*ori = 6;
BOOST_TEST_EQ(6, *ori);
BOOST_TEST_EQ(6, I.i);
}
{
Int I (0);
optional<Int&> orI (I);
optional<int&> ori = orI.flat_map(get_opt_int_ref);
BOOST_TEST(!ori);
}
{
optional<Int&> orI;
optional<int&> ori = orI.flat_map(get_opt_int_ref);
BOOST_TEST(!ori);
}
}
optional< optional<Int> > make_opt_int(int i)
{
if (i == 0)
return boost::none;
else if (i == 1)
return boost::make_optional(optional<Int>());
else
return boost::make_optional(boost::make_optional(Int(i)));
}
void test_flat_map_opt_opt()
{
{
optional<int> oi (9);
verify_type<optional<optional<Int> > >(oi.flat_map(make_opt_int));
optional<optional<Int> > ooI = oi.flat_map(make_opt_int);
BOOST_TEST(bool(ooI));
BOOST_TEST(bool(*ooI));
BOOST_TEST_EQ(9, (**ooI).i);
}
{
optional<int> oi (1);
optional<optional<Int> > ooI = oi.flat_map(make_opt_int);
BOOST_TEST(bool(ooI));
BOOST_TEST(!*ooI);
}
{
optional<int> oi (0);
optional<optional<Int> > ooI = oi.flat_map(make_opt_int);
BOOST_TEST(!ooI);
}
{
optional<int> oi;
optional<optional<Int> > ooI = oi.flat_map(make_opt_int);
BOOST_TEST(!ooI);
}
}
#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
struct MoveOnly
{
int value;
explicit MoveOnly(int i) : value(i) {}
MoveOnly(MoveOnly && r) : value(r.value) { r.value = 0; }
MoveOnly& operator=(MoveOnly && r) { value = r.value; r.value = 0; return *this; }
private:
MoveOnly(MoveOnly const&);
void operator=(MoveOnly const&);
};
MoveOnly makeMoveOnly(int i)
{
return MoveOnly(i);
}
optional<MoveOnly> makeOptMoveOnly(int i)
{
return optional<MoveOnly>(MoveOnly(i));
}
optional<int> get_val(MoveOnly m)
{
return optional<int>(m.value != 0, m.value);
}
void test_flat_map_move_only()
{
{
optional<MoveOnly> om (makeMoveOnly(1)), om2 (makeMoveOnly(2));
verify_type<optional<int> >(boost::move(om).flat_map(get_val));
optional<int> oi = boost::move(om2).flat_map(get_val);
BOOST_TEST(bool(oi));
BOOST_TEST_EQ(2, *oi);
}
{
optional<int> oj = makeOptMoveOnly(4).flat_map(get_val);
BOOST_TEST(bool(oj));
BOOST_TEST_EQ(4, *oj);
}
{
optional<int> oj = optional<MoveOnly>().flat_map(get_val);
BOOST_TEST(!oj);
}
}
#endif // no rvalue refs
int main()
{
test_flat_map_on_mutable_optional_with_function_object();
test_flat_map_on_const_optional_with_function_object();
test_flat_map_with_lambda();
test_flat_map_obj_to_ref();
test_flat_map_ref_to_ref();
test_flat_map_opt_opt();
#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
test_flat_map_move_only();
#endif
return boost::report_errors();
}

View File

@ -0,0 +1,64 @@
// 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/optional.hpp"
#include "boost/config.hpp"
#include "boost/core/lightweight_test.hpp"
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET) && !defined(BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH)
#include <unordered_set>
void test_unordered_map()
{
std::unordered_set<boost::optional<int> > set;
set.insert(boost::optional<int>(1));
set.insert(boost::optional<int>(1));
BOOST_TEST(set.size() == 1u);
BOOST_TEST(set.find(boost::optional<int>(1)) != set.end());
}
#else
void test_unordered_map()
{}
#endif
#if !defined(BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
void tets_hash()
{
std::hash<boost::optional<int> > hash_int;
boost::optional<int> oN;
boost::optional<int> o1(1);
BOOST_TEST(hash_int(oN) == hash_int(oN));
BOOST_TEST(hash_int(o1) == hash_int(o1));
}
#else
void tets_hash()
{}
#endif
int main()
{
test_unordered_map();
tets_hash();
return boost::report_errors();
}

View File

@ -13,7 +13,7 @@
#include<string>
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
@ -31,10 +31,10 @@ struct Guard
std::string str;
Guard() : num() {}
Guard(double num_, std::string str_) : num(num_), str(str_) {}
friend bool operator==(const Guard& lhs, const Guard& rhs) { return lhs.num == rhs.num && lhs.str == rhs.str; }
friend bool operator!=(const Guard& lhs, const Guard& rhs) { return !(lhs == rhs); }
private:
Guard(const Guard&);
Guard& operator=(const Guard&);
@ -44,26 +44,30 @@ void test_ctor()
{
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
Guard g0, g1(1.0, "one"), g2(2.0, "two");
boost::optional<Guard> og0 ( boost::in_place() );
boost::optional<Guard> og1 ( boost::in_place(1.0, "one") );
boost::optional<Guard> og1_( boost::in_place(1.0, "one") );
boost::optional<Guard> og2 ( boost::in_place<Guard>(2.0, "two") );
BOOST_TEST(og0);
BOOST_TEST(og1);
BOOST_TEST(og1_);
BOOST_TEST(og2);
BOOST_TEST(*og0 == g0);
BOOST_TEST(*og1 == g1);
BOOST_TEST(*og1_ == g1);
BOOST_TEST(*og2 == g2);
BOOST_TEST(og1_ == og1);
BOOST_TEST(og1_ != og2);
BOOST_TEST(og1_ != og0);
#endif
boost::optional<unsigned int> o( boost::in_place(5) );
BOOST_TEST(o);
BOOST_TEST(*o == 5);
#endif
}
void test_assign()
@ -71,27 +75,32 @@ void test_assign()
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#ifndef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
Guard g0, g1(1.0, "one"), g2(2.0, "two");
boost::optional<Guard> og0, og1, og1_, og2;
og0 = boost::in_place();
og1 = boost::in_place(1.0, "one");
og1_ = boost::in_place(1.0, "one");
og2 = boost::in_place<Guard>(2.0, "two");
BOOST_TEST(og0);
BOOST_TEST(og1);
BOOST_TEST(og1_);
BOOST_TEST(og2);
BOOST_TEST(*og0 == g0);
BOOST_TEST(*og1 == g1);
BOOST_TEST(*og1_ == g1);
BOOST_TEST(*og2 == g2);
BOOST_TEST(og1_ == og1);
BOOST_TEST(og1_ != og2);
BOOST_TEST(og1_ != og0);
boost::optional<unsigned int> o;
o = boost::in_place(5);
BOOST_TEST(o);
BOOST_TEST(*o == 5);
#endif
#endif
}
@ -101,4 +110,4 @@ int main()
test_ctor();
test_assign();
return boost::report_errors();
}
}

View File

@ -13,7 +13,7 @@
#include<string>
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@ -13,7 +13,7 @@
#include<string>
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@ -10,18 +10,21 @@
// You are welcome to contact the author at:
// fernando_cacciola@hotmail.com
#include <sstream>
#include "boost/optional/optional.hpp"
#include "boost/optional/optional_io.hpp"
#include "boost/core/lightweight_test.hpp"
#ifdef __BORLANDC__
#ifndef BOOST_NO_IOSTREAM
#include <sstream>
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/core/lightweight_test.hpp"
using boost::optional;
using boost::make_optional;
template<class Opt>
void test2( Opt o, Opt buff )
@ -30,7 +33,7 @@ void test2( Opt o, Opt buff )
const int markv = 123 ;
int mark = 0 ;
s << o << " " << markv ;
s >> buff >> mark ;
@ -42,10 +45,10 @@ void test2( Opt o, Opt buff )
template<class T>
void test( T v, T w )
{
test2( make_optional(v), optional<T> ());
test2( make_optional(v), make_optional(w));
test2( boost::make_optional(v), optional<T> ());
test2( boost::make_optional(v), boost::make_optional(w));
test2( optional<T> () , optional<T> ());
test2( optional<T> () , make_optional(w));
test2( optional<T> () , boost::make_optional(w));
}
@ -86,3 +89,12 @@ int main()
return boost::report_errors();
}
#else // BOOST_NO_IOSTREAM
int main()
{
return boost::report_errors();
}
#endif // BOOST_NO_IOSTREAM

View File

@ -0,0 +1,121 @@
// Copyright (C) 2017 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/optional.hpp"
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/core/ignore_unused.hpp"
#include "boost/core/is_same.hpp"
#include "boost/core/lightweight_test.hpp"
#include "boost/core/lightweight_test_trait.hpp"
using boost::optional;
using boost::make_optional;
using boost::core::is_same;
template <typename Expected, typename Deduced>
void verify_type(Deduced)
{
BOOST_TEST_TRAIT_TRUE(( is_same<Expected, Deduced> ));
}
#if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
struct MoveOnly
{
int value;
explicit MoveOnly(int i) : value(i) {}
MoveOnly(MoveOnly && r) : value(r.value) { r.value = 0; }
MoveOnly& operator=(MoveOnly && r) { value = r.value; r.value = 0; return *this; }
private:
MoveOnly(MoveOnly const&);
void operator=(MoveOnly const&);
};
MoveOnly makeMoveOnly(int i)
{
return MoveOnly(i);
}
void test_make_optional_for_move_only_type()
{
verify_type< optional<MoveOnly> >(make_optional(makeMoveOnly(2)));
verify_type< optional<MoveOnly> >(make_optional(true, makeMoveOnly(2)));
optional<MoveOnly> o1 = make_optional(makeMoveOnly(1));
BOOST_TEST (o1);
BOOST_TEST_EQ (1, o1->value);
optional<MoveOnly> o2 = make_optional(true, makeMoveOnly(2));
BOOST_TEST (o2);
BOOST_TEST_EQ (2, o2->value);
optional<MoveOnly> oN = make_optional(false, makeMoveOnly(2));
BOOST_TEST (!oN);
}
#endif // !defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
void test_make_optional_for_optional()
{
optional<int> oi;
verify_type< optional< optional<int> > >(make_optional(oi));
verify_type< optional< optional<int> > >(make_optional(true, oi));
optional< optional<int> > ooi = make_optional(oi);
BOOST_TEST (ooi);
BOOST_TEST (!*ooi);
optional< optional<int> > ooT = make_optional(true, oi);
BOOST_TEST (ooT);
BOOST_TEST (!*ooT);
optional< optional<int> > ooF = make_optional(false, oi);
BOOST_TEST (!ooF);
}
void test_nested_make_optional()
{
verify_type< optional< optional<int> > >(make_optional(make_optional(1)));
verify_type< optional< optional<int> > >(make_optional(true, make_optional(true, 2)));
optional< optional<int> > oo1 = make_optional(make_optional(1));
BOOST_TEST (oo1);
BOOST_TEST (*oo1);
BOOST_TEST_EQ (1, **oo1);
optional< optional<int> > oo2 = make_optional(true, make_optional(true, 2));
BOOST_TEST (oo2);
BOOST_TEST (*oo2);
BOOST_TEST_EQ (2, **oo2);
optional< optional<int> > oo3 = make_optional(true, make_optional(false, 3));
BOOST_TEST (oo3);
BOOST_TEST (!*oo3);
optional< optional<int> > oo4 = make_optional(false, make_optional(true, 4));
BOOST_TEST (!oo4);
}
int main()
{
#if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
test_make_optional_for_move_only_type();
#endif
test_make_optional_for_optional();
test_nested_make_optional();
return boost::report_errors();
}

192
test/optional_test_map.cpp Normal file
View File

@ -0,0 +1,192 @@
// Copyright (C) 2018 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/optional.hpp"
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/core/ignore_unused.hpp"
#include "boost/core/is_same.hpp"
#include "boost/core/lightweight_test.hpp"
#include "boost/core/lightweight_test_trait.hpp"
using boost::optional;
using boost::make_optional;
using boost::core::is_same;
template <typename Expected, typename Deduced>
void verify_type(Deduced)
{
BOOST_TEST_TRAIT_TRUE(( is_same<Expected, Deduced> ));
}
#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
struct MoveOnly
{
int value;
explicit MoveOnly(int i) : value(i) {}
MoveOnly(MoveOnly && r) : value(r.value) { r.value = 0; }
MoveOnly& operator=(MoveOnly && r) { value = r.value; r.value = 0; return *this; }
private:
MoveOnly(MoveOnly const&);
void operator=(MoveOnly const&);
};
MoveOnly makeMoveOnly(int i)
{
return MoveOnly(i);
}
optional<MoveOnly> makeOptMoveOnly(int i)
{
return optional<MoveOnly>(MoveOnly(i));
}
int get_val(MoveOnly m)
{
return m.value;
}
void test_map_move_only()
{
optional<MoveOnly> om (makeMoveOnly(7)), om2 (makeMoveOnly(8));
verify_type<optional<int> >(boost::move(om).map(get_val));
optional<int> oi = boost::move(om2).map(get_val);
BOOST_TEST(bool(oi));
BOOST_TEST_EQ(8, *oi);
optional<int> oj = makeOptMoveOnly(4).map(get_val);
BOOST_TEST(bool(oj));
BOOST_TEST_EQ(4, *oj);
optional<MoveOnly> o_;
optional<int> oi_ = boost::move(o_).map(get_val);
BOOST_TEST(!oi_);
}
#endif // no rvalue refs
struct Int
{
int i;
explicit Int(int i_) : i(i_) {}
};
struct convert_t
{
typedef Int result_type;
Int operator()(int i) { return Int(i); }
};
int& get_int_ref(Int& i)
{
return i.i;
}
struct get_ref
{
typedef int& result_type;
int& operator()(int& i) { return i; }
};
void test_map()
{
optional<int> oi (1);
verify_type<optional<Int> >(oi.map(convert_t()));
optional<Int> oI = oi.map(convert_t());
BOOST_TEST(bool(oI));
BOOST_TEST_EQ(1, oI->i);
optional<Int> o_ = optional<int>().map(convert_t());
BOOST_TEST(!o_);
}
optional<Int> make_opt_int(int i)
{
if (i != 0)
return Int(i);
else
return boost::none;
}
void test_map_optional()
{
optional<int> o9 (9), o0 (0), o_;
verify_type<optional<optional<Int> > >(o9.map(make_opt_int));
optional<optional<Int> > oo9 = o9.map(make_opt_int);
BOOST_TEST(bool(oo9));
BOOST_TEST(bool(*oo9));
BOOST_TEST_EQ(9, (**oo9).i);
optional<optional<Int> > oo0 = o0.map(make_opt_int);
BOOST_TEST(bool(oo0));
BOOST_TEST(!*oo0);
optional<optional<Int> > oo_ = o_.map(make_opt_int);
BOOST_TEST(!oo_);
}
void test_map_with_lambda()
{
#if !defined BOOST_NO_CXX11_LAMBDAS && !defined BOOST_NO_CXX11_DECLTYPE_N3276
optional<int> oi (1), oj(2);
verify_type<optional<bool> >(oi.map([](int i){ return i == 1; }));
optional<bool> ob = oi.map([](int i){ return i == 1; });
optional<bool> oc = oj.map([](int i){ return i == 1; });
BOOST_TEST(bool(ob));
BOOST_TEST_EQ(true, *ob);
BOOST_TEST(bool(oc));
BOOST_TEST_EQ(false, *oc);
#endif // lambdas
}
void test_map_to_ref()
{
optional<int> oi (2);
verify_type<optional<int&> >(oi.map(get_ref()));
optional<int&> ori = oi.map(get_ref());
BOOST_TEST(bool(ori));
*ori = 3;
BOOST_TEST(bool(oi));
BOOST_TEST_EQ(3, *oi);
BOOST_TEST_EQ(3, *ori);
}
void test_map_optional_ref()
{
Int I (5);
optional<Int&> ori (I);
verify_type<optional<int&> >(ori.map(get_int_ref));
optional<int&> orii = ori.map(get_int_ref);
BOOST_TEST(bool(orii));
BOOST_TEST_EQ(5, *orii);
*orii = 6;
BOOST_TEST_EQ(6, I.i);
}
int main()
{
#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
test_map_move_only();
#endif
test_map_with_lambda();
test_map();
test_map_optional();
test_map_to_ref();
test_map_optional();
test_map_optional_ref();
return boost::report_errors();
}

View File

@ -0,0 +1,32 @@
// Copyright (C) 2017 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/optional.hpp"
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
boost::optional<int> getitem();
int main(int argc, const char *[])
{
boost::optional<int> a = getitem();
boost::optional<int> b;
if (argc > 0)
b = argc;
if (a == b)
return 1;
return 0;
}

View File

@ -0,0 +1,44 @@
// 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/optional.hpp"
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/core/lightweight_test.hpp"
struct Status
{
enum T
{
DISCONNECTED,
CONNECTING,
CONNECTED,
};
T mValue;
};
void test_member_T()
{
boost::optional<Status> x = Status();
x->mValue = Status::CONNECTED;
BOOST_TEST(x->mValue == Status::CONNECTED);
}
int main()
{
test_member_T();
return boost::report_errors();
}

View File

@ -11,10 +11,11 @@
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include <string>
#include "boost/core/lightweight_test.hpp"
#include "boost/none.hpp"

View File

@ -12,7 +12,7 @@
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@ -12,7 +12,7 @@
#define BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@ -12,7 +12,7 @@
#include "boost/static_assert.hpp"
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif

View File

@ -0,0 +1,223 @@
// Copyright (C) 2014 - 2018 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
#define BOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL // does old implementation still work for basic usage?
#include "boost/optional/optional.hpp"
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/core/ignore_unused.hpp"
#include "boost/core/lightweight_test.hpp"
using boost::optional;
struct IntWrapper
{
int _i;
IntWrapper(int i) : _i(i) {}
bool operator==(IntWrapper const& rhs) const { return _i == rhs._i; }
};
template <typename T>
void test_function_value_or_for()
{
optional<T> oM0;
const optional<T> oC0;
optional<T> oM1(1);
const optional<T> oC2(2);
BOOST_TEST(oM0.value_or(5) == 5);
BOOST_TEST(oC0.value_or(5) == 5);
BOOST_TEST(oM1.value_or(5) == 1);
BOOST_TEST(oC2.value_or(5) == 2);
}
template <typename T>
void test_function_value_for()
{
optional<T> o0;
optional<T> o1(1);
const optional<T> oC(2);
try
{
T& v = o1.value();
BOOST_TEST(v == 1);
}
catch(...)
{
BOOST_TEST(false);
}
try
{
T const& v = oC.value();
BOOST_TEST(v == 2);
}
catch(...)
{
BOOST_TEST(false);
}
BOOST_TEST_THROWS(o0.value(), boost::bad_optional_access);
}
void test_function_value()
{
test_function_value_for<int>();
test_function_value_for<double>();
test_function_value_for<IntWrapper>();
}
struct FatToIntConverter
{
static int conversions;
int _val;
FatToIntConverter(int val) : _val(val) {}
operator int() const { conversions += 1; return _val; }
};
int FatToIntConverter::conversions = 0;
void test_function_value_or()
{
test_function_value_or_for<int>();
test_function_value_or_for<double>();
test_function_value_or_for<IntWrapper>();
optional<int> oi(1);
BOOST_TEST(oi.value_or(FatToIntConverter(2)) == 1);
BOOST_TEST(FatToIntConverter::conversions == 0);
oi = boost::none;
BOOST_TEST(oi.value_or(FatToIntConverter(2)) == 2);
BOOST_TEST(FatToIntConverter::conversions == 1);
}
struct FunM
{
int operator()() { return 5; }
};
struct FunC
{
int operator()() const { return 6; }
};
int funP ()
{
return 7;
}
int throw_()
{
throw int();
}
void test_function_value_or_eval()
{
optional<int> o1 = 1;
optional<int> oN;
FunM funM;
FunC funC;
BOOST_TEST_EQ(o1.value_or_eval(funM), 1);
BOOST_TEST_EQ(oN.value_or_eval(funM), 5);
BOOST_TEST_EQ(o1.value_or_eval(FunM()), 1);
BOOST_TEST_EQ(oN.value_or_eval(FunM()), 5);
BOOST_TEST_EQ(o1.value_or_eval(funC), 1);
BOOST_TEST_EQ(oN.value_or_eval(funC), 6);
BOOST_TEST_EQ(o1.value_or_eval(FunC()), 1);
BOOST_TEST_EQ(oN.value_or_eval(FunC()), 6);
BOOST_TEST_EQ(o1.value_or_eval(funP), 1);
BOOST_TEST_EQ(oN.value_or_eval(funP), 7);
#ifndef BOOST_NO_CXX11_LAMBDAS
BOOST_TEST_EQ(o1.value_or_eval([](){return 8;}), 1);
BOOST_TEST_EQ(oN.value_or_eval([](){return 8;}), 8);
#endif
try
{
BOOST_TEST_EQ(o1.value_or_eval(throw_), 1);
}
catch(...)
{
BOOST_TEST(false);
}
BOOST_TEST_THROWS(oN.value_or_eval(throw_), int);
}
const optional<std::string> makeConstOptVal()
{
return std::string("something");
}
void test_const_move()
{
std::string s5 = *makeConstOptVal();
std::string s6 = makeConstOptVal().value();
boost::ignore_unused(s5);
boost::ignore_unused(s6);
}
#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
struct MoveOnly
{
explicit MoveOnly(int){}
MoveOnly(MoveOnly &&){}
void operator=(MoveOnly &&);
private:
MoveOnly(MoveOnly const&);
void operator=(MoveOnly const&);
};
optional<MoveOnly> makeMoveOnly()
{
return MoveOnly(1);
}
MoveOnly moveOnlyDefault()
{
return MoveOnly(1);
}
// compile-time test
void test_move_only_getters()
{
MoveOnly m1 = *makeMoveOnly();
MoveOnly m2 = makeMoveOnly().value();
MoveOnly m3 = makeMoveOnly().value_or(MoveOnly(1));
MoveOnly m4 = makeMoveOnly().value_or_eval(moveOnlyDefault);
boost::ignore_unused(m1);
boost::ignore_unused(m2);
boost::ignore_unused(m3);
boost::ignore_unused(m4);
}
#endif // !defined BOOST_NO_CXX11_REF_QUALIFIERS
int main()
{
test_function_value();
test_function_value_or();
test_function_value_or_eval();
test_const_move();
return boost::report_errors();
}

View File

@ -0,0 +1,73 @@
// Copyright (C) 2019 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/optional.hpp"
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#ifndef BOOST_OPTIONAL_DETAIL_NO_IS_CONSTRUCTIBLE_TRAIT
#ifndef BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS
template <typename, typename>
struct void_t
{
typedef void type;
};
template <typename T, typename = void>
struct trait
{
};
// the following trait emulates properties std::iterator_traits
template <typename T>
struct trait<T, BOOST_DEDUCED_TYPENAME void_t<BOOST_DEDUCED_TYPENAME T::value_type,
BOOST_DEDUCED_TYPENAME boost::enable_if<boost::is_constructible<T, T&> >::type
>::type>
{
typedef BOOST_DEDUCED_TYPENAME T::value_type value_type;
};
// This class emulates the properties of std::filesystem::path
struct Path
{
#if __cplusplus >= 201103
template <typename T, typename = BOOST_DEDUCED_TYPENAME trait<T>::value_type>
Path(T const&);
#else
template <typename T>
Path(T const&, BOOST_DEDUCED_TYPENAME trait<T>::value_type* = 0);
#endif
};
#endif
#endif
int main()
{
#ifndef BOOST_OPTIONAL_DETAIL_NO_IS_CONSTRUCTIBLE_TRAIT
#ifndef BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS
boost::optional<Path> optFs1;
boost::optional<Path> optFs2;
optFs1 = optFs2;
// the following still fails although it shouldn't
//BOOST_STATIC_ASSERT((std::is_copy_constructible<boost::optional<Path>>::value));
#endif
#endif
}

Some files were not shown because too many files have changed in this diff Show More