Compare commits

...

85 Commits

Author SHA1 Message Date
c60db27762 Fixed misspelled word 'from' 2023-11-09 00:38:43 +01:00
5064a9a28d GHA: Fix osx job (update image) 2023-11-09 00:38:43 +01:00
fe0384baa6 GHA: Update installed packages on containers 2023-11-09 00:38:43 +01:00
76c82e83ae GHA: Fix failing jobs by updating removed images 2023-11-09 00:38:43 +01:00
e59b1bce1d Fix typo in none_t.hpp. Closes #115. 2023-11-09 00:38:43 +01:00
f95fb5dff2 fix docs 2023-11-09 00:38:43 +01:00
7878dec842 document monadic interface 2023-11-09 00:38:43 +01:00
a3abf04548 added deprecation message 2023-11-09 00:38:43 +01:00
9c43ae3612 Use is_same from Boost.TypeTraits.
boost::core::is_same is deprecated, so use the one from Boost.TypeTraits
instead.
2023-11-09 00:38:43 +01:00
def2db7c45 Switch to boost::core::invoke_swap.
boost::swap is deprecated and will be removed. Use boost::core::invoke_swap
as a replacement.
2023-11-09 00:38:43 +01:00
6266c39b8e note on deprecating C++03 support 2023-07-11 00:39:14 +02:00
e300c4bc60 spelling: value
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:14 +02:00
302f39e545 spelling: unswapped
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:14 +02:00
d4f84a868d spelling: unique
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
46ad495a60 spelling: uninitialized
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
246f1663e1 spelling: trivially
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
668c8d924b spelling: suppressing
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
653ebefbac spelling: support
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
ce500ee436 spelling: specialization
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
b4c8f493c6 spelling: shallow
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
7e395f4520 spelling: screwed
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
630cf7f7b5 spelling: referred
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
cdc2bd8482 spelling: references
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
db472e7ed6 spelling: recognized
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
8ffb7e3f57 spelling: pointees
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
deda20af89 spelling: overloads
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
4b63acfc10 spelling: optional
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
599c72f23b spelling: occur
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
a4479bf8cd spelling: nonexistent
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
ba1846abd3 spelling: necessarily
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
168552e021 spelling: msvc
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
581c43f25c spelling: member
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
c76b73c48b spelling: management
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
e26c2d7489 spelling: intel
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
969930959c spelling: implicitly
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
56156dcc87 spelling: functions
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
802e73477a spelling: flagged
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
9944804c5c spelling: doesn't
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
2121a9fa59 spelling: different
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
cc416b8989 spelling: deprecated
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
74a684232f spelling: defined
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
6f85014c00 spelling: converting
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
29dd9187ec spelling: convertibility
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
bcc83a662a spelling: compiling
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
c4291fa461 spelling: compiler
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
de27c0f853 spelling: classes
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
9c44e402f6 spelling: because
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
5ab4701192 spelling: assignment
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
ab7e5275c0 spelling: addresses
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
416c89e165 spelling: achieve
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-07-11 00:39:13 +02:00
c809700d6a Merge branch 'develop' 2022-07-30 18:50:53 +02:00
293d1861d7 fixed broken links to SGI docs 2022-07-30 10:09:35 +02:00
3038bdea4b Merge branch 'develop' 2022-06-22 22:59:18 +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
4ead6d14ff Added release notes 2022-03-26 23:52:09 +01:00
78d42ff970 Merge branch 'develop' 2022-03-26 23:32:57 +01: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
5a444eb84b docs: updated copyright notice 2021-03-10 23:07:18 +01:00
0566bde447 Merge branch 'develop' 2021-03-10 23:01:22 +01: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
100 changed files with 1218 additions and 331 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

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

@ -0,0 +1,396 @@
name: GitHub Actions CI
on:
pull_request:
push:
branches:
- master
- develop
- githubactions*
- feature/**
- fix/**
- pr/**
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
NET_RETRY_COUNT: 5
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: "clang"
packages_to_remove: ""
os: "ubuntu-22.04"
container: "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-22.04"
container: "ubuntu:18.04"
cxx: "clang++-5.0"
sources: ""
llvm_os: ""
llvm_ver: ""
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: |
if [ -f "/etc/debian_version" ]; then
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
export DEBIAN_FRONTEND=noninteractive
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common curl wget apt-transport-https ca-certificates
# Need (newer) git, and the older Ubuntu container may require requesting the key manually using port 80
curl -sSL --retry ${NET_RETRY_COUNT:-5} 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xE1DD270288B4E6030699E45FA1715D88E1DF1F24' | sudo gpg --dearmor > /etc/apt/trusted.gpg.d/git-core_ubuntu_ppa.gpg
for i in {1..${NET_RETRY_COUNT:-3}}; do sudo -E add-apt-repository -y ppa:git-core/ppa && break || sleep 10; done
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y g++ python libpython-dev git unzip libssl-dev build-essential libc++-helpers gcc-multilib g++-multilib pkgconf ccache
fi
- 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-11"
cxx: "clang++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang"
compiler: "clang++"
cxxstd: "03,11,14,17,2a"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- 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

View File

@ -1,12 +1,9 @@
# 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
#
# NOTE: CMake support for Boost.Optional is currently experimental at best
# and the interface is likely to change in the future
cmake_minimum_required( VERSION 3.5 )
project( BoostOptional )
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 )

View File

@ -2,7 +2,7 @@
[quickbook 1.4]
[authors [Cacciola Carballal, Fernando Luis]]
[copyright 2003-2007 Fernando Luis Cacciola Carballal]
[copyright 2014-2018 Andrzej Krzemie&#324;ski]
[copyright 2014-2023 Andrzej Krzemie&#324;ski]
[category miscellaneous]
[id optional]
[dirname optional]
@ -38,10 +38,10 @@ Distributed under the Boost Software License, Version 1.0.
[/ Other web resources ]
[def __HASKELL__ [@http://www.haskell.org/ Haskell]]
[def __SGI_DEFAULT_CONSTRUCTIBLE__ [@http://www.sgi.com/tech/stl/DefaultConstructible.html `DefaultConstructible`]]
[def __SGI_LESS_THAN_COMPARABLE__ [@http://www.sgi.com/tech/stl/LessThanComparable.html `LessThanComparable`]]
[def __SGI_EQUALITY_COMPARABLE__ [@http://www.sgi.com/tech/stl/EqualityComparable.html `EqualityComparable`]]
[def __SGI_GENERATOR__ [@http://www.sgi.com/tech/stl/Generator.html `Generator`]]
[def __STD_DEFAULT_CONSTRUCTIBLE__ [@https://en.cppreference.com/w/cpp/named_req/DefaultConstructible `DefaultConstructible`]]
[def __STD_LESS_THAN_COMPARABLE__ [@https://en.cppreference.com/w/cpp/named_req/LessThanComparable `LessThanComparable`]]
[def __STD_EQUALITY_COMPARABLE__ [@https://en.cppreference.com/w/cpp/named_req/EqualityComparable `EqualityComparable`]]
[def __SGI_GENERATOR__ [@http://www.rrsd.com/software_development/stl/stl/Generator.html `Generator`]]
[/ Icons ]
@ -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]
@ -80,13 +80,14 @@ This is how you solve it with `boost::optional`:
[include 11_development.qbk]
[include 12_when_to_use.qbk]
[include 13_relational_operators.qbk]
[include 14_io.qbk]
[include 15_optional_references.qbk]
[include 16_in_place_factories.qbk]
[include 17_gotchas.qbk]
[include 18_exception_safety.qbk]
[include 19_type_requirements.qbk]
[include 1A_on_performance.qbk]
[include 14_monadic_interface.qbk]
[include 15_io.qbk]
[include 16_optional_references.qbk]
[include 17_in_place_factories.qbk]
[include 18_gotchas.qbk]
[include 19_exception_safety.qbk]
[include 1A_type_requirements.qbk]
[include 1B_on_performance.qbk]
[endsect]
[section:reference Reference]
[include 21_ref_none.qbk]
@ -102,5 +103,3 @@ This is how you solve it with `boost::optional`:
[include 90_dependencies.qbk]
[include 91_relnotes.qbk]
[include 92_acknowledgments.qbk]

View File

@ -25,7 +25,7 @@ All necessary functionality can be included with one header `<boost/optional.hpp
boost::optional<int> oi = convert(text); // move-construct
if (oi) // contextual conversion to bool
int i = *oi; // operator*
In order to test if `optional` contains a value, we use the contextual conversion to type `bool`. Because of this we can combine the initialization of the optional object and the test into one instruction:
if (boost::optional<int> oi = convert(text))
@ -34,7 +34,7 @@ In order to test if `optional` contains a value, we use the contextual conversio
We extract the contained value with `operator*` (and with `operator->` where it makes sense). An attempt to extract the contained value of an uninitialized optional object is an ['undefined behaviour] (UB). This implementation guards the call with `BOOST_ASSERT`. Therefore you should be sure that the contained value is there before extracting. For instance, the following code is reasonably UB-safe:
int i = *convert("100");
This is because we know that string value `"100"` converts to a valid value of `int`. If you do not like this potential UB, you can use an alternative way of extracting the contained value:
try {
@ -44,18 +44,18 @@ This is because we know that string value `"100"` converts to a valid value of `
// deal with it
}
This version throws an exception upon an attempt to access a non-existent contained value. If your way of dealing with the missing value is to use some default, like `0`, there exists a yet another alternative:
This version throws an exception upon an attempt to access a nonexistent contained value. If your way of dealing with the missing value is to use some default, like `0`, there exists a yet another alternative:
int k = convert(text).value_or(0);
This uses the `atoi`-like approach to conversions: if `text` does not represent an integral number just return `0`. Finally, you can provide a callback to be called when trying to access the contained value fails:
int fallback_to_default()
{
cerr << "could not convert; using -1 instead" << endl;
cerr << "could not convert; using -1 instead" << endl;
return -1;
}
int l = convert(text).value_or_eval(fallback_to_default);
This will call the provided callback and return whatever the callback returns. The callback can have side effects: they will only be observed when the optional object does not contain a value.
@ -63,7 +63,7 @@ This will call the provided callback and return whatever the callback returns. T
Now, let's consider how function `convert` can be implemented.
boost::optional<int> convert(const std::string& text)
{
{
std::stringstream s(text);
int i;
if ((s >> i) && s.get() == std::char_traits<char>::eof())
@ -72,7 +72,7 @@ Now, let's consider how function `convert` can be implemented.
return boost::none;
}
Observe the two return statements. `return i` uses the converting constructor that can create `optional<T>` from `T`. Thus constructed optional object is initialized and its value is a copy of `i`. The other return statement uses another converting constructor from a special tag `boost::none`. It is used to indicate that we want to create an uninitialized optional object.
Observe the two return statements. `return i` uses the converting constructor that can create `optional<T>` from `T`. Thus constructed optional object is initialized and its value is a copy of `i`. The other return statement uses another converting constructor from a special tag `boost::none`. It is used to indicate that we want to create an uninitialized optional object.
[endsect]
@ -91,7 +91,7 @@ We could write function `convert` in a slightly different manner, so that it has
return ans;
}
The default constructor of `optional` creates an unitialized optional object. Unlike with `int`s you cannot have an `optional<int>` in an indeterminate state. Its state is always well defined. Instruction `ans = i` initializes the optional object. It uses the 'mixed' assignment from `int`. In general, for `optional<T>`, when an assignment from `T` is invoked, it can do two things. If the optional object is not initialized (our case here), it initializes the contained value using `T`'s copy constructor. If the optional object is already initialized, it assigns the new value to it using `T`'s copy assignment.
The default constructor of `optional` creates an uninitialized optional object. Unlike with `int`s you cannot have an `optional<int>` in an indeterminate state. Its state is always well defined. Instruction `ans = i` initializes the optional object. It uses the 'mixed' assignment from `int`. In general, for `optional<T>`, when an assignment from `T` is invoked, it can do two things. If the optional object is not initialized (our case here), it initializes the contained value using `T`'s copy constructor. If the optional object is already initialized, it assigns the new value to it using `T`'s copy assignment.
[endsect]
[section Optional data members]
@ -101,20 +101,20 @@ Suppose we want to implement a ['lazy load] optimization. This is because we do
class Widget
{
mutable boost::optional<const Resource> resource_;
public:
Widget() {}
const Resource& getResource() const // not thread-safe
{
if (resource_ == boost::none)
resource_.emplace("resource", "arguments");
return *resource_;
}
};
`optional`'s default constructor creates an uninitialized optional. No call to `Resource`'s default constructor is attempted. `Resource` doesn't have to be __SGI_DEFAULT_CONSTRUCTIBLE__. In function `getResource` we first check if `resource_` is initialized. This time we do not use the contextual conversion to `bool`, but a comparison with `boost::none`. These two ways are equivalent. Function `emplace` initializes the optional in-place by perfect-forwarding the arguments to the constructor of `Resource`. No copy- or move-construction is involved here. `Resource` doesn't even have to be `MoveConstructible`.
`optional`'s default constructor creates an uninitialized optional. No call to `Resource`'s default constructor is attempted. `Resource` doesn't have to be __STD_DEFAULT_CONSTRUCTIBLE__. In function `getResource` we first check if `resource_` is initialized. This time we do not use the contextual conversion to `bool`, but a comparison with `boost::none`. These two ways are equivalent. Function `emplace` initializes the optional in-place by perfect-forwarding the arguments to the constructor of `Resource`. No copy- or move-construction is involved here. `Resource` doesn't even have to be `MoveConstructible`.
[note Function `emplace` is only available on compilers that support rvalue references and variadic templates. If your compiler does not support these features and you still need to avoid any move-constructions, use [link boost_optional.tutorial.in_place_factories In-Place Factories].]
@ -125,17 +125,17 @@ Suppose we want to implement a ['lazy load] optimization. This is because we do
Suppose we have class `Date`, which does not have a default constructor: there is no good candidate for a default date. We have a function that returns two dates in form of a `boost::tuple`:
boost::tuple<Date, Date> getPeriod();
In other place we want to use the result of `getPeriod`, but want the two dates to be named: `begin` and `end`. We want to implement something like 'multiple return values':
Date begin, end; // Error: no default ctor!
boost::tie(begin, end) = getPeriod();
The second line works already, this is the capability of __BOOST_TUPLE__ library, but the first line won't work. We could set some invented initial dates, but it is confusing and may be an unacceptable cost, given that these values will be overwritten in the next line anyway. This is where `optional` can help:
boost::optional<Date> begin, end;
boost::tie(begin, end) = getPeriod();
It works because inside `boost::tie` a move-assignment from `T` is invoked on `optional<T>`, which internally calls a move-constructor of `T`.
[endsect]
@ -144,15 +144,17 @@ It works because inside `boost::tie` a move-assignment from `T` is invoked on `o
Suppose you want to ask users to choose some number (an `int`). One of the valid responses is to choose nothing, which is represented by an uninitialized `optional<int>`. You want to make a histogram showing how many times each choice was made. You can use an `std::map`:
std::map<boost::optional<int>, int> choices;
for (int i = 0; i < LIMIT; ++i) {
boost::optional<int> choice = readChoice();
++choices[choice];
}
This works because `optional<T>` is __SGI_LESS_THAN_COMPARABLE__ whenever `T` is __SGI_LESS_THAN_COMPARABLE__. In this case the state of being uninitialized is treated as a yet another value of `T`, which is compared less than any value of `T`.
This works because `optional<T>` is __STD_LESS_THAN_COMPARABLE__ whenever `T` is __STD_LESS_THAN_COMPARABLE__.
In this case the state of being uninitialized is treated as a yet another value of `T`,
which is compared less than any value of `T`.
`optional<T>` can also be stored as a key in `std::unordered_map` and `std::unordered_set`
as it provides specializations for `std::hash`.
[endsect]
[endsect]

View File

@ -11,7 +11,7 @@ Here, having received an empty `vec` and having no `size_t` to return is not a [
Another typical situation is to indicate that we do not have a value yet, but we expect to have it later. This notion can be used in implementing solutions like lazy initialization or a two-phase initialization.
`optional` can be used to take a non-__SGI_DEFAULT_CONSTRUCTIBLE__ type `T` and create a sibling type with a default constructor. This is a way to add a ['null-state] to any type that doesn't have it already.
`optional` can be used to take a non-__STD_DEFAULT_CONSTRUCTIBLE__ type `T` and create a sibling type with a default constructor. This is a way to add a ['null-state] to any type that doesn't have it already.
Sometimes type `T` already provides a built-in null-state, but it may still be useful to wrap it into `optional`. Consider `std::string`. When you read a piece of text from a GUI form or a DB table, it is hardly ever that the empty string indicates anything else but a missing text. And some data bases do not even distinguish between a null string entry and a non-null string of length 0. Still, it may be practical to use `optional<string>` to indicate in the returned type that we want to treat the empty string in a special dedicated program path:

View File

@ -1,37 +1,37 @@

[section Relational operators]
Type `optional<T>` is __SGI_EQUALITY_COMPARABLE__ whenever `T` is __SGI_EQUALITY_COMPARABLE__. Two optional objects containing a value compare in the same way as their contained values. The uninitialized state of `optional<T>` is treated as a distinct value, equal to itself, and unequal to any value of type `T`:
Type `optional<T>` is __STD_EQUALITY_COMPARABLE__ whenever `T` is __STD_EQUALITY_COMPARABLE__. Two optional objects containing a value compare in the same way as their contained values. The uninitialized state of `optional<T>` is treated as a distinct value, equal to itself, and unequal to any value of type `T`:
boost::optional<int> oN = boost::none;
boost::optional<int> o0 = 0;
boost::optional<int> o1 = 1;
assert(oN != o0);
assert(o1 != oN);
assert(o0 != o1);
assert(oN == oN);
assert(o0 == o0);
The converting constructor from `T` as well as from `boost::none` implies the existence and semantics of the mixed comparison between `T` and `optional<T>` as well as between `none_t` and `optionl<T>`:
The converting constructor from `T` as well as from `boost::none` implies the existence and semantics of the mixed comparison between `T` and `optional<T>` as well as between `none_t` and `optional<T>`:
assert(oN != 0);
assert(o1 != boost::none);
assert(o0 != 1);
assert(oN == boost::none);
assert(o0 == 0);
This mixed comparison has a practical interpretation, which is occasionally useful:
boost::optional<int> choice = ask_user();
if (choice == 2)
start_procedure_2();
In the above example, the meaning of the comparison is 'user chose number 2'. If user chose nothing, he didn't choose number 2.
In case where `optional<T>` is compared to `none`, it is not required that `T` be __SGI_EQUALITY_COMPARABLE__.
In case where `optional<T>` is compared to `none`, it is not required that `T` be __STD_EQUALITY_COMPARABLE__.
In a similar manner, type `optional<T>` is __SGI_LESS_THAN_COMPARABLE__ whenever `T` is __SGI_LESS_THAN_COMPARABLE__. The optional object containing no value is compared less than any value of `T`. To illustrate this, if the default ordering of `size_t` is {`0`, `1`, `2`, ...}, the default ordering of `optional<size_t>` is {`boost::none`, `0`, `1`, `2`, ...}. This order does not have a practical interpretation. The goal is to have any semantically correct default ordering in order for `optional<T>` to be usable in ordered associative containers (wherever `T` is usable).
In a similar manner, type `optional<T>` is __STD_LESS_THAN_COMPARABLE__ whenever `T` is __STD_LESS_THAN_COMPARABLE__. The optional object containing no value is compared less than any value of `T`. To illustrate this, if the default ordering of `size_t` is {`0`, `1`, `2`, ...}, the default ordering of `optional<size_t>` is {`boost::none`, `0`, `1`, `2`, ...}. This order does not have a practical interpretation. The goal is to have any semantically correct default ordering in order for `optional<T>` to be usable in ordered associative containers (wherever `T` is usable).
Mixed relational operators are the only case where the contained value of an optional object can be inspected without the usage of value accessing function (`operator*`, `value`, `value_or`).
[endsect]

View File

@ -0,0 +1,45 @@
[section Monadic interface]
The monadic interface of `optional` allows the application of functions
to optional values without resorting to the usage of explicit `if`-statements.
Function `map` takes a function mapping type `T` onto type `U` and maps an `optional<T>`
onto an `optional<U>` using the provided function.
int length(const string& s){ return s.size(); };
optional<string> null{}, thin{""}, word{"word"};
assert (null.map(length) == none);
assert (thin.map(length) == 0);
assert (word.map(length) == 4);
Function `flat_map` is similar, but it requires the function to return an
`optional<V>` for some type `V`. This `optional<V>` becomes the return type of
`flat_map`.
optional<char> first_char(const string& s) {
if (s.empty()) return none;
else return s[0];
};
optional<string> null{}, thin{""}, word{"word"};
assert (null.flat_map(first_char) == none);
assert (thin.flat_map(first_char) == none);
assert (word.flat_map(first_char) == 'w');
These functions can be combined in one expression reflecting a chain of computations:
auto get_contents(path p) -> optional<string>;
auto trim(string) -> string;
auto length(string) -> int;
auto trimmed_size_of(optional<path> p) -> int
{
return p.flat_map(get_contents)
.map(trim)
.map(length)
.value_or(0);
}
[endsect]

View File

@ -16,7 +16,7 @@ some operations are not available in this case:
* Value-access via pointer
Also, even though `optional<T&>` treats it wrapped pseudo-object much as
a real value, a true real reference is stored so aliasing will ocurr:
a real value, a true real reference is stored so aliasing will occur:
* Copies of `optional<T&>` will copy the references but all these references
will nonetheless refer to the same object.

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 __STD_LESS_THAN_COMPARABLE__ when `T` is __STD_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
@ -80,7 +80,7 @@ you can sometimes get an unexpected runtime result where you would rather expect
[section False positive with -Wmaybe-uninitialized]
Sometimes on GCC compilers below version 5.1 you may get an -Wmaybe-uninitialized warning when copiling with option -02 on a perfectly valid `boost::optional` usage. For instance in this program:
Sometimes on GCC compilers below version 5.1 you may get an -Wmaybe-uninitialized warning when compiling with option -02 on a perfectly valid `boost::optional` usage. For instance in this program:
#include <boost/optional.hpp>
@ -108,4 +108,4 @@ This is obviously redundant, but makes the warning disappear.
[endsect]
[endsect]
[endsect]

View File

@ -51,7 +51,7 @@ Operation `emplace` provides basic exception safety guarantee. If it throws, the
Unless `swap` on optional is customized, its primary implementation forwards calls to `T`'s `swap` or move constructor (depending on the initialization state of the optional objects). Thus, if both `T`'s `swap` and move constructor never throw, `swap` on `optional<T>` never throws. similarly, if both `T`'s `swap` and move constructor offer strong guarantee, `swap` on `optional<T>` also offers a strong guarantee.
In case `swap` on optional is customized, the call to `T`'s move constructor are replaced with the calls to `T`'s default constructor followed by `swap`. (This is more useful on older compilers that do not support move semantics, when one wants to acheive stronger exception safety guarantees.) In this case the exception safety guarantees for `swap` are reliant on the guarantees of `T`'s `swap` and default constructor
In case `swap` on optional is customized, the call to `T`'s move constructor are replaced with the calls to `T`'s default constructor followed by `swap`. (This is more useful on older compilers that do not support move semantics, when one wants to achieve stronger exception safety guarantees.) In this case the exception safety guarantees for `swap` are reliant on the guarantees of `T`'s `swap` and default constructor
[endsect]

View File

@ -33,6 +33,6 @@ If `T` is `Moveable` (both __MOVE_CONSTRUCTIBLE__ and `MoveAssignable`) then `op
Similarly, if `T` is `Copyable` (both __COPY_CONSTRUCTIBLE__ and `CopyAssignable`) then `optional<T>` is also `Copyable` and additionally can be constructed and assigned from an lvalue of type `T`.
`T` ['is not] required to be __SGI_DEFAULT_CONSTRUCTIBLE__.
`T` ['is not] required to be __STD_DEFAULT_CONSTRUCTIBLE__.
[endsect]

View File

@ -19,7 +19,7 @@ Lifetime of the `T` inside `_storage` is manually controlled with placement-`new
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`:
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 recognized by `optional` as candidate for optimized storage, by specializing type trait `boost::optional_config::optional_uses_direct_storage_for`:
struct X // not trivial
{
@ -86,7 +86,7 @@ Which gives us the following layout (and smaller total size):
[$images/opt_align3.png]
Sometimes it requires detailed consideration what data we make optional. In our case above, if we determine that both minimum and maximum value can be provided or not provided together, but one is never provided without the other, we can make only one optional memebr:
Sometimes it requires detailed consideration what data we make optional. In our case above, if we determine that both minimum and maximum value can be provided or not provided together, but one is never provided without the other, we can make only one optional member:
struct Limits
{

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.
* [*Requires:] `T` is __STD_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.
* [*Returns:] `out`.
[endsect]

View File

@ -73,6 +73,16 @@
} // 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]
@ -92,7 +102,7 @@
}
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.
Classes `in_place_init_t` and `in_place_init_if_t` are empty classes. Their purpose is to control overload resolution in the initialization of optional objects.
They are empty, trivially copyable classes with disabled default constructor.
[endsect]
@ -218,7 +228,7 @@ They are empty, trivially copyable classes with disabled default constructor.
[#reference_operator_template_spec]
template <class T>
class optional<T&> // specilization for lvalue references
class optional<T&> // specialization for lvalue references
{
public :

View File

@ -163,7 +163,7 @@ assert (!uninit);
optional<std::unique_ptr<T>> uinit2 ( std::move(uninit) ) ;
assert ( uninit2 == uninit );
optional<std::unique_ptr<T>> init( std::uniqye_ptr<T>(new T(2)) );
optional<std::unique_ptr<T>> init( std::unique_ptr<T>(new T(2)) );
assert ( **init == T(2) ) ;
optional<std::unique_ptr<T>> init2 ( std::move(init) ) ;
@ -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 support 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 support variadic templates or rvalue references, this constuctor is available in limited functionality. For details [link optional_emplace_workaround see here].
* [*Example:]
``
@ -502,7 +502,7 @@ __SPACE__
* [*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 support variadic templates or rvalue references, this function is available in limited functionality. For details [link optional_emplace_workaround see here].
* [*Example:]
``
T v;
@ -875,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 support binding to const lvalues of integral types. For more details [link optional_reference_binding see here].
* [*Example:]
``
T v;
@ -1136,21 +1136,21 @@ __SPACE__
[#reference_optional_ref_reset_value]
[: `template<class R> void optional<T&>::reset ( R&& r) noexcept;`]
* [*Effects:] Equivalent to `*this = std::forward<R>(r)`.
* [*Remarks:] This function is depprecated.
* [*Remarks:] This function is deprecated.
__SPACE__
[#reference_optional_ref_is_initialized]
[: `bool optional<T&>::is_initialized() const noexcept;`]
* [*Effects:] Equivalent to `return bool(*this)`.
* [*Remarks:] This function is depprecated.
* [*Remarks:] This function is deprecated.
__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);`.
* [*Remarks:] This function is depprecated.
* [*Remarks:] This function is deprecated.
[endsect]
@ -1216,7 +1216,7 @@ __SPACE__
[: `bool operator == ( optional<T> const& x, optional<T> const& y );`]
* [*Requires:] `T` shall meet requirements of __SGI_EQUALITY_COMPARABLE__.
* [*Requires:] `T` shall meet requirements of __STD_EQUALITY_COMPARABLE__.
* [*Returns:] If both `x` and `y` are initialized, `(*x == *y)`. If only
`x` or `y` is initialized, `false`. If both are uninitialized, `true`.
* [*Notes:] This definition guarantees that `optional<T>` not containing a value is compared unequal to any `optional<T>` containing any value, and equal to any other `optional<T>` not containing a value.
@ -1249,7 +1249,7 @@ __SPACE__
* [*Returns:] `(!y) ? false : (!x) ? true : *x < *y`.
* [*Notes:] This definition guarantees that `optional<T>` not containing a value is ordered as less than any `optional<T>` containing any value, and equivalent to any other `optional<T>` not containing a value.
Pointers have shallow relational operators while `optional` has deep relational operators. Do not use `operator<` directly in generic code
which expect to be given either an `optional<T>` or a pointer; use __FUNCTION_LESS_POINTEES__ instead. `T` need not be __SGI_LESS_THAN_COMPARABLE__. Only single `operator<` is required. Other relational operations are defined in terms of this one. If `T`'s `operator<` satisfies the axioms of __SGI_LESS_THAN_COMPARABLE__ (transitivity, antisymmetry and irreflexivity), `optinal<T>` is __SGI_LESS_THAN_COMPARABLE__.
which expect to be given either an `optional<T>` or a pointer; use __FUNCTION_LESS_POINTEES__ instead. `T` need not be __STD_LESS_THAN_COMPARABLE__. Only single `operator<` is required. Other relational operations are defined in terms of this one. If `T`'s `operator<` satisfies the axioms of __STD_LESS_THAN_COMPARABLE__ (transitivity, antisymmetry and irreflexivity), `optional<T>` is __STD_LESS_THAN_COMPARABLE__.
* [*Example:]
``
optional<T> oN, oN_;
@ -1310,7 +1310,7 @@ __SPACE__
[: `bool operator == ( none_t, optional<T> const& x ) noexcept;`]
* [*Returns:] `!x`.
* [*Notes:] `T` need not meet requirements of __SGI_EQUALITY_COMPARABLE__.
* [*Notes:] `T` need not meet requirements of __STD_EQUALITY_COMPARABLE__.
__SPACE__
@ -1386,7 +1386,7 @@ __SPACE__
[#reference_swap_optional_reference]
[: `void swap ( optional<T&>& x, optional<T&>& y ) noexcept ;`]
* [*Postconditions:] `x` refers to what `y` refererred to before the swap (if anything). `y` refers to whatever `x` referred to before the swap.
* [*Postconditions:] `x` refers to what `y` referred to before the swap (if anything). `y` refers to whatever `x` referred to before the swap.
* [*Example:]
``
@ -1408,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

@ -46,7 +46,7 @@ On compilers that do not support variadic templates, each of these functions is
template<class Arg> void emplace(Arg&& arg);
void emplace();
On compilers that do not support rvalue references, each of these functions is substituted with three overloadss: taking `const` and non-`const` lvalue reference, and third forwarding zero arguments. This forms the following set:
On compilers that do not support rvalue references, each of these functions is substituted with three overloads: taking `const` and non-`const` lvalue reference, and third forwarding zero arguments. This forms the following set:
template<class Arg> optional(in_place_init_t, const Arg& arg);
template<class Arg> optional(in_place_init_t, Arg& arg);
@ -60,12 +60,12 @@ On compilers that do not support rvalue references, each of these functions is s
template<class Arg> void emplace(Arg& arg);
void emplace();
This workaround addressess about 40% of all use cases. If this is insufficient, you need to resort to using [link boost_optional.tutorial.in_place_factories In-Place Factories].
This workaround addresses about 40% of all use cases. If this is insufficient, you need to resort to using [link boost_optional.tutorial.in_place_factories In-Place Factories].
[endsect]
[section Optional Reference Binding][#optional_reference_binding]
A number of compilers incorrectly treat const lvalues of integral type as rvalues, and create an illegal temporary when binding to an lvalue reference to const in some expressions. This could result in creating an optional lvalue reference that is in fact bound to an unexpected temporary rather than to the intended object. In order to prevent hard to find run-time bugs, this library performs compile-time checks to prevent expressions that would otherwise bind an optional reference to an unexpected temporary. As a consequence, on certain compilers certain pieces of functionality in optional references are missing. In order to maintain a portability of your code across diferent compilers, it is recommended that you only stick to the minimum portable interface of optional references: prefer direct-initialization and copy assignment of optional references to copy-initialization and assignment from `T&`:
A number of compilers incorrectly treat const lvalues of integral type as rvalues, and create an illegal temporary when binding to an lvalue reference to const in some expressions. This could result in creating an optional lvalue reference that is in fact bound to an unexpected temporary rather than to the intended object. In order to prevent hard to find run-time bugs, this library performs compile-time checks to prevent expressions that would otherwise bind an optional reference to an unexpected temporary. As a consequence, on certain compilers certain pieces of functionality in optional references are missing. In order to maintain a portability of your code across different compilers, it is recommended that you only stick to the minimum portable interface of optional references: prefer direct-initialization and copy assignment of optional references to copy-initialization and assignment from `T&`:
const int i = 0;
optional<const int&> or1;

View File

@ -1,7 +1,7 @@
[/
Boost.Optional
Copyright (c) 2015 - 2018 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,26 @@
[section:relnotes Release Notes]
[heading Boost Release 1.83]
* Deprecated support for C++03 and earlier, C++11 will be required in release 1.86.
[heading Boost Release 1.80]
* [*Breaking change:] Added specializations for `std::hash<boost::optional<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].
* Fixed [@https://github.com/boostorg/optional/issues/92 issue #92].
* Added support for `BOOST_NO_IOSTREAM`.
* Now aligned storage uses `unsigned char` rather than `char` to avoid UB.
* Now using cv-unqualified `value_type` with placement `new` to avoid UB.
[heading Boost Release 1.76]
* Fixed MSVC warning C4702.
[heading Boost Release 1.75]
* `boost::none` is `constexpr`-declared.
@ -22,7 +42,7 @@
* Fixed [@https://github.com/boostorg/optional/issues/78 issue #78].
* `boost::none` is now declared as an inline variable (on compilers that 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`.
* Now suppressing warning `-Wweak-vtables`.
[heading Boost Release 1.69]
@ -34,7 +54,7 @@
* 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>`.
* Added member function `flat_map()` for transforming `optional<T>` into `optional<U>` using a function of type `T -> optional<U>`.
[heading Boost Release 1.67]
@ -66,7 +86,7 @@
* the `sizeof` of optional reference is that of a pointer,
* some bugs connected to copying optional references are gone,
* all run-time bugs caused by incorrect reference binding on some compilers are now turned into compile-time errors,
* you can swap optional references: it is like swapping pointers: shalow, underlying objects are not affected,
* you can swap optional references: it is like swapping pointers: shallow, underlying objects are not affected,
* optional references to abstract types work.
* Documented nested typedefs ([@https://svn.boost.org/trac/boost/ticket/5193 Trac #5193]).
* Made the perfect-forwarding constructor SFINAE-friendly, which fixes [@https://svn.boost.org/trac/boost/ticket/12002 Trac #12002]. However, this only works in the newer platforms that correctly implement C++11 `<type_traits>`.

View File

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -52,7 +52,7 @@
</pre>
<p>
On compilers that do not support rvalue references, each of these functions
is substituted with three overloadss: taking <code class="computeroutput"><span class="keyword">const</span></code>
is substituted with three overloads: taking <code class="computeroutput"><span class="keyword">const</span></code>
and non-<code class="computeroutput"><span class="keyword">const</span></code> lvalue reference,
and third forwarding zero arguments. This forms the following set:
</p>
@ -69,14 +69,14 @@
<span class="keyword">void</span> <span class="identifier">emplace</span><span class="special">();</span>
</pre>
<p>
This workaround addressess about 40% of all use cases. If this is insufficient,
This workaround addresses about 40% of all use cases. If this is insufficient,
you need to resort to using <a class="link" href="../tutorial/in_place_factories.html" title="In-Place Factories">In-Place
Factories</a>.
</p>
</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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -37,7 +37,7 @@
prevent expressions that would otherwise bind an optional reference to an
unexpected temporary. As a consequence, on certain compilers certain pieces
of functionality in optional references are missing. In order to maintain
a portability of your code across diferent compilers, it is recommended that
a portability of your code across different compilers, it is recommended that
you only stick to the minimum portable interface of optional references:
prefer direct-initialization and copy assignment of optional references to
copy-initialization and assignment from <code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code>:
@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -422,7 +422,7 @@
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">uinit2</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">uninit</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">uninit2</span> <span class="special">==</span> <span class="identifier">uninit</span> <span class="special">);</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">uniqye_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="keyword">new</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</span><span class="special">))</span> <span class="special">);</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="keyword">new</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</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">init</span> <span class="special">==</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init2</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">init</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>

View File

@ -293,8 +293,8 @@
</p>
<h5>
<a name="boost_optional.development.the_interface.h0"></a>
<span class="phrase"><a name="boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_"></a></span><a class="link" href="development.html#boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_">Lexically-hinted
Value Access in the presence of possibly untitialized optional objects: The
<span class="phrase"><a name="boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_uninitialized_optional_objects__the_operators___and___gt_"></a></span><a class="link" href="development.html#boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_uninitialized_optional_objects__the_operators___and___gt_">Lexically-hinted
Value Access in the presence of possibly uninitialized optional objects: The
operators * and -&gt;</a>
</h5>
<p>

View File

@ -148,7 +148,7 @@
move constructor are replaced with the calls to <code class="computeroutput"><span class="identifier">T</span></code>'s
default constructor followed by <code class="computeroutput"><span class="identifier">swap</span></code>.
(This is more useful on older compilers that do not support move semantics,
when one wants to acheive stronger exception safety guarantees.) In this case
when one wants to achieve stronger exception safety guarantees.) In this case
the exception safety guarantees for <code class="computeroutput"><span class="identifier">swap</span></code>
are reliant on the guarantees of <code class="computeroutput"><span class="identifier">T</span></code>'s
<code class="computeroutput"><span class="identifier">swap</span></code> and default constructor

View File

@ -55,7 +55,7 @@
<p>
Also, even though <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code>
treats it wrapped pseudo-object much as a real value, a true real reference
is stored so aliasing will ocurr:
is stored so aliasing will occur:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">

View File

@ -100,7 +100,7 @@
<span class="special">}</span>
</pre>
<p>
This version throws an exception upon an attempt to access a non-existent
This version throws an exception upon an attempt to access a nonexistent
contained value. If your way of dealing with the missing value is to use
some default, like <code class="computeroutput"><span class="number">0</span></code>, there exists
a yet another alternative:
@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -44,7 +44,7 @@
</pre>
<p>
The default constructor of <code class="computeroutput"><span class="identifier">optional</span></code>
creates an unitialized optional object. Unlike with <code class="computeroutput"><span class="keyword">int</span></code>s
creates an uninitialized optional object. Unlike with <code class="computeroutput"><span class="keyword">int</span></code>s
you cannot have an <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span></code>
in an indeterminate state. Its state is always well defined. Instruction
<code class="computeroutput"><span class="identifier">ans</span> <span class="special">=</span>
@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -37,7 +37,7 @@
is possible. A natural signature for this function can be:
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">optional</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">optionl</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">convert</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">text</span><span class="special">);</span>
<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">convert</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">text</span><span class="special">);</span>
</pre>
<p>
All necessary functionality can be included with one header <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">optional</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>.
@ -49,7 +49,7 @@
can use our function:
</p>
<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">text</span> <span class="special">=</span> <span class="comment">/*... */</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">optionl</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">oi</span> <span class="special">=</span> <span class="identifier">convert</span><span class="special">(</span><span class="identifier">text</span><span class="special">);</span> <span class="comment">// move-construct</span>
<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">oi</span> <span class="special">=</span> <span class="identifier">convert</span><span class="special">(</span><span class="identifier">text</span><span class="special">);</span> <span class="comment">// move-construct</span>
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">oi</span><span class="special">)</span> <span class="comment">// contextual conversion to bool</span>
<span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="special">*</span><span class="identifier">oi</span><span class="special">;</span> <span class="comment">// operator*</span>
</pre>
@ -58,7 +58,7 @@
contains a value, we use the contextual conversion to type <code class="computeroutput"><span class="keyword">bool</span></code>. Because of this we can combine the initialization
of the optional object and the test into one instruction:
</p>
<pre class="programlisting"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optionl</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">oi</span> <span class="special">=</span> <span class="identifier">convert</span><span class="special">(</span><span class="identifier">text</span><span class="special">))</span>
<pre class="programlisting"><span class="keyword">if</span> <span class="special">(</span><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">oi</span> <span class="special">=</span> <span class="identifier">convert</span><span class="special">(</span><span class="identifier">text</span><span class="special">))</span>
<span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="special">*</span><span class="identifier">oi</span><span class="special">;</span>
</pre>
<p>
@ -84,7 +84,7 @@
<span class="special">}</span>
</pre>
<p>
This version throws an exception upon an attempt to access a non-existent
This version throws an exception upon an attempt to access a nonexistent
contained value. If your way of dealing with the missing value is to use
some default, like <code class="computeroutput"><span class="number">0</span></code>, there exists
a yet another alternative:
@ -98,7 +98,7 @@
Now, let's consider how function <code class="computeroutput"><span class="identifier">convert</span></code>
can be implemented.
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optionl</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">convert</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">text</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">convert</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">text</span><span class="special">)</span>
<span class="special">{</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">stringstream</span> <span class="identifier">s</span><span class="special">(</span><span class="identifier">text</span><span class="special">);</span>
<span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span>

View File

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -433,7 +433,7 @@
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">uinit2</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">uninit</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">uninit2</span> <span class="special">==</span> <span class="identifier">uninit</span> <span class="special">);</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">uniqye_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="keyword">new</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</span><span class="special">))</span> <span class="special">);</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="keyword">new</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</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">init</span> <span class="special">==</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init2</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">init</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
@ -2129,7 +2129,7 @@
is required. Other relational operations are defined in terms of this
one. If <code class="computeroutput"><span class="identifier">T</span></code>'s <code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;</span></code>
satisfies the axioms of <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a> (transitivity,
antisymmetry and irreflexivity), <code class="computeroutput"><span class="identifier">optinal</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> is <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a>.
antisymmetry and irreflexivity), <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 <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a>.
</li>
<li class="listitem">
<span class="bold"><strong>Example:</strong></span>
@ -2380,7 +2380,7 @@
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Postconditions:</strong></span> <code class="computeroutput"><span class="identifier">x</span></code>
refers to what <code class="computeroutput"><span class="identifier">y</span></code> refererred
refers to what <code class="computeroutput"><span class="identifier">y</span></code> referred
to before the swap (if anything). <code class="computeroutput"><span class="identifier">y</span></code>
refers to whatever <code class="computeroutput"><span class="identifier">x</span></code>
referred to before the swap.

View File

@ -153,7 +153,7 @@
is required. Other relational operations are defined in terms of this
one. If <code class="computeroutput"><span class="identifier">T</span></code>'s <code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;</span></code>
satisfies the axioms of <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a> (transitivity,
antisymmetry and irreflexivity), <code class="computeroutput"><span class="identifier">optinal</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> is <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a>.
antisymmetry and irreflexivity), <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 <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a>.
</li>
<li class="listitem">
<span class="bold"><strong>Example:</strong></span>
@ -404,7 +404,7 @@
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Postconditions:</strong></span> <code class="computeroutput"><span class="identifier">x</span></code>
refers to what <code class="computeroutput"><span class="identifier">y</span></code> refererred
refers to what <code class="computeroutput"><span class="identifier">y</span></code> referred
to before the swap (if anything). <code class="computeroutput"><span class="identifier">y</span></code>
refers to whatever <code class="computeroutput"><span class="identifier">x</span></code>
referred to before the swap.

View File

@ -403,7 +403,7 @@
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">uinit2</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">uninit</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">uninit2</span> <span class="special">==</span> <span class="identifier">uninit</span> <span class="special">);</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">uniqye_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="keyword">new</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</span><span class="special">))</span> <span class="special">);</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="keyword">new</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</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">init</span> <span class="special">==</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init2</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">init</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>

View File

@ -179,7 +179,7 @@
is required. Other relational operations are defined in terms of this
one. If <code class="computeroutput"><span class="identifier">T</span></code>'s <code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;</span></code>
satisfies the axioms of <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a> (transitivity,
antisymmetry and irreflexivity), <code class="computeroutput"><span class="identifier">optinal</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> is <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a>.
antisymmetry and irreflexivity), <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 <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a>.
</li>
<li class="listitem">
<span class="bold"><strong>Example:</strong></span>
@ -479,7 +479,7 @@
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<span class="bold"><strong>Postconditions:</strong></span> <code class="computeroutput"><span class="identifier">x</span></code>
refers to what <code class="computeroutput"><span class="identifier">y</span></code> refererred
refers to what <code class="computeroutput"><span class="identifier">y</span></code> referred
to before the swap (if anything). <code class="computeroutput"><span class="identifier">y</span></code>
refers to whatever <code class="computeroutput"><span class="identifier">x</span></code>
referred to before the swap.
@ -507,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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -58,7 +58,7 @@
<li class="listitem">
<span class="bold"><strong>Notes:</strong></span> This constructor is declared
<code class="computeroutput"><span class="keyword">explicit</span></code> on compilers
that do not correctly suport binding to const lvalues of integral types.
that do not correctly support binding to const lvalues of integral types.
For more details <a class="link" href="../../dependencies_and_portability/optional_reference_binding.html#optional_reference_binding">see here</a>.
</li>
<li class="listitem">
@ -502,7 +502,7 @@
<span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">forward</span><span class="special">&lt;</span><span class="identifier">R</span><span class="special">&gt;(</span><span class="identifier">r</span><span class="special">)</span></code>.
</li>
<li class="listitem">
<span class="bold"><strong>Remarks:</strong></span> This function is depprecated.
<span class="bold"><strong>Remarks:</strong></span> This function is deprecated.
</li>
</ul></div>
<p>
@ -516,7 +516,7 @@
<span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><span class="keyword">return</span> <span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span></code>.
</li>
<li class="listitem">
<span class="bold"><strong>Remarks:</strong></span> This function is depprecated.
<span class="bold"><strong>Remarks:</strong></span> This function is deprecated.
</li>
</ul></div>
<p>
@ -532,13 +532,13 @@
<span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><span class="keyword">return</span> <span class="identifier">value_or</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">forward</span><span class="special">&lt;</span><span class="identifier">R</span><span class="special">&gt;(</span><span class="identifier">r</span><span class="special">);</span></code>.
</li>
<li class="listitem">
<span class="bold"><strong>Remarks:</strong></span> This function is depprecated.
<span class="bold"><strong>Remarks:</strong></span> This function is deprecated.
</li>
</ul></div>
</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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -301,7 +301,7 @@
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">uinit2</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">uninit</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">uninit2</span> <span class="special">==</span> <span class="identifier">uninit</span> <span class="special">);</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">uniqye_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="keyword">new</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</span><span class="special">))</span> <span class="special">);</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="keyword">new</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</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">init</span> <span class="special">==</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&gt;</span> <span class="identifier">init2</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">init</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
@ -429,7 +429,7 @@
<li class="listitem">
<span class="bold"><strong>Notes: </strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
need not be <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>.
On compilers that do not suppor variadic templates or rvalue references,
On compilers that do not support variadic templates or rvalue references,
this constuctor is available in limited functionality. For details
<a class="link" href="../../dependencies_and_portability/emplace_operations_in_older_compilers.html#optional_emplace_workaround">see here</a>.
</li>
@ -476,7 +476,7 @@
<li class="listitem">
<span class="bold"><strong>Notes: </strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
need not be <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>.
On compilers that do not suppor variadic templates or rvalue references,
On compilers that do not support variadic templates or rvalue references,
this constuctor is available in limited functionality. For details
<a class="link" href="../../dependencies_and_portability/emplace_operations_in_older_compilers.html#optional_emplace_workaround">see here</a>.
</li>
@ -1125,7 +1125,7 @@
<span class="bold"><strong>Notes:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
need not be <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>
or <code class="computeroutput"><span class="identifier">MoveAssignable</span></code>.
On compilers that do not suppor variadic templates or rvalue references,
On compilers that do not support variadic templates or rvalue references,
this function is available in limited functionality. For details <a class="link" href="../../dependencies_and_portability/emplace_operations_in_older_compilers.html#optional_emplace_workaround">see here</a>.
</li>
<li class="listitem">
@ -1774,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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -40,14 +40,14 @@
<p>
Classes <code class="computeroutput"><span class="identifier">in_place_init_t</span></code>
and <code class="computeroutput"><span class="identifier">in_place_init_if_t</span></code>
are empty clsses. Their purpose is to control overload resolution in the
are empty classes. Their purpose is to control overload resolution in the
initialization of optional objects. They are empty, trivially copyable
classes with disabled default constructor.
</p>
</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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -28,7 +28,7 @@
References</a>
</h4></div></div></div>
<a name="reference_operator_template_spec"></a><pre class="programlisting"><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">class</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span> <span class="comment">// specilization for lvalue references</span>
<span class="keyword">class</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span> <span class="comment">// specialization for lvalue references</span>
<span class="special">{</span>
<span class="keyword">public</span> <span class="special">:</span>
@ -104,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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -28,6 +28,42 @@
</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>
<li class="listitem">
Fixed <a href="https://github.com/boostorg/optional/issues/92" target="_top">issue
#92</a>.
</li>
<li class="listitem">
Added support for <code class="computeroutput"><span class="identifier">BOOST_NO_IOSTREAM</span></code>.
</li>
<li class="listitem">
Now aligned storage uses <code class="computeroutput"><span class="keyword">unsigned</span>
<span class="keyword">char</span></code> rather than <code class="computeroutput"><span class="keyword">char</span></code>
to avoid UB.
</li>
<li class="listitem">
Now using cv-unqualified <code class="computeroutput"><span class="identifier">value_type</span></code>
with placement <code class="computeroutput"><span class="keyword">new</span></code> to avoid
UB.
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h1"></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.h2"></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>
@ -41,7 +77,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h1"></a>
<a name="boost_optional.relnotes.h3"></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>
@ -60,11 +96,11 @@
#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>.
Now suppressing 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.h2"></a>
<a name="boost_optional.relnotes.h4"></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>
@ -82,7 +118,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h3"></a>
<a name="boost_optional.relnotes.h5"></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>
@ -95,11 +131,11 @@
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>.
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">optional</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.h4"></a>
<a name="boost_optional.relnotes.h6"></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>
@ -113,7 +149,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h5"></a>
<a name="boost_optional.relnotes.h7"></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>
@ -131,7 +167,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h6"></a>
<a name="boost_optional.relnotes.h8"></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>
@ -155,7 +191,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h7"></a>
<a name="boost_optional.relnotes.h9"></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>
@ -163,7 +199,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.h8"></a>
<a name="boost_optional.relnotes.h10"></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>
@ -184,7 +220,7 @@
are now turned into compile-time errors,
</li>
<li class="listitem">
you can swap optional references: it is like swapping pointers: shalow,
you can swap optional references: it is like swapping pointers: shallow,
underlying objects are not affected,
</li>
<li class="listitem">
@ -206,7 +242,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h9"></a>
<a name="boost_optional.relnotes.h11"></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>
@ -217,7 +253,7 @@
#11203</a>.
</li></ul></div>
<h4>
<a name="boost_optional.relnotes.h10"></a>
<a name="boost_optional.relnotes.h12"></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>
@ -231,7 +267,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h11"></a>
<a name="boost_optional.relnotes.h13"></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>
@ -267,7 +303,7 @@
</li>
</ul></div>
<h4>
<a name="boost_optional.relnotes.h12"></a>
<a name="boost_optional.relnotes.h14"></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>
@ -277,7 +313,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.h13"></a>
<a name="boost_optional.relnotes.h15"></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>
@ -334,7 +370,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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -398,8 +398,8 @@
</p>
<h6>
<a name="boost_optional.tutorial.design_overview.the_interface.h0"></a>
<span class="phrase"><a name="boost_optional.tutorial.design_overview.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_"></a></span><a class="link" href="tutorial.html#boost_optional.tutorial.design_overview.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_">Lexically-hinted
Value Access in the presence of possibly untitialized optional objects:
<span class="phrase"><a name="boost_optional.tutorial.design_overview.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_uninitialized_optional_objects__the_operators___and___gt_"></a></span><a class="link" href="tutorial.html#boost_optional.tutorial.design_overview.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_uninitialized_optional_objects__the_operators___and___gt_">Lexically-hinted
Value Access in the presence of possibly uninitialized optional objects:
The operators * and -&gt;</a>
</h6>
<p>

View File

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -153,7 +153,7 @@
move constructor are replaced with the calls to <code class="computeroutput"><span class="identifier">T</span></code>'s
default constructor followed by <code class="computeroutput"><span class="identifier">swap</span></code>.
(This is more useful on older compilers that do not support move semantics,
when one wants to acheive stronger exception safety guarantees.) In this
when one wants to achieve stronger exception safety guarantees.) In this
case the exception safety guarantees for <code class="computeroutput"><span class="identifier">swap</span></code>
are reliant on the guarantees of <code class="computeroutput"><span class="identifier">T</span></code>'s
<code class="computeroutput"><span class="identifier">swap</span></code> and default constructor
@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -29,7 +29,7 @@
</h4></div></div></div>
<p>
Sometimes on GCC compilers below version 5.1 you may get an -Wmaybe-uninitialized
warning when copiling with option -02 on a perfectly valid <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span></code> usage. For instance in this
warning when compiling with option -02 on a perfectly valid <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span></code> usage. For instance in this
program:
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">optional</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -30,7 +30,7 @@
<p>
Because <code class="computeroutput"><span class="identifier">T</span></code> is convertible
to <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>
and because <code class="computeroutput"><span class="identifier">opiotnal</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>
and because <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 <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a> when <code class="computeroutput"><span class="identifier">T</span></code> is <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top"><code class="computeroutput"><span class="identifier">LessThanComparable</span></code></a>, you can sometimes
get an unexpected runtime result where you would rather expect a compiler
error:
@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -42,14 +42,14 @@
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
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">opiotnal</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>
<code class="computeroutput"><span class="identifier">boost</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></code>
to be trivially copyable when <code class="computeroutput"><span class="identifier">T</span></code>
is trivial.
</p>
</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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -59,7 +59,7 @@
<p>
Also, even though <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> treats it wrapped pseudo-object
much as a real value, a true real reference is stored so aliasing will
ocurr:
occur:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -60,9 +60,9 @@
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
leave the programmer a way of customizing her type, so that it is recognized
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>:
for optimized storage, by specializing type trait <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional_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>
@ -165,7 +165,7 @@
Sometimes it requires detailed consideration what data we make optional.
In our case above, if we determine that both minimum and maximum value can
be provided or not provided together, but one is never provided without the
other, we can make only one optional memebr:
other, we can make only one optional member:
</p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">Limits</span>
<span class="special">{</span>
@ -251,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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -51,7 +51,7 @@
of the mixed comparison between <code class="computeroutput"><span class="identifier">T</span></code>
and <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> as
well as between <code class="computeroutput"><span class="identifier">none_t</span></code> and
<code class="computeroutput"><span class="identifier">optionl</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>:
<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>:
</p>
<pre class="programlisting"><span class="identifier">assert</span><span class="special">(</span><span class="identifier">oN</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">o1</span> <span class="special">!=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span><span class="special">);</span>
@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -26,7 +26,7 @@
<span class="firstname">Fernando Luis</span> <span class="surname">Cacciola Carballal</span>
</h3></div></div>
<div><p class="copyright">Copyright © 2003-2007 Fernando Luis Cacciola Carballal</p></div>
<div><p class="copyright">Copyright © 2014-2018 Andrzej Krzemieński</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
@ -114,7 +114,7 @@
<span class="phrase"><a name="optional.introduction.problem"></a></span><a class="link" href="index.html#optional.introduction.problem">Problem</a>
</h4>
<p>
Suppose we want to read a parameter form a config file which represents some
Suppose we want to read a parameter from a config file which represents some
integral value, let's call it <code class="computeroutput"><span class="string">"MaxValue"</span></code>.
It is possible that this parameter is not specified; such situation is no error.
It is valid to not specify the parameter and in that case the program is supposed
@ -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: October 28, 2020 at 21:28:19 GMT</small></p></td>
<td align="left"><p><small>Last revised: March 26, 2022 at 22:47:53 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -97,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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -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 © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2018 Andrzej Krzemień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

@ -14,6 +14,14 @@
#define BOOST_NONE_T_17SEP2003_HPP
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if defined (BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_REF_QUALIFIERS) \
|| defined(BOOST_NO_CXX11_LAMBDAS) || defined(BOOST_NO_CXX11_DECLTYPE_N3276) || defined(BOOST_NO_CXX11_NOEXCEPT) || defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || defined(BOOST_NO_CXX11_DEFAULTED_MOVES) || defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
BOOST_PRAGMA_MESSAGE("C++03 support is deprecated in Boost.Optional 1.83 and will be removed in Boost.Optional 1.86.")
#endif
namespace boost {

View File

@ -17,6 +17,7 @@
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/core/invoke_swap.hpp>
namespace boost {
@ -336,7 +337,7 @@ class optional_base : public optional_tag
// No-throw (assuming T::~T() doesn't)
void reset() BOOST_NOEXCEPT { destroy(); }
// **DEPPRECATED** Replaces the current value -if any- with 'val'
// **DEPRECATED** Replaces the current value -if any- with 'val'
void reset ( argument_type val ) { assign(val); }
// Returns a pointer to the value if this is initialized, otherwise,
@ -542,7 +543,7 @@ class optional_base : public optional_tag
// 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
// For VC<=70 compilers this workaround doesn't work because the compiler issues and error
// instead of choosing the wrong overload
//
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
@ -629,7 +630,7 @@ class optional_base : public optional_tag
// If T is of reference type, trying to get a pointer to the held value must result in a compile-time error.
// Decent compilers should disallow conversions from reference_content<T>* to T*, but just in case,
// the following olverloads are used to filter out the case and guarantee an error in case of T being a reference.
// the following overloads are used to filter out the case and guarantee an error in case of T being a reference.
pointer_const_type cast_ptr( internal_type const* p, is_not_reference_tag ) const { return p ; }
pointer_type cast_ptr( internal_type * p, is_not_reference_tag ) { return p ; }
pointer_const_type cast_ptr( internal_type const* p, is_reference_tag ) const { return &p->get() ; }
@ -894,7 +895,7 @@ class optional : public optional_detail::optional_base<T>
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);
boost::core::invoke_swap(*this, arg);
}

View File

@ -28,7 +28,7 @@ class aligned_storage
// 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_ ;

View File

@ -53,7 +53,7 @@
#endif
#if (defined(_MSC_VER) && _MSC_VER <= 1800)
// on MSCV 2013 and earlier an unwanted temporary is created when you assign from
// on MSVC 2013 and earlier an unwanted temporary is created when you assign from
// a const lvalue of integral type. Thus we bind not to the original address but
// to a temporary.
# define BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
@ -114,9 +114,9 @@
#endif
// Detect suport for defaulting move operations
// Detect support for defaulting move operations
// (some older compilers implement rvalue references,
// defaulted funcitons but move operations are not special members and cannot be defaulted)
// defaulted functions 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

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

@ -66,7 +66,7 @@ void prevent_assignment_from_false_const_integral()
{
#ifndef BOOST_OPTIONAL_CONFIG_ALLOW_BINDING_TO_RVALUES
#ifdef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
// MSVC compiler without rvalue refernces: we need to disable the asignment from
// MSVC compiler without rvalue references: we need to disable the assignment from
// const integral lvalue reference, as it may be an invalid temporary
BOOST_STATIC_ASSERT_MSG(!is_const_integral<From>::value,
"binding const lvalue references to integral types is disabled in this compiler");
@ -130,7 +130,7 @@ public:
explicit optional(const optional<U&>& rhs) BOOST_NOEXCEPT : ptr_(rhs.get_ptr()) {}
optional(const optional& rhs) BOOST_NOEXCEPT : ptr_(rhs.get_ptr()) {}
// the following two implement a 'conditionally explicit' constructor: condition is a hack for buggy compilers with srewed conversion construction from const int
// the following two implement a 'conditionally explicit' constructor: condition is a hack for buggy compilers with screwed 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, bool>::type = true) BOOST_NOEXCEPT
: ptr_(boost::addressof(rhs)) {}
@ -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()

View File

@ -16,7 +16,7 @@
namespace boost {
// optional's relational operators ( ==, !=, <, >, <=, >= ) have deep-semantics (compare values).
// WARNING: This is UNLIKE pointers. Use equal_pointees()/less_pointess() in generic code instead.
// WARNING: This is UNLIKE pointers. Use equal_pointees()/less_pointees() in generic code instead.
//

View File

@ -13,7 +13,7 @@
#ifndef BOOST_OPTIONAL_DETAIL_OPTIONAL_SWAP_AJK_28JAN2015_HPP
#define BOOST_OPTIONAL_DETAIL_OPTIONAL_SWAP_AJK_28JAN2015_HPP
#include <boost/core/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/optional/optional_fwd.hpp>
namespace boost {
@ -39,8 +39,8 @@ struct swap_selector<true>
else if ( !hasY )
y.emplace();
// Boost.Utility.Swap will take care of ADL and workarounds for broken compilers
boost::swap(x.get(), y.get());
// Boost.Core.Swap will take care of ADL and workarounds for broken compilers
boost::core::invoke_swap(x.get(), y.get());
if( !hasX )
y = boost::none ;
@ -64,13 +64,13 @@ struct swap_selector<false>
{
template <class T>
static void optional_swap ( optional<T>& x, optional<T>& y )
//BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::swap(*x, *y)))
//BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::core::invoke_swap(*x, *y)))
{
if (x)
{
if (y)
{
boost::swap(*x, *y);
boost::core::invoke_swap(*x, *y);
}
else
{
@ -105,7 +105,7 @@ struct optional_swap_should_use_default_constructor : has_nothrow_default_constr
template <class T>
inline void swap ( optional<T>& x, optional<T>& y )
//BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::swap(*x, *y)))
//BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::core::invoke_swap(*x, *y)))
{
optional_detail::swap_selector<optional_swap_should_use_default_constructor<T>::value>::optional_swap(x, y);
}

View File

@ -1,4 +1,15 @@
// trivilally-copyable version of the storage
// 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
// trivially-copyable version of the storage
template<class T>
class tc_optional_base : public optional_tag
@ -69,7 +80,7 @@ class tc_optional_base : public optional_tag
// ~tc_optional_base() = default;
// Assigns from another optional<T> (deep-copies the rhs value)
void assign ( tc_optional_base const& rhs )
void assign ( tc_optional_base const& rhs )
{
*this = rhs;
}
@ -84,7 +95,7 @@ class tc_optional_base : public optional_tag
#else
m_storage = static_cast<value_type>(rhs.get());
#endif
m_initialized = rhs.is_initialized();
}
@ -99,7 +110,7 @@ class tc_optional_base : public optional_tag
m_initialized = rhs.is_initialized();
}
#endif
void assign ( argument_type val )
{
construct(val);
@ -131,7 +142,7 @@ class tc_optional_base : public optional_tag
// No-throw (assuming T::~T() doesn't)
void reset() BOOST_NOEXCEPT { destroy(); }
// **DEPPRECATED** Replaces the current value -if any- with 'val'
// **DEPRECATED** 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,
@ -166,7 +177,7 @@ class tc_optional_base : public optional_tag
{
construct(in_place_init, boost::forward<Args>(args)...);
}
template<class... Args>
explicit tc_optional_base ( in_place_init_t, Args&&... args )
:
@ -174,7 +185,7 @@ class tc_optional_base : public optional_tag
{
construct(in_place_init, boost::forward<Args>(args)...);
}
template<class... Args>
explicit tc_optional_base ( in_place_init_if_t, bool cond, Args&&... args )
:
@ -190,24 +201,24 @@ class tc_optional_base : public optional_tag
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 )
:
@ -215,11 +226,11 @@ class tc_optional_base : public optional_tag
{
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 )
:
@ -228,7 +239,7 @@ class tc_optional_base : public optional_tag
if ( cond )
construct(in_place_init, boost::forward<Arg>(arg));
}
explicit tc_optional_base ( in_place_init_if_t, bool cond )
:
m_initialized(false)
@ -238,21 +249,21 @@ class tc_optional_base : public optional_tag
}
#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();
@ -264,18 +275,18 @@ class tc_optional_base : public optional_tag
{
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)
@ -289,13 +300,13 @@ class tc_optional_base : public optional_tag
{
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)
@ -303,15 +314,15 @@ class tc_optional_base : public optional_tag
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)
{
@ -444,7 +455,7 @@ class tc_optional_base : public optional_tag
// 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
// For VC<=70 compilers this workaround doesn't work because the compiler issues and error
// instead of choosing the wrong overload
//
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES

View File

@ -1,5 +1,5 @@
// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
// Copyright (C) 2014 - 2018 Andrzej Krzemienski.
// Copyright (C) 2014 - 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
@ -18,7 +18,9 @@
#define BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP
#include <new>
#ifndef BOOST_NO_IOSTREAM
#include <iosfwd>
#endif // BOOST_NO_IOSTREAM
#ifdef BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
# include <type_traits>
@ -28,21 +30,25 @@
#include <boost/core/addressof.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/core/explicit_operator_bool.hpp>
#include <boost/core/swap.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/optional/bad_optional_access.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#include <boost/type.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/conjunction.hpp>
#include <boost/type_traits/disjunction.hpp>
#include <boost/type_traits/has_nothrow_constructor.hpp>
#include <boost/type_traits/type_with_alignment.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/decay.hpp>
#include <boost/type_traits/is_assignable.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_constructible.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_lvalue_reference.hpp>
#include <boost/type_traits/is_nothrow_move_assignable.hpp>
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
@ -59,6 +65,7 @@
#include <boost/optional/detail/optional_config.hpp>
#include <boost/optional/detail/optional_factory_support.hpp>
#include <boost/optional/detail/optional_aligned_storage.hpp>
#include <boost/optional/detail/optional_hash.hpp>
namespace boost { namespace optional_detail {
@ -123,6 +130,7 @@ class optional_base : public optional_tag
protected :
typedef T value_type ;
typedef typename boost::remove_const<T>::type unqualified_value_type;
protected:
typedef T & reference_type ;
@ -384,7 +392,7 @@ class optional_base : public optional_tag
// No-throw (assuming T::~T() doesn't)
void reset() BOOST_NOEXCEPT { destroy(); }
// **DEPPRECATED** Replaces the current value -if any- with 'val'
// **DEPRECATED** Replaces the current value -if any- with 'val'
void reset ( argument_type val ) { assign(val); }
// Returns a pointer to the value if this is initialized, otherwise,
@ -399,14 +407,14 @@ class optional_base : public optional_tag
void construct ( argument_type val )
{
::new (m_storage.address()) value_type(val) ;
::new (m_storage.address()) unqualified_value_type(val) ;
m_initialized = true ;
}
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
void construct ( rval_reference_type val )
{
::new (m_storage.address()) value_type( boost::move(val) ) ;
::new (m_storage.address()) unqualified_value_type( boost::move(val) ) ;
m_initialized = true ;
}
#endif
@ -418,7 +426,7 @@ class optional_base : public optional_tag
template<class... Args>
void construct ( in_place_init_t, Args&&... args )
{
::new (m_storage.address()) value_type( boost::forward<Args>(args)... ) ;
::new (m_storage.address()) unqualified_value_type( boost::forward<Args>(args)... ) ;
m_initialized = true ;
}
@ -449,13 +457,13 @@ class optional_base : public optional_tag
template<class Arg>
void construct ( in_place_init_t, Arg&& arg )
{
::new (m_storage.address()) value_type( boost::forward<Arg>(arg) );
::new (m_storage.address()) unqualified_value_type( boost::forward<Arg>(arg) );
m_initialized = true ;
}
void construct ( in_place_init_t )
{
::new (m_storage.address()) value_type();
::new (m_storage.address()) unqualified_value_type();
m_initialized = true ;
}
@ -509,20 +517,20 @@ class optional_base : public optional_tag
template<class Arg>
void construct ( in_place_init_t, const Arg& arg )
{
::new (m_storage.address()) value_type( arg );
::new (m_storage.address()) unqualified_value_type( arg );
m_initialized = true ;
}
template<class Arg>
void construct ( in_place_init_t, Arg& arg )
{
::new (m_storage.address()) value_type( arg );
::new (m_storage.address()) unqualified_value_type( arg );
m_initialized = true ;
}
void construct ( in_place_init_t )
{
::new (m_storage.address()) value_type();
::new (m_storage.address()) unqualified_value_type();
m_initialized = true ;
}
@ -667,7 +675,7 @@ class optional_base : public optional_tag
template<class Expr>
void construct ( Expr&& expr, void const* )
{
new (m_storage.address()) value_type(boost::forward<Expr>(expr)) ;
new (m_storage.address()) unqualified_value_type(boost::forward<Expr>(expr)) ;
m_initialized = true ;
}
@ -688,7 +696,7 @@ class optional_base : public optional_tag
template<class Expr>
void construct ( Expr const& expr, void const* )
{
new (m_storage.address()) value_type(expr) ;
new (m_storage.address()) unqualified_value_type(expr) ;
m_initialized = true ;
}
@ -714,7 +722,7 @@ class optional_base : public optional_tag
// 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
// For VC<=70 compilers this workaround doesn't work because the compiler issues and error
// instead of choosing the wrong overload
//
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
@ -726,7 +734,7 @@ class optional_base : public optional_tag
{
// An exception can be thrown here.
// It it happens, THIS will be left uninitialized.
new (m_storage.address()) value_type(boost::move(expr.get())) ;
new (m_storage.address()) unqualified_value_type(boost::move(expr.get())) ;
m_initialized = true ;
}
}
@ -739,7 +747,7 @@ class optional_base : public optional_tag
{
// An exception can be thrown here.
// It it happens, THIS will be left uninitialized.
new (m_storage.address()) value_type(expr.get()) ;
new (m_storage.address()) unqualified_value_type(expr.get()) ;
m_initialized = true ;
}
}
@ -779,7 +787,7 @@ class optional_base : public optional_tag
// definition of metafunction is_optional_val_init_candidate
template <typename U>
struct is_optional_related
struct is_optional_or_tag
: boost::conditional< boost::is_base_of<optional_detail::optional_tag, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value
|| boost::is_same<BOOST_DEDUCED_TYPENAME boost::decay<U>::type, none_t>::value
|| boost::is_same<BOOST_DEDUCED_TYPENAME boost::decay<U>::type, in_place_init_t>::value
@ -787,14 +795,22 @@ struct is_optional_related
boost::true_type, boost::false_type>::type
{};
template <typename T, typename U>
struct has_dedicated_constructor
: boost::disjunction<is_optional_or_tag<U>, boost::is_same<T, BOOST_DEDUCED_TYPENAME boost::decay<U>::type> >
{};
template <typename U>
struct is_in_place_factory
: boost::disjunction< boost::is_base_of<boost::in_place_factory_base, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>,
boost::is_base_of<boost::typed_in_place_factory_base, BOOST_DEDUCED_TYPENAME boost::decay<U>::type> >
{};
#if !defined(BOOST_OPTIONAL_DETAIL_NO_IS_CONSTRUCTIBLE_TRAIT)
template <typename T, typename U>
struct is_convertible_to_T_or_factory
: boost::conditional< boost::is_base_of<boost::in_place_factory_base, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value
|| boost::is_base_of<boost::typed_in_place_factory_base, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value
|| (boost::is_constructible<T, U&&>::value && !boost::is_same<T, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value)
, boost::true_type, boost::false_type>::type
struct is_factory_or_constructible_to_T
: boost::disjunction< is_in_place_factory<U>, boost::is_constructible<T, U&&> >
{};
template <typename T, typename U>
@ -804,7 +820,7 @@ struct is_optional_constructible : boost::is_constructible<T, U>
#else
template <typename, typename>
struct is_convertible_to_T_or_factory : boost::true_type
struct is_factory_or_constructible_to_T : boost::true_type
{};
template <typename T, typename U>
@ -813,15 +829,58 @@ struct is_optional_constructible : boost::true_type
#endif // is_convertible condition
template <typename T, typename U, bool = is_optional_related<U>::value>
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800)
// for is_assignable
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES)
// On some initial rvalue reference implementations GCC does it in a strange way,
// preferring perfect-forwarding constructor to implicit copy constructor.
template <typename T, typename U>
struct is_opt_assignable
: boost::conjunction<boost::is_convertible<U&&, T>, boost::is_assignable<T&, U&&> >
{};
#else
template <typename T, typename U>
struct is_opt_assignable
: boost::conjunction<boost::is_convertible<U, T>, boost::is_assignable<T&, U> >
{};
#endif
#else
template <typename T, typename U>
struct is_opt_assignable : boost::is_convertible<U, T>
{};
#endif
template <typename T, typename U>
struct is_factory_or_opt_assignable_to_T
: boost::disjunction< is_in_place_factory<U>, is_opt_assignable<T, U> >
{};
template <typename T, typename U, bool = has_dedicated_constructor<T, U>::value>
struct is_optional_val_init_candidate
: boost::false_type
{};
template <typename T, typename U>
struct is_optional_val_init_candidate<T, U, false>
: boost::conditional< is_convertible_to_T_or_factory<T, U>::value
, boost::true_type, boost::false_type>::type
: is_factory_or_constructible_to_T<T, U>
{};
template <typename T, typename U, bool = has_dedicated_constructor<T, U>::value>
struct is_optional_val_assign_candidate
: boost::false_type
{};
template <typename T, typename U>
struct is_optional_val_assign_candidate<T, U, false>
: is_factory_or_opt_assignable_to_T<T, U>
{};
} // namespace optional_detail
@ -994,7 +1053,7 @@ class optional
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
template<class Expr>
BOOST_DEDUCED_TYPENAME boost::enable_if<optional_detail::is_optional_val_init_candidate<T, Expr>, optional&>::type
BOOST_DEDUCED_TYPENAME boost::enable_if<optional_detail::is_optional_val_assign_candidate<T, Expr>, optional&>::type
operator= ( Expr&& expr )
{
this->assign_expr(boost::forward<Expr>(expr),boost::addressof(expr));
@ -1201,7 +1260,7 @@ class optional
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);
boost::core::invoke_swap(*this, arg);
}
@ -1586,6 +1645,7 @@ get_pointer ( optional<T>& opt )
} // namespace boost
#ifndef BOOST_NO_IOSTREAM
namespace boost {
// The following declaration prevents a bug where operator safe-bool is used upon streaming optional object if you forget the IO header.
@ -1598,6 +1658,7 @@ operator<<(std::basic_ostream<CharType, CharTrait>& os, optional_detail::optiona
}
} // namespace boost
#endif // BOOST_NO_IOSTREAM
#include <boost/optional/detail/optional_relops.hpp>
#include <boost/optional/detail/optional_swap.hpp>

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

@ -22,9 +22,11 @@ import testing ;
[ 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 ]

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>
@ -75,7 +77,7 @@ void test_basics( T const* )
check_uninitialized(def);
// Implicit construction
// The first parameter is implicitely converted to optional<T>(a);
// The first parameter is implicitly converted to optional<T>(a);
test_implicit_construction(a,a,z);
// Direct initialization.
@ -162,7 +164,7 @@ void test_basics( T const* )
}
template<class T>
void test_conditional_ctor_and_get_valur_or ( T const* )
void test_conditional_ctor_and_get_value_or ( T const* )
{
TRACE( std::endl << BOOST_CURRENT_FUNCTION );
@ -448,8 +450,8 @@ void test_throwing_val_assign_on_initialized( T const* )
{
// This should:
// Attempt to assign 'a' and throw.
// opt is kept initialized but its value not neccesarily fully assigned
// (in this test, incompletely assigned is flaged with the value -1 being set)
// opt is kept initialized but its value not necessarily fully assigned
// (in this test, incompletely assigned is flagged with the value -1 being set)
set_pending_assign( ARG(T) ) ;
opt.reset ( a ) ;
passed = true ;
@ -573,8 +575,8 @@ void test_throwing_assign_to_initialized( T const* )
{
// This should:
// Attempt to copy construct 'opt1.value()' into opt0 and throw.
// opt0 is kept initialized but its value not neccesarily fully assigned
// (in this test, incompletely assigned is flaged with the value -1 being set)
// opt0 is kept initialized but its value not necessarily fully assigned
// (in this test, incompletely assigned is flagged with the value -1 being set)
set_pending_assign( ARG(T) ) ;
opt0 = opt1 ;
passed = true ;
@ -685,7 +687,7 @@ void test_throwing_swap( T const* )
try
{
// This should attempt to swap optionals and fail at opt0.reset(*opt1)
// Both opt0 and op1 are left unchanged (unswaped)
// Both opt0 and op1 are left unchanged (unswapped)
swap(opt0,opt1);
passed = true ;
@ -725,7 +727,7 @@ void test_relops( T const* )
BOOST_TEST ( !(def0 != def0) ) ;
BOOST_TEST ( !(opt0 != opt0) ) ;
// Check when both are uininitalized.
// Check when both are uninitialized.
BOOST_TEST ( def0 == def1 ) ; // both uninitialized compare equal
BOOST_TEST ( !(def0 < def1) ) ; // uninitialized is never less than uninitialized
BOOST_TEST ( !(def0 > def1) ) ; // uninitialized is never greater than uninitialized
@ -833,7 +835,7 @@ void test_with_builtin_types()
TRACE( std::endl << BOOST_CURRENT_FUNCTION );
test_basics( ARG(double) );
test_conditional_ctor_and_get_valur_or( ARG(double) );
test_conditional_ctor_and_get_value_or( ARG(double) );
test_uninitialized_access( ARG(double) );
test_no_throwing_swap( ARG(double) );
test_relops( ARG(double) ) ;
@ -855,7 +857,7 @@ void test_with_class_type()
test_basics( ARG(X) );
test_basics( ARG(VBase) );
test_conditional_ctor_and_get_valur_or( ARG(X) );
test_conditional_ctor_and_get_value_or( ARG(X) );
test_direct_value_manip( ARG(X) );
test_uninitialized_access( ARG(X) );
test_throwing_direct_init( ARG(X) );
@ -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

@ -58,7 +58,7 @@ using boost::get_pointer ;
#define ARG(T) (static_cast< T const* >(0))
//
// Helper class used to verify the lifetime managment of the values held by optional
// Helper class used to verify the lifetime management of the values held by optional
//
class X
{

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

@ -22,7 +22,7 @@ int main()
class basic_multi_buffer;
class const_buffers_type // a similar declaration in boost.beast had problem
{ // with boost opitonal
{ // with boost optional
basic_multi_buffer const* b_;
friend class basic_multi_buffer;

View File

@ -15,7 +15,7 @@
// THIS TEST SHOULD FAIL TO COMPILE
//
#if BOOST_WORKAROUND( BOOST_INTEL_CXX_VERSION, <= 700) // Intel C++ 7.0
// Interl C++ 7.0 incorrectly accepts the initialization "boost::optional<int> opt = 3"
// Intel C++ 7.0 incorrectly accepts the initialization "boost::optional<int> opt = 3"
// even though the ctor is explicit (c.f. 12.3.1.2), so the test uses another form of
// copy-initialization: argument-passing (8.5.12)
void helper ( boost::optional<int> ) ;

View File

@ -13,7 +13,7 @@
// THIS TEST SHOULD FAIL TO COMPILE
void test_converitng_assignment_of_different_enums()
void test_converting_assignment_of_different_enums()
{
const boost::optional<int> o1(1);
const boost::optional<int> o2(2);
@ -22,5 +22,5 @@ void test_converitng_assignment_of_different_enums()
int main()
{
test_converitng_assignment_of_different_enums();
test_converting_assignment_of_different_enums();
}

View File

@ -16,7 +16,7 @@
enum E1 {e1};
enum E2 {e2};
void test_converitng_assignment_of_different_enums()
void test_converting_assignment_of_different_enums()
{
boost::optional<E2> o2(e2);
boost::optional<E1> o1;

View File

@ -16,14 +16,14 @@
#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"
#include "boost/type_traits/is_same.hpp"
using boost::optional;
using boost::make_optional;
using boost::core::is_same;
using boost::is_same;
template <typename Expected, typename Deduced>
void verify_type(Deduced)

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

@ -10,15 +10,19 @@
// 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"
#ifndef BOOST_NO_IOSTREAM
#include <sstream>
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/core/lightweight_test.hpp"
using boost::optional;
@ -29,7 +33,7 @@ void test2( Opt o, Opt buff )
const int markv = 123 ;
int mark = 0 ;
s << o << " " << markv ;
s >> buff >> mark ;
@ -85,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

@ -16,21 +16,21 @@
#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"
#include "boost/type_traits/is_same.hpp"
using boost::optional;
using boost::make_optional;
using boost::core::is_same;
using boost::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
{
@ -38,7 +38,7 @@ struct MoveOnly
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&);
@ -53,15 +53,15 @@ 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);
}
@ -73,15 +73,15 @@ 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);
}
@ -90,21 +90,21 @@ 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);
}

View File

@ -16,29 +16,29 @@
#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"
#include "boost/type_traits/is_same.hpp"
using boost::optional;
using boost::make_optional;
using boost::core::is_same;
using boost::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)
#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&);
@ -70,7 +70,7 @@ void test_map_move_only()
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_);
@ -126,16 +126,16 @@ 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(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);
BOOST_TEST(bool(oo0));
BOOST_TEST(!*oo0);
optional<optional<Int> > oo_ = o_.map(make_opt_int);
BOOST_TEST(!oo_);
BOOST_TEST(!oo_);
}
void test_map_with_lambda()
@ -178,7 +178,7 @@ void test_map_optional_ref()
int main()
{
#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
test_map_move_only();
#endif
test_map_with_lambda();

View File

@ -105,7 +105,7 @@ void test_noexcept_optional_with_operator() // compile-time test
BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onx0 = ONx0() ));
}
#endif // !defned BOOST_NO_CXX11_NOEXCEPT
#endif // !defined BOOST_NO_CXX11_NOEXCEPT
#endif // !defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
int main()

View File

@ -431,7 +431,7 @@ void test_swap()
}
template <typename T, typename U>
void test_convertability_of_compatible_reference_types()
void test_convertibility_of_compatible_reference_types()
{
typename concrete_type_of<T>::type v1(1);
optional<T&> oN, o1(v1);
@ -489,11 +489,11 @@ int main()
test_optional_const_ref<Abstract>();
test_optional_const_ref< optional<int> >();
test_convertability_of_compatible_reference_types<int, const int>();
test_convertability_of_compatible_reference_types<Impl, Abstract>();
test_convertability_of_compatible_reference_types<Impl, const Abstract>();
test_convertability_of_compatible_reference_types<const Impl, const Abstract>();
test_convertability_of_compatible_reference_types<optional<int>, const optional<int> >();
test_convertibility_of_compatible_reference_types<int, const int>();
test_convertibility_of_compatible_reference_types<Impl, Abstract>();
test_convertibility_of_compatible_reference_types<Impl, const Abstract>();
test_convertibility_of_compatible_reference_types<const Impl, const Abstract>();
test_convertibility_of_compatible_reference_types<optional<int>, const optional<int> >();
return boost::report_errors();
}

View File

@ -70,7 +70,7 @@ void test_value_init()
}
}
void test_optoinal_reference_wrapper()
void test_optional_reference_wrapper()
{
boost::optional<W<S&> > o;
BOOST_TEST(boost::none == o);
@ -80,7 +80,7 @@ int main()
{
test_tc_base();
test_value_init();
test_optoinal_reference_wrapper();
test_optional_reference_wrapper();
return boost::report_errors();
}