mirror of
https://github.com/boostorg/optional.git
synced 2025-07-13 12:26:36 +02:00
Compare commits
184 Commits
boost-1.64
...
boost-1.86
Author | SHA1 | Date | |
---|---|---|---|
c60db27762 | |||
5064a9a28d | |||
fe0384baa6 | |||
76c82e83ae | |||
e59b1bce1d | |||
f95fb5dff2 | |||
7878dec842 | |||
a3abf04548 | |||
9c43ae3612 | |||
def2db7c45 | |||
6266c39b8e | |||
e300c4bc60 | |||
302f39e545 | |||
d4f84a868d | |||
46ad495a60 | |||
246f1663e1 | |||
668c8d924b | |||
653ebefbac | |||
ce500ee436 | |||
b4c8f493c6 | |||
7e395f4520 | |||
630cf7f7b5 | |||
cdc2bd8482 | |||
db472e7ed6 | |||
8ffb7e3f57 | |||
deda20af89 | |||
4b63acfc10 | |||
599c72f23b | |||
a4479bf8cd | |||
ba1846abd3 | |||
168552e021 | |||
581c43f25c | |||
c76b73c48b | |||
e26c2d7489 | |||
969930959c | |||
56156dcc87 | |||
802e73477a | |||
9944804c5c | |||
2121a9fa59 | |||
cc416b8989 | |||
74a684232f | |||
6f85014c00 | |||
29dd9187ec | |||
bcc83a662a | |||
c4291fa461 | |||
de27c0f853 | |||
9c44e402f6 | |||
5ab4701192 | |||
ab7e5275c0 | |||
416c89e165 | |||
c809700d6a | |||
293d1861d7 | |||
3038bdea4b | |||
938806c876 | |||
85ebe0a2ed | |||
ce5834add2 | |||
a514ce627d | |||
ec677383dc | |||
52abe4842e | |||
4ead6d14ff | |||
78d42ff970 | |||
6117d08d79 | |||
916ca23572 | |||
c300a8c517 | |||
4f713acdf8 | |||
1e6f838a90 | |||
51b7053abf | |||
ec96129e9e | |||
8e86559103 | |||
56568445b9 | |||
7dd512a019 | |||
21253ea63a | |||
14d43d2e6e | |||
0b159febf8 | |||
d0ab8004c0 | |||
5a444eb84b | |||
0566bde447 | |||
a70c51eed1 | |||
9c9ff5e376 | |||
708db7fe9a | |||
27971d8b11 | |||
97da91f665 | |||
4a1a9c9cdd | |||
71feb7961b | |||
ead529af54 | |||
45321f321e | |||
18222c8394 | |||
a7f49cbec8 | |||
7e0b8145b5 | |||
2b08711ec6 | |||
88e7d55bbc | |||
9de55e6ffd | |||
409a225afe | |||
db5e156ebc | |||
aeac95857e | |||
d5b7791710 | |||
c486bb724c | |||
19b94c01f3 | |||
404f40bcc1 | |||
9b1f8033eb | |||
e52d7d4a9e | |||
ed9edd54e4 | |||
d2479d6f52 | |||
78d6563bce | |||
d4a4a5b6ad | |||
9581804efa | |||
d07ae78901 | |||
683dbe2412 | |||
010ee00604 | |||
13bc27698e | |||
0481b05d1f | |||
4c863f5bf8 | |||
9ed20cb085 | |||
4fbb7582e1 | |||
29dfc173c6 | |||
f4d1107e86 | |||
324272fc0e | |||
ee575b34c5 | |||
a192204b41 | |||
545fd9a72f | |||
29b2dae630 | |||
2f3cf1ca84 | |||
24d29e5865 | |||
eea107d9b5 | |||
69e239530e | |||
65bb040db8 | |||
fae2791f45 | |||
0f8e356bca | |||
59277bc31f | |||
bebc606a4c | |||
106f9aee5e | |||
350ebab88a | |||
a3916b46a9 | |||
c52280bb78 | |||
155ad5911e | |||
228b20df82 | |||
2854383cf7 | |||
d0b87d2f35 | |||
71d797b9ee | |||
701afd43a4 | |||
d13623884a | |||
7320dd54e8 | |||
51a46f95c6 | |||
35ca7c1ff1 | |||
0169460194 | |||
42445e94aa | |||
250806d029 | |||
51d1bc843d | |||
e47a017009 | |||
5182f7f30f | |||
8f992acb94 | |||
33c7a6aa2b | |||
76ff82d191 | |||
b1e29eb585 | |||
a5aaf4d8d0 | |||
1f6d8bc602 | |||
e230bd83c6 | |||
b832d4c54f | |||
fb54ee1741 | |||
5b6f4be434 | |||
f9fdf42a17 | |||
7541076cf1 | |||
40f7c97292 | |||
06dea2cb9b | |||
cbf3cd05af | |||
6e10173a44 | |||
69bf75ae6d | |||
01ebd2ad7f | |||
42c2377a0d | |||
9d0ddc4709 | |||
a7f33f5d6f | |||
58f7c2f14a | |||
ebef3ed6f7 | |||
9e0726cee1 | |||
2d2c3c3f6f | |||
e95f9fc254 | |||
7e1beb473c | |||
61bf382ffa | |||
4fe57f57fa | |||
c695be11b5 | |||
e9f5641be3 | |||
b709447922 | |||
cd4e44f3dc | |||
c3abf83426 |
36
.drone.star
Normal file
36
.drone.star
Normal 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
37
.drone/drone.sh
Executable 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
396
.github/workflows/ci.yml
vendored
Normal 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
|
201
.travis.yml
Normal file
201
.travis.yml
Normal file
@ -0,0 +1,201 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
python: "2.7"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/build
|
||||
- git submodule update --init libs/config
|
||||
- git submodule update --init tools/boostdep
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/optional
|
||||
- python tools/boostdep/depinst/depinst.py optional
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 libs/optional/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
25
CMakeLists.txt
Normal file
25
CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
# 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
|
||||
|
||||
cmake_minimum_required( VERSION 3.5...3.20 )
|
||||
project( boost_optional VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX )
|
||||
|
||||
add_library( boost_optional INTERFACE )
|
||||
add_library( Boost::optional ALIAS boost_optional )
|
||||
|
||||
target_include_directories( boost_optional INTERFACE include )
|
||||
|
||||
target_link_libraries( boost_optional
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::detail
|
||||
Boost::move
|
||||
Boost::predef
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
Boost::type_traits
|
||||
Boost::utility
|
||||
)
|
@ -2,7 +2,7 @@
|
||||
[quickbook 1.4]
|
||||
[authors [Cacciola Carballal, Fernando Luis]]
|
||||
[copyright 2003-2007 Fernando Luis Cacciola Carballal]
|
||||
[copyright 2014-2016 Andrzej Krzemieński]
|
||||
[copyright 2014-2023 Andrzej Krzemień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]
|
||||
|
||||
|
||||
|
@ -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]
|
||||
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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]
|
||||
|
45
doc/14_monadic_interface.qbk
Normal file
45
doc/14_monadic_interface.qbk
Normal 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]
|
@ -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.
|
@ -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]
|
@ -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]
|
||||
|
||||
|
@ -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]
|
@ -1,7 +1,7 @@
|
||||
|
||||
[section Performance considerations]
|
||||
|
||||
Technical details aside, the memory layout of `optional<T>` is more-less this:
|
||||
Technical details aside, the memory layout of `optional<T>` for a generic `T` is more-less this:
|
||||
|
||||
template <typename T>
|
||||
class optional
|
||||
@ -9,8 +9,33 @@ Technical details aside, the memory layout of `optional<T>` is more-less this:
|
||||
bool _initialized;
|
||||
std::aligned_storage_t<sizeof(t), alignof(T)> _storage;
|
||||
};
|
||||
|
||||
Lifetime of the `T` inside `_storage` is manually controlled with placement-`new`s and pseudo-destructor calls. However, for scalar `T`s we use a different way of storage, by simply holding a `T`:
|
||||
|
||||
But for the purpose of this analysis, considering memory layouts, we can think of it as:
|
||||
template <typename T>
|
||||
class optional
|
||||
{
|
||||
bool _initialized;
|
||||
T _storage;
|
||||
};
|
||||
|
||||
We call it a ['direct] storage. This makes `optional<T>` a trivially-copyable type for scalar `T`s. This only works for compilers that support defaulted functions (including defaulted move assignment and constructor). On compilers without defaulted functions we still use the direct storage, but `optional<T>` is no longer recognized as trivially-copyable. Apart from scalar types, we leave the programmer a way of customizing her type, so that it is recognized by `optional` as candidate for optimized storage, by specializing type trait `boost::optional_config::optional_uses_direct_storage_for`:
|
||||
|
||||
struct X // not trivial
|
||||
{
|
||||
X() {}
|
||||
};
|
||||
|
||||
namespace boost { namespace optional_config {
|
||||
|
||||
template <> struct optional_uses_direct_storage_for<X> : boost::true_type {};
|
||||
|
||||
}}
|
||||
|
||||
|
||||
[heading Controlling the size]
|
||||
|
||||
For the purpose of the following analysis, considering memory layouts, we can think of it as:
|
||||
|
||||
template <typename T>
|
||||
class optional
|
||||
@ -61,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
|
||||
{
|
@ -17,8 +17,8 @@ namespace boost {
|
||||
|
||||
class none_t {/* see below */};
|
||||
|
||||
const none_t none (/* see below */);
|
||||
|
||||
inline constexpr none_t none (/* see below */);
|
||||
|
||||
} // namespace boost
|
||||
```
|
||||
|
||||
|
@ -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]
|
||||
|
@ -17,16 +17,16 @@
|
||||
|
||||
class in_place_init_t { /* see below */ } ; ``[link reference_in_place_init __GO_TO__]``
|
||||
const in_place_init_t in_place_init ( /* see below */ ) ;
|
||||
|
||||
|
||||
class in_place_init_if_t { /*see below*/ } ; ``[link reference_in_place_init_if __GO_TO__]``
|
||||
const in_place_init_if_t in_place_init_if ( /*see below*/ ) ;
|
||||
|
||||
|
||||
template <class T>
|
||||
class optional ; ``[link reference_operator_template __GO_TO__]``
|
||||
|
||||
|
||||
template <class T>
|
||||
class optional<T&> ; ``[link reference_operator_template_spec __GO_TO__]``
|
||||
|
||||
|
||||
template<class T> inline bool operator == ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_equal_optional_optional __GO_TO__]``
|
||||
|
||||
template<class T> inline bool operator != ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_not_equal_optional_optional __GO_TO__]``
|
||||
@ -38,17 +38,21 @@
|
||||
template<class T> inline bool operator <= ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_less_or_equal_optional_optional __GO_TO__]``
|
||||
|
||||
template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_greater_or_equal_optional_optional __GO_TO__]``
|
||||
|
||||
|
||||
template<class T> inline bool operator == ( optional<T> const& x, none_t ) noexcept ; ``[link reference_operator_compare_equal_optional_none __GO_TO__]``
|
||||
|
||||
template<class T> inline bool operator != ( optional<T> const& x, none_t ) noexcept ; ``[link reference_operator_compare_not_equal_optional_none __GO_TO__]``
|
||||
|
||||
template<class T> inline optional<T> make_optional ( T const& v ) ; ``[link reference_make_optional_value __GO_TO__]``
|
||||
|
||||
template<class T> inline optional<std::decay_t<T>> make_optional ( T && v ) ; ``[link reference_make_optional_rvalue __GO_TO__]``
|
||||
|
||||
template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; ``[link reference_make_optional_bool_value __GO_TO__]``
|
||||
|
||||
template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_const_type def ) -> typename optional<T>::reference_const_type; ``[link reference_free_get_value_or __GO_TO__]``
|
||||
|
||||
template<class T> inline optional<std::decay_t<T>> make_optional ( bool condition, T && v ) ; ``[link reference_make_optional_bool_rvalue __GO_TO__]``
|
||||
|
||||
template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_const_type def ) -> typename optional<T>::reference_const_type; ``[link reference_free_get_value_or __GO_TO__]``
|
||||
|
||||
template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_type def ) -> typename optional<T>::reference_type ; ``[link reference_free_get_value_or __GO_TO__]``
|
||||
|
||||
template<class T> inline T const& get ( optional<T> const& opt ) ; ``[link reference_optional_get __GO_TO__]``
|
||||
@ -64,11 +68,21 @@
|
||||
template<class T> inline auto get_pointer ( optional<T> & opt ) -> ``['see below]``; ``[link reference_free_get_pointer __GO_TO__]``
|
||||
|
||||
template<class T> inline void swap( optional<T>& x, optional<T>& y ) ; ``[link reference_swap_optional_optional __GO_TO__]``
|
||||
|
||||
|
||||
template<class T> inline void swap( optional<T&>& x, optional<T&>& y ) ; ``[link reference_swap_optional_reference __GO_TO__]``
|
||||
|
||||
} // namespace boost
|
||||
|
||||
namespace std {
|
||||
|
||||
template <typename T>
|
||||
struct hash<boost::optional<T> > ; ``[link reference_std_hash_spec __GO_TO__]``
|
||||
|
||||
template <typename T>
|
||||
struct hash<boost::optional<T&> > ; ``[link reference_std_hash_spec __GO_TO__]``
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
@ -82,21 +96,21 @@
|
||||
|
||||
class in_place_init_t { /* see below */ } ;
|
||||
const in_place_init_t in_place_init ( /* see below */ ) ;
|
||||
|
||||
|
||||
class in_place_init_if_t { /*see below*/ } ;
|
||||
const in_place_init_if_t in_place_init_if ( /*see below*/ ) ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Classes `in_place_init_t` and `in_place_init_if_t` are empty clsses. Their purpose is to control overload resolution in the initialization of optional objects.
|
||||
They are empty, trivially copyable classes with disabled default constructor.
|
||||
Classes `in_place_init_t` and `in_place_init_if_t` are empty 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]
|
||||
|
||||
[section:header_optional_optional_values Optional Values]
|
||||
|
||||
[#reference_operator_template]
|
||||
|
||||
|
||||
template <class T>
|
||||
class optional
|
||||
{
|
||||
@ -108,27 +122,27 @@ They are empty, trivially copyable classes with disabled default constructor.
|
||||
typedef T && rval_reference_type ;
|
||||
typedef T * pointer_type ;
|
||||
typedef T const* pointer_const_type ;
|
||||
|
||||
|
||||
optional () noexcept ; ``[link reference_optional_constructor __GO_TO__]``
|
||||
|
||||
optional ( none_t ) noexcept ; ``[link reference_optional_constructor_none_t __GO_TO__]``
|
||||
|
||||
optional ( T const& v ) ; ``[link reference_optional_constructor_value __GO_TO__]``
|
||||
|
||||
|
||||
optional ( T&& v ) ; ``[link reference_optional_constructor_move_value __GO_TO__]``
|
||||
|
||||
optional ( bool condition, T const& v ) ; ``[link reference_optional_constructor_bool_value __GO_TO__]``
|
||||
optional ( bool condition, T const& v ) ; ``[link reference_optional_constructor_bool_value __GO_TO__]``
|
||||
|
||||
optional ( optional const& rhs ) ; ``[link reference_optional_constructor_optional __GO_TO__]``
|
||||
|
||||
|
||||
optional ( optional&& rhs ) noexcept(``['see below]``) ; ``[link reference_optional_move_constructor_optional __GO_TO__]``
|
||||
|
||||
template<class U> explicit optional ( optional<U> const& rhs ) ; ``[link reference_optional_constructor_other_optional __GO_TO__]``
|
||||
|
||||
|
||||
template<class U> explicit optional ( optional<U>&& rhs ) ; ``[link reference_optional_move_constructor_other_optional __GO_TO__]``
|
||||
|
||||
|
||||
template<class... Args> explicit optional ( in_place_init_t, Args&&... args ) ; ``[link reference_optional_in_place_init __GO_TO__]``
|
||||
|
||||
|
||||
template<class... Args> explicit optional ( in_place_init_if_t, bool condition, Args&&... args ) ; ``[link reference_optional_in_place_init_if __GO_TO__]``
|
||||
|
||||
template<class InPlaceFactory> explicit optional ( InPlaceFactory const& f ) ; ``[link reference_optional_constructor_factory __GO_TO__]``
|
||||
@ -138,17 +152,17 @@ They are empty, trivially copyable classes with disabled default constructor.
|
||||
optional& operator = ( none_t ) noexcept ; ``[link reference_optional_operator_equal_none_t __GO_TO__]``
|
||||
|
||||
optional& operator = ( T const& v ) ; ``[link reference_optional_operator_equal_value __GO_TO__]``
|
||||
|
||||
|
||||
optional& operator = ( T&& v ) ; ``[link reference_optional_operator_move_equal_value __GO_TO__]``
|
||||
|
||||
optional& operator = ( optional const& rhs ) ; ``[link reference_optional_operator_equal_optional __GO_TO__]``
|
||||
|
||||
|
||||
optional& operator = ( optional&& rhs ) noexcept(``['see below]``) ; ``[link reference_optional_operator_move_equal_optional __GO_TO__]``
|
||||
|
||||
template<class U> optional& operator = ( optional<U> const& rhs ) ; ``[link reference_optional_operator_equal_other_optional __GO_TO__]``
|
||||
|
||||
|
||||
template<class U> optional& operator = ( optional<U>&& rhs ) ; ``[link reference_optional_operator_move_equal_other_optional __GO_TO__]``
|
||||
|
||||
|
||||
template<class... Args> void emplace ( Args&&... args ) ; ``[link reference_optional_emplace __GO_TO__]``
|
||||
|
||||
template<class InPlaceFactory> optional& operator = ( InPlaceFactory const& f ) ; ``[link reference_optional_operator_equal_factory __GO_TO__]``
|
||||
@ -164,29 +178,38 @@ They are empty, trivially copyable classes with disabled default constructor.
|
||||
T const& operator *() const& ; ``[link reference_optional_operator_asterisk __GO_TO__]``
|
||||
T& operator *() & ; ``[link reference_optional_operator_asterisk __GO_TO__]``
|
||||
T&& operator *() && ; ``[link reference_optional_operator_asterisk_move __GO_TO__]``
|
||||
|
||||
|
||||
T const& value() const& ; ``[link reference_optional_value __GO_TO__]``
|
||||
T& value() & ; ``[link reference_optional_value __GO_TO__]``
|
||||
T&& value() && ; ``[link reference_optional_value_move __GO_TO__]``
|
||||
|
||||
|
||||
template<class U> T value_or( U && v ) const& ; ``[link reference_optional_value_or __GO_TO__]``
|
||||
template<class U> T value_or( U && v ) && ; ``[link reference_optional_value_or_move __GO_TO__]``
|
||||
|
||||
|
||||
template<class F> T value_or_eval( F f ) const& ; ``[link reference_optional_value_or_call __GO_TO__]``
|
||||
template<class F> T value_or_eval( F f ) && ; ``[link reference_optional_value_or_call_move __GO_TO__]``
|
||||
|
||||
template<class F> auto map( F f ) const& -> ``['see below]``; ``[link reference_optional_map __GO_TO__]``
|
||||
template<class F> auto map( F f ) & -> ``['see below]``; ``[link reference_optional_map __GO_TO__]``
|
||||
template<class F> auto map( F f ) && -> ``['see below]``; ``[link reference_optional_map_move __GO_TO__]``
|
||||
|
||||
template<class F> auto flat_map( F f ) const& -> ``['see below]``; ``[link reference_optional_flat_map __GO_TO__]``
|
||||
template<class F> auto flat_map( F f ) & -> ``['see below]``; ``[link reference_optional_flat_map __GO_TO__]``
|
||||
template<class F> auto flat_map( F f ) && -> ``['see below]``; ``[link reference_optional_flat_map_move __GO_TO__]``
|
||||
|
||||
T const* get_ptr() const ; ``[link reference_optional_get_ptr __GO_TO__]``
|
||||
T* get_ptr() ; ``[link reference_optional_get_ptr __GO_TO__]``
|
||||
|
||||
bool has_value() const noexcept ; ``[link reference_optional_operator_bool __GO_TO__]``
|
||||
|
||||
explicit operator bool() const noexcept ; ``[link reference_optional_operator_bool __GO_TO__]``
|
||||
|
||||
bool operator!() const noexcept ; ``[link reference_optional_operator_not __GO_TO__]``
|
||||
|
||||
// deprecated methods
|
||||
|
||||
// (deprecated)
|
||||
void reset() noexcept ; ``[link reference_optional_reset __GO_TO__]``
|
||||
|
||||
// deprecated methods
|
||||
|
||||
// (deprecated)
|
||||
void reset ( T const& ) ; ``[link reference_optional_reset_value __GO_TO__]``
|
||||
|
||||
@ -194,7 +217,7 @@ They are empty, trivially copyable classes with disabled default constructor.
|
||||
bool is_initialized() const ; ``[link reference_optional_is_initialized __GO_TO__]``
|
||||
|
||||
// (deprecated)
|
||||
T const& get_value_or( T const& default ) const ; ``[link reference_optional_get_value_or_value __GO_TO__]``
|
||||
T const& get_value_or( T const& default ) const ; ``[link reference_optional_get_value_or_value __GO_TO__]``
|
||||
};
|
||||
|
||||
|
||||
@ -205,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 :
|
||||
|
||||
@ -221,22 +244,21 @@ They are empty, trivially copyable classes with disabled default constructor.
|
||||
optional ( none_t ) noexcept ; ``[link reference_optional_ref_default_ctor __GO_TO__]``
|
||||
|
||||
template<class R> optional(R&& r) noexcept ; ``[link reference_optional_ref_value_ctor __GO_TO__]``
|
||||
|
||||
|
||||
template <class R> optional(bool cond, R&& r) noexcept ; ``[link reference_optional_ref_cond_value_ctor __GO_TO__]``
|
||||
|
||||
|
||||
optional ( optional const& rhs ) noexcept ; ``[link reference_optional_ref_copy_ctor __GO_TO__]``
|
||||
|
||||
template<class U> explicit optional ( optional<U&> const& rhs ) noexcept ; ``[link reference_optional_ref_ctor_from_opt_U __GO_TO__]``
|
||||
|
||||
optional& operator = ( none_t ) noexcept ; ``[link reference_optional_ref_assign_none_t __GO_TO__]``
|
||||
|
||||
|
||||
optional& operator = ( optional const& rhs ) noexcept; ``[link reference_optional_ref_copy_assign __GO_TO__]``
|
||||
|
||||
template<class U> optional& operator = ( optional<U&> const& rhs ) noexcept ; ``[link reference_optional_ref_assign_optional_U __GO_TO__]``
|
||||
|
||||
template<class R> optional& operator = (R&& r) noexcept ; ``[link reference_optional_ref_assign_R __GO_TO__]``
|
||||
|
||||
|
||||
template<class R> optional& operator = (R&& r) noexcept ; ``[link reference_optional_ref_assign_R __GO_TO__]``
|
||||
|
||||
template<class R> void emplace ( R&& r ) noexcept ; ``[link reference_optional_ref_emplace_R __GO_TO__]``
|
||||
|
||||
T& get() const ; ``[link reference_optional_ref_get __GO_TO__]``
|
||||
@ -245,22 +267,27 @@ They are empty, trivially copyable classes with disabled default constructor.
|
||||
T* operator ->() const ; ``[link reference_optional_ref_arrow __GO_TO__]``
|
||||
|
||||
T& value() const& ; ``[link reference_optional_ref_value __GO_TO__]``
|
||||
|
||||
|
||||
template<class R> T& value_or( R && r ) const noexcept ; ``[link reference_optional_ref_value_or __GO_TO__]``
|
||||
|
||||
|
||||
template<class F> T& value_or_eval( F f ) const ; ``[link reference_optional_ref_value_or_eval __GO_TO__]``
|
||||
|
||||
template<class F> auto map( F f ) const -> ``['see below]``; ``[link reference_optional_ref_map __GO_TO__]``
|
||||
|
||||
template<class F> auto flat_map( F f ) const -> ``['see below]``; ``[link reference_optional_ref_flat_map __GO_TO__]``
|
||||
|
||||
T* get_ptr() const noexcept ; ``[link reference_optional_ref_get_ptr __GO_TO__]``
|
||||
|
||||
bool has_value() const noexcept ; ``[link reference_optional_ref_operator_bool __GO_TO__]``
|
||||
|
||||
explicit operator bool() const noexcept ; ``[link reference_optional_ref_operator_bool __GO_TO__]``
|
||||
|
||||
bool operator!() const noexcept ; ``[link reference_optional_ref_operator_not __GO_TO__]``
|
||||
|
||||
// deprecated methods
|
||||
|
||||
// (deprecated)
|
||||
void reset() noexcept ; ``[link reference_optional_ref_reset __GO_TO__]``
|
||||
|
||||
// deprecated methods
|
||||
|
||||
// (deprecated)
|
||||
template<class R> void reset ( R && r ) noexcept ; ``[link reference_optional_ref_reset_value __GO_TO__]``
|
||||
|
||||
@ -268,8 +295,8 @@ They are empty, trivially copyable classes with disabled default constructor.
|
||||
bool is_initialized() const noexcept ; ``[link reference_optional_ref_is_initialized __GO_TO__]``
|
||||
|
||||
// (deprecated)
|
||||
template<class R> T& get_value_or( R && r ) constnoexcept; ``[link reference_optional_ref_get_value_or_value __GO_TO__]``
|
||||
|
||||
template<class R> T& get_value_or( R && r ) constnoexcept; ``[link reference_optional_ref_get_value_or_value __GO_TO__]``
|
||||
|
||||
private:
|
||||
T* ref; // exposition only
|
||||
};
|
||||
|
@ -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:]
|
||||
``
|
||||
@ -376,13 +376,13 @@ __SPACE__
|
||||
* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `CopyAssignable`.
|
||||
* [*Effects:]
|
||||
[table
|
||||
[]
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`;
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
* [*Exception Safety:] If any exception is thrown, the initialization state of `*this` and `rhs` remains unchanged.
|
||||
If an exception is thrown during the call to `T`'s copy constructor, no effect.
|
||||
If an exception is thrown during the call to `T`'s copy assignment, the state of its contained value is as defined by the exception safety guarantee of `T`'s copy assignment.
|
||||
@ -406,14 +406,14 @@ __SPACE__
|
||||
|
||||
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `MoveAssignable`.
|
||||
* [*Effects:]
|
||||
[table
|
||||
[table
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`;
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
* [*Remarks:] The expression inside `noexcept` is equivalent to `is_nothrow_move_constructible<T>::value && is_nothrow_move_assignable<T>::value`.
|
||||
* [*Exception Safety:] If any exception is thrown, the initialization state of `*this` and `rhs` remains unchanged. If an exception is
|
||||
thrown during the call to `T`'s move constructor, the state of `*rhs` is determined by the exception safety guarantee
|
||||
@ -437,15 +437,15 @@ __SPACE__
|
||||
|
||||
[: `template<U> optional& optional<T>::operator= ( optional<U> const& rhs ) ;`]
|
||||
|
||||
* [*Effect:]
|
||||
[table
|
||||
* [*Effect:]
|
||||
[table
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`.
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
* [*Exception Safety:] If any exception is thrown, the result of the expression `bool(*this)` remains unchanged.
|
||||
If an exception is thrown during the call to `T`'s constructor, no effect.
|
||||
If an exception is thrown during the call to `T`'s assignment, the state of its contained value is as defined by the exception safety guarantee of `T`'s copy assignment.
|
||||
@ -467,13 +467,13 @@ __SPACE__
|
||||
|
||||
* [*Effect:]
|
||||
[table
|
||||
[]
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`.
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
* [*Exception Safety:] If any exception is thrown, the result of the expression `bool(*this)` remains unchanged.
|
||||
If an exception is thrown during the call to `T`'s constructor, no effect.
|
||||
If an exception is thrown during the call to `T`'s assignment, the state of its contained value is as defined by the exception safety guarantee of `T`'s copy assignment.
|
||||
@ -485,7 +485,7 @@ optional<U> opt1;
|
||||
|
||||
opt1 = std::move(opt0) ;
|
||||
assert ( opt0 );
|
||||
assert ( opt1 )
|
||||
assert ( opt1 )
|
||||
assert ( *opt1 == static_cast<U>(v) ) ;
|
||||
``
|
||||
|
||||
@ -498,11 +498,11 @@ __SPACE__
|
||||
* [*Requires:] The compiler supports rvalue references and variadic templates.
|
||||
* [*Effect:] If `*this` is initialized calls `*this = none`.
|
||||
Then initializes in-place the contained value as if direct-initializing an object
|
||||
of type `T` with `std::forward<Args>(args)...`.
|
||||
of type `T` with `std::forward<Args>(args)...`.
|
||||
* [*Postconditions: ] `*this` is [_initialized].
|
||||
* [*Throws:] Whatever the selected `T`'s constructor throws.
|
||||
* [*Exception Safety:] If an exception is thrown during the initialization of `T`, `*this` is ['uninitialized].
|
||||
* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`. On compilers that do not suppor variadic templates or rvalue references, this function is available in limited functionality. For details [link optional_emplace_workaround see here].
|
||||
* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`. On compilers that do not support variadic templates or rvalue references, this function is available in limited functionality. For details [link optional_emplace_workaround see here].
|
||||
* [*Example:]
|
||||
``
|
||||
T v;
|
||||
@ -541,7 +541,7 @@ __SPACE__
|
||||
[#reference_optional_reset]
|
||||
|
||||
[: `void optional<T>::reset() noexcept ;`]
|
||||
* [*Deprecated:] Same as `operator=( none_t );`
|
||||
* [*Effects:] Same as `operator=( none_t );`
|
||||
|
||||
__SPACE__
|
||||
|
||||
@ -685,6 +685,65 @@ __SPACE__
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_optional_map]
|
||||
|
||||
[: `template<class F> auto optional<T>::map(F f) const& -> `['see below]` ;`]
|
||||
[: `template<class F> auto optional<T>::map(F f) & -> `['see below]` ;`]
|
||||
|
||||
* [*Effects:] `if (*this) return f(**this); else return none;`
|
||||
* [*Notes:] The return type of these overloads is `optional<decltype(f(**this))>`. On compilers that do not support ref-qualifiers on member functions, these two (as well as the next one) overloads are replaced with good old const and non-const overloads.
|
||||
* [*Example:]
|
||||
``
|
||||
auto length = [](const string& s){ return s.size(); };
|
||||
optional<string> o1 {}, o2 {"cat"};
|
||||
optional<size_t> os1 = o1.map(length), os2 = o2.map(length);
|
||||
assert ( !os1 ) ;
|
||||
assert ( os2 ) ;
|
||||
assert ( *os2 == 3 ) ;
|
||||
``
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_optional_map_move]
|
||||
|
||||
[: `template<class F> auto optional<T>::map(F f) && -> `['see below]` ;`]
|
||||
|
||||
* [*Effects:] `if (*this) return f(std::move(**this)); else return none;`
|
||||
* [*Notes:] The return type of this overload is `optional<decltype(f(istd::move(**this)))>`.
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_optional_flat_map]
|
||||
|
||||
[: `template<class F> auto optional<T>::flat_map(F f) const& -> `['see below]` ;`]
|
||||
[: `template<class F> auto optional<T>::flat_map(F f) & -> `['see below]` ;`]
|
||||
|
||||
* [*Requires:] The return type of expression `f(**this)` is `optional<U>` for some object or reference type `U`.
|
||||
* [*Effects:] `if (*this) return f(**this); else return none;`
|
||||
* [*Notes:] The return type of these overloads is `optional<U>`. On compilers that do not support ref-qualifiers on member functions, these two (as well as the next one) overloads are replaced with good old const and non-const overloads.
|
||||
* [*Example:]
|
||||
``
|
||||
optional<char> first_char(const string& s) {
|
||||
return s.empty() ? none : optional<char>(s[0]);
|
||||
};
|
||||
optional<string> o1 {}, o2 {"cat"};
|
||||
optional<char> os1 = o1.flat_map(first_char), os2 = o2.flat_map(first_char);
|
||||
assert ( !os1 ) ;
|
||||
assert ( os2 ) ;
|
||||
assert ( *os2 == 'c' ) ;
|
||||
``
|
||||
__SPACE__
|
||||
|
||||
[#reference_optional_flat_map_move]
|
||||
|
||||
[: `template<class F> auto optional<T>::flat_map(F f) && -> `['see below]` ;`]
|
||||
|
||||
* [*Requires:] The return type of expression `f(std::move(**this))` is `optional<U>` for some object or reference type `U`.
|
||||
* [*Effects:] `if (*this) return f(std::move(**this)); else return none;`
|
||||
* [*Notes:] The return type of this overload is `optional<U>`.
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_optional_get_value_or_value]
|
||||
|
||||
[: `T const& optional<T>::get_value_or( T const& default) const ;`]
|
||||
@ -754,6 +813,7 @@ __SPACE__
|
||||
[#reference_optional_operator_bool]
|
||||
|
||||
[: `explicit optional<T>::operator bool() const noexcept ;`]
|
||||
[: `bool optional<T>::has_value() const noexcept ;`]
|
||||
|
||||
* [*Returns:] `get_ptr() != 0`.
|
||||
* [*Notes:] On compilers that do not support explicit conversion operators this falls back to safe-bool idiom.
|
||||
@ -815,7 +875,7 @@ __SPACE__
|
||||
[: `template<class R> optional<T&>::optional(R&& r) noexcept;`]
|
||||
* [*Postconditions:] `bool(*this) == true`; `addressof(**this) == addressof(r)`.
|
||||
* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed. This constructor does not participate in overload resolution if `decay<R>` is an instance of `boost::optional`.
|
||||
* [*Notes:] This constructor is declared `explicit` on compilers that do not correctly suport binding to const lvalues of integral types. For more details [link optional_reference_binding see here].
|
||||
* [*Notes:] This constructor is declared `explicit` on compilers that do not correctly support binding to const lvalues of integral types. For more details [link optional_reference_binding see here].
|
||||
* [*Example:]
|
||||
``
|
||||
T v;
|
||||
@ -842,7 +902,7 @@ __SPACE__
|
||||
[: `optional<T&>::optional ( optional const& rhs ) noexcept ;`]
|
||||
|
||||
* [*Effects: ] Initializes `ref` with expression `rhs.ref`.
|
||||
|
||||
|
||||
* [*Postconditions:] `bool(*this) == bool(rhs)`.
|
||||
|
||||
* [*Example:]
|
||||
@ -875,7 +935,7 @@ __SPACE__
|
||||
* [*Requires:] `is_convertible<U&, T&>::value` is `true`.
|
||||
|
||||
* [*Effects: ] Initializes `ref` with expression `rhs.ref`.
|
||||
|
||||
|
||||
* [*Postconditions:] `bool(*this) == bool(rhs)`.
|
||||
|
||||
|
||||
@ -891,7 +951,7 @@ __SPACE__
|
||||
|
||||
* [*Postconditions:] `bool(*this) == false`.
|
||||
|
||||
|
||||
|
||||
|
||||
[#reference_optional_ref_copy_assign]
|
||||
|
||||
@ -939,7 +999,7 @@ assert ( *ora == 4 ) ;
|
||||
* [*returns:] `*this`.
|
||||
|
||||
* [*Postconditions:] `bool(*this) == bool(rhs)`.
|
||||
|
||||
|
||||
|
||||
__SPACE__
|
||||
|
||||
@ -950,7 +1010,7 @@ __SPACE__
|
||||
* [*Effects: ] Assigns `ref` with expression `r`.
|
||||
|
||||
* [*returns:] `*this`.
|
||||
|
||||
|
||||
* [*Postconditions:] `bool(*this) == true`.
|
||||
|
||||
* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed. This function does not participate in overload resolution if `decay<R>` is an instance of `boost::optional`.
|
||||
@ -1015,13 +1075,13 @@ __SPACE__
|
||||
|
||||
[#reference_optional_ref_value]
|
||||
[: `T& optional<T&>::value() const ;`]
|
||||
* [*Effects:] Equivalent to `return bool(*this) ? *val : throw bad_optional_access();`.
|
||||
* [*Effects:] Equivalent to `return bool(*this) ? *val : throw bad_optional_access();`.
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_optional_ref_value_or]
|
||||
[: `template<class R> T& optional<T&>::value_or( R&& r ) const noexcept;`]
|
||||
* [*Effects:] Equivalent to `if (*this) return **this; else return r;`.
|
||||
* [*Effects:] Equivalent to `if (*this) return **this; else return r;`.
|
||||
* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed.
|
||||
|
||||
__SPACE__
|
||||
@ -1033,6 +1093,21 @@ __SPACE__
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_optional_ref_map]
|
||||
[: `template<class F> auto optional<T&>::map( F f ) const -> `['see below]`;`]
|
||||
* [*Effects:] Equivalent to `if (*this) return f(**this); else return none;`.
|
||||
* [*Remarks:] The return type of this function is `optional<decltype(f(**this))>`.
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_optional_ref_flat_map]
|
||||
[: `template<class F> auto optional<T&>::flat_map( F f ) const -> `['see below]`;`]
|
||||
* [*Requires:] The return type of expression `f(**this)` is `optional<U>` for some object or reference type `U`.
|
||||
* [*Effects:] Equivalent to `if (*this) return f(**this); else return none;`.
|
||||
* [*Remarks:] The return type of this function is `optional<U>`.
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_optional_ref_get_ptr]
|
||||
[: `T* optional<T&>::get_ptr () const noexcept;`]
|
||||
* [*Returns:] `ref`.
|
||||
@ -1040,6 +1115,7 @@ __SPACE__
|
||||
__SPACE__
|
||||
|
||||
[#reference_optional_ref_operator_bool]
|
||||
[: `bool has_value() const noexcept;`]
|
||||
[: `optional<T&>::operator bool () const noexcept;`]
|
||||
* [*Returns:] `bool(ref)`.
|
||||
|
||||
@ -1053,30 +1129,29 @@ __SPACE__
|
||||
|
||||
[#reference_optional_ref_reset]
|
||||
[: `void optional<T&>::reset() noexcept;`]
|
||||
* [*Effects:] Use `*this = none` instead.
|
||||
* [*Remarks:] This function is depprecated.
|
||||
* [*Effects:] Same as `*this = none`.
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#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.
|
||||
|
||||
* [*Effects:] Equivalent to `return value_or(std::forward<R>(r);`.
|
||||
* [*Remarks:] This function is deprecated.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@ -1097,6 +1172,15 @@ template<class T> void foo ( optional<T> const& opt ) ;
|
||||
foo ( make_optional(1+1) ) ; // Creates an optional<int>
|
||||
``
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_make_optional_rvalue]
|
||||
|
||||
[: `optional<std::decay_t<T>> make_optional( T && v )`]
|
||||
|
||||
* [*Returns: ] `optional<std::decay_t<T>>(std::move(v))` for the ['deduced] type `T` of `v`.
|
||||
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_make_optional_bool_value]
|
||||
@ -1117,13 +1201,22 @@ if ( !v )
|
||||
error("foo wasn't computed");
|
||||
``
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_make_optional_bool_rvalue]
|
||||
|
||||
[: `optional<std::decay_t<T>> make_optional( bool condition, T && v )`]
|
||||
|
||||
* [*Returns: ] `optional<std::decay_t<T>>(condition, std::move(v))` for the ['deduced] type `T` of `v`.
|
||||
|
||||
|
||||
__SPACE__
|
||||
|
||||
[#reference_operator_compare_equal_optional_optional]
|
||||
|
||||
[: `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.
|
||||
@ -1156,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_;
|
||||
@ -1217,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__
|
||||
@ -1257,7 +1350,7 @@ __SPACE__
|
||||
|
||||
* [*Requires:] Lvalues of type `T` shall be swappable and `T` shall be __MOVE_CONSTRUCTIBLE__.
|
||||
* [*Effects:]
|
||||
[table
|
||||
[table
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][calls `swap(*(*this), *rhs)`][initializes the contained value of `*this` as if direct-initializing an object of type `T` with the expression `std::move(*rhs)`, followed by `rhs.val->T::~T()`, `*this` contains a value and `rhs` does not contain a value]]
|
||||
@ -1293,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:]
|
||||
``
|
||||
@ -1315,3 +1408,37 @@ assert (addressof(*opt0) == addressof(y));
|
||||
``
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[section Detailed Semantics - std::hash Specializations]
|
||||
|
||||
__SPACE__
|
||||
[#reference_std_hash_spec]
|
||||
|
||||
``
|
||||
namespace std {
|
||||
|
||||
template <typename T>
|
||||
struct hash<boost::optional<T> > ;
|
||||
|
||||
template <typename T>
|
||||
struct hash<boost::optional<T&> > ;
|
||||
|
||||
} // namespace std
|
||||
``
|
||||
|
||||
The specialization `hash<optional<T>>` is enabled if and only if
|
||||
`hash<remove_const_t<T>>` is enabled. When enabled, for an object `o`
|
||||
of type `optional<T>`, if `o.has_value() == true`, then `hash<optional<T>>()(o)`
|
||||
evaluates to the same value as `hash<remove_const_t<T>>()(*o)`; otherwise it
|
||||
evaluates to an unspecified value.
|
||||
The member functions are not guaranteed to be `noexcept`.
|
||||
|
||||
[caution
|
||||
You may get compiler errors when your program provides specializations for
|
||||
`std::hash<boost::optional<T>>`. If this happens, define macro
|
||||
`BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH` to suppress the specializations
|
||||
of `std::hash` in this library.
|
||||
]
|
||||
|
||||
[endsect]
|
||||
|
@ -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;
|
||||
|
@ -1,7 +1,7 @@
|
||||
[/
|
||||
Boost.Optional
|
||||
|
||||
Copyright (c) 2015, 2016 Andrzej Krzemienski
|
||||
Copyright (c) 2015 - 2022 Andrzej Krzemienski
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -11,6 +11,63 @@
|
||||
|
||||
[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.
|
||||
|
||||
* Fixed [@https://github.com/boostorg/optional/issues/78 issue #78].
|
||||
|
||||
[heading Boost Release 1.73]
|
||||
|
||||
* Fixed [@https://github.com/boostorg/optional/issues/78 issue #78].
|
||||
* `boost::none` is now declared as an inline variable (on compilers 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 suppressing warning `-Wweak-vtables`.
|
||||
|
||||
[heading Boost Release 1.69]
|
||||
|
||||
* Remove deprecation mark from `reset()` method (without arguments).
|
||||
* Fixed [@https://github.com/boostorg/optional/issues/59 issue #59].
|
||||
* Fixed bug with initialization of certain wrapper types in clang with -std=c++03. See [@https://github.com/boostorg/optional/pull/64 pr #64].
|
||||
|
||||
[heading Boost Release 1.68]
|
||||
|
||||
* Added member function `has_value()` for compatibility with `std::optional` ([@https://github.com/boostorg/optional/issues/52 issue #52]).
|
||||
* Added member function `map()` for transforming `optional<T>` into `optional<U>` using a function of type `T -> U`.
|
||||
* Added member function `flat_map()` for transforming `optional<T>` into `optional<U>` using a function of type `T -> optional<U>`.
|
||||
|
||||
|
||||
[heading Boost Release 1.67]
|
||||
|
||||
* Fixed [@https://github.com/boostorg/optional/issues/46 issue #46].
|
||||
* Fixed `-Wzero-as-null-pointer-constant` warnings.
|
||||
|
||||
|
||||
[heading Boost Release 1.66]
|
||||
|
||||
* On newer compilers `optional` is now trivially-copyable for scalar `T`s. This uses a different storage (just `T` rather than `aligned_storage`). We require the compiler to support defaulted functions.
|
||||
* Changed the implementation of `operator==` to get rid of the `-Wmaybe-uninitialized` false-positive warning from GCC.
|
||||
|
||||
[heading Boost Release 1.63]
|
||||
* Added two new in-place constructors. They work similarly to `emplace()` functions: they initialize the contained value by perfect-forwarding the obtained arguments. One constructor always initializes the contained value, the other based on a boolean condition.
|
||||
* Syntax `o = {}` now correctly un-initializes optional, just like in `std::optional`.
|
||||
@ -29,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>`.
|
||||
@ -53,7 +110,7 @@
|
||||
* IOStream operators are now mentioned in documentation.
|
||||
* Added a way to manually disable move semantics: just define macro `BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES`. This can be used to work around [@https://svn.boost.org/trac/boost/ticket/10399 Trac #10399].
|
||||
* It is no longer possible to assign `optional<U>` to `optional<T>` when `U` is not assignable or convertible to `T` ([@https://svn.boost.org/trac/boost/ticket/11087 Trac #11087]).
|
||||
* Value accessors now work correctly on rvalues of `optional<T&>` ([@https://svn.boost.org/trac/boost/ticket/10839 Trac #10839]).
|
||||
* Value accessors now work correctly on rvalues of `optional<T&>` ([@https://svn.boost.org/trac/boost/ticket/10839 Trac #10839]).
|
||||
|
||||
|
||||
[heading Boost Release 1.57]
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Acknowledgements</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../index.html" title="Boost.Optional">
|
||||
<link rel="prev" href="relnotes.html" title="Release Notes">
|
||||
@ -116,7 +116,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Dependencies and Portability</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../index.html" title="Boost.Optional">
|
||||
<link rel="prev" href="reference/header__boost_optional_hpp_.html" title="Header <boost/optional.hpp>">
|
||||
@ -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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Emplace operations in older compilers</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../dependencies_and_portability.html" title="Dependencies and Portability">
|
||||
<link rel="prev" href="../dependencies_and_portability.html" title="Dependencies and Portability">
|
||||
@ -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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Optional Reference Binding</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../dependencies_and_portability.html" title="Dependencies and Portability">
|
||||
<link rel="prev" href="emplace_operations_in_older_compilers.html" title="Emplace operations in older compilers">
|
||||
@ -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">&</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-2016 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>
|
||||
|
@ -422,7 +422,7 @@
|
||||
<span class="identifier">optional</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">T</span><span class="special">>(</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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">T</span><span class="special">>(</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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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>
|
||||
|
@ -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 -></a>
|
||||
</h5>
|
||||
<p>
|
||||
|
@ -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
|
||||
|
@ -55,7 +55,7 @@
|
||||
<p>
|
||||
Also, even though <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></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">
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Quick Start</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../index.html" title="Boost.Optional">
|
||||
<link rel="prev" href="../index.html" title="Boost.Optional">
|
||||
@ -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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Bypassing unnecessary default construction</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../quick_start.html" title="Quick Start">
|
||||
<link rel="prev" href="optional_data_members.html" title="Optional data members">
|
||||
@ -61,7 +61,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Optional automatic variables</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../quick_start.html" title="Quick Start">
|
||||
<link rel="prev" href="../quick_start.html" title="Quick Start">
|
||||
@ -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"><</span><span class="keyword">int</span><span class="special">></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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Optional data members</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../quick_start.html" title="Quick Start">
|
||||
<link rel="prev" href="optional_automatic_variables.html" title="Optional automatic variables">
|
||||
@ -80,7 +80,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -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"><</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">></span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">optionl</span><span class="special"><</span><span class="keyword">int</span><span class="special">></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">&</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"><</span><span class="keyword">int</span><span class="special">></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">&</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"><</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">></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">&</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"><</span><span class="keyword">int</span><span class="special">></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"><</span><span class="keyword">int</span><span class="special">></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"><</span><span class="keyword">int</span><span class="special">></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"><</span><span class="keyword">int</span><span class="special">></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"><</span><span class="keyword">int</span><span class="special">></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">&</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"><</span><span class="keyword">int</span><span class="special">></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">&</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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Storage in containers</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../quick_start.html" title="Quick Start">
|
||||
<link rel="prev" href="bypassing_unnecessary_default_construction.html" title="Bypassing unnecessary default construction">
|
||||
@ -50,7 +50,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Header <boost/optional/bad_optional_access.hpp></title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/reference.html" title="Reference">
|
||||
<link rel="prev" href="../../optional/reference.html" title="Reference">
|
||||
@ -49,7 +49,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Detailed semantics</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../header__boost_optional_bad_optional_access_hpp_.html" title="Header <boost/optional/bad_optional_access.hpp>">
|
||||
<link rel="prev" href="../header__boost_optional_bad_optional_access_hpp_.html" title="Header <boost/optional/bad_optional_access.hpp>">
|
||||
@ -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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Header <boost/optional.hpp></title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/reference.html" title="Reference">
|
||||
<link rel="prev" href="header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html" title="Detailed Semantics - Free Functions">
|
||||
@ -33,7 +33,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Header <boost/optional/optional_fwd.hpp></title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/reference.html" title="Reference">
|
||||
<link rel="prev" href="io_header/io_semantics.html" title="Detailed semantics">
|
||||
@ -52,7 +52,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -433,7 +433,7 @@
|
||||
<span class="identifier">optional</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">T</span><span class="special">>(</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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">T</span><span class="special">>(</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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</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"><</span><span class="identifier">T</span><span class="special">></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"><</span><span class="identifier">T</span><span class="special">></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.
|
||||
|
@ -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"><</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"><</span><span class="identifier">T</span><span class="special">></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"><</span><span class="identifier">T</span><span class="special">></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.
|
||||
|
@ -403,7 +403,7 @@
|
||||
<span class="identifier">optional</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">T</span><span class="special">>(</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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">T</span><span class="special">>(</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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Detailed Semantics - Free Functions</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header <boost/optional/optional.hpp>">
|
||||
<link rel="prev" href="detailed_semantics___optional_references.html" title="Detailed Semantics - Optional References">
|
||||
@ -47,6 +47,19 @@
|
||||
</pre>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
<a name="reference_make_optional_rvalue"></a><div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></span>
|
||||
<span class="identifier">make_optional</span><span class="special">(</span>
|
||||
<span class="identifier">T</span> <span class="special">&&</span>
|
||||
<span class="identifier">v</span> <span class="special">)</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
<span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special"><</span><span class="identifier">T</span><span class="special">>>(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">v</span><span class="special">))</span></code> for the <span class="emphasis"><em>deduced</em></span>
|
||||
type <code class="computeroutput"><span class="identifier">T</span></code> of <code class="computeroutput"><span class="identifier">v</span></code>.
|
||||
</li></ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
@ -73,6 +86,19 @@
|
||||
</pre>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
<a name="reference_make_optional_bool_rvalue"></a><div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></span>
|
||||
<span class="identifier">make_optional</span><span class="special">(</span>
|
||||
<span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="special">&&</span> <span class="identifier">v</span>
|
||||
<span class="special">)</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
<span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special"><</span><span class="identifier">T</span><span class="special">>>(</span><span class="identifier">condition</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(</span><span class="identifier">v</span><span class="special">))</span></code> for the <span class="emphasis"><em>deduced</em></span>
|
||||
type <code class="computeroutput"><span class="identifier">T</span></code> of <code class="computeroutput"><span class="identifier">v</span></code>.
|
||||
</li></ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
@ -153,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"><</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"><</span><span class="identifier">T</span><span class="special">></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"><</span><span class="identifier">T</span><span class="special">></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>
|
||||
@ -453,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.
|
||||
@ -481,7 +507,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Detailed Semantics - Optional References</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header <boost/optional/optional.hpp>">
|
||||
<link rel="prev" href="detailed_semantics___optional_values.html" title="Detailed Semantics - Optional Values">
|
||||
@ -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">
|
||||
@ -407,6 +407,45 @@
|
||||
is ill-formed.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
<a name="reference_optional_ref_map"></a><div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&>::</span><span class="identifier">map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">-></span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput"><span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><span class="keyword">if</span> <span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">);</span> <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">none</span><span class="special">;</span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Remarks:</strong></span> The return type of this function
|
||||
is <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">))></span></code>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
<a name="reference_optional_ref_flat_map"></a><div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&>::</span><span class="identifier">flat_map</span><span class="special">(</span>
|
||||
<span class="identifier">F</span> <span class="identifier">f</span>
|
||||
<span class="special">)</span> <span class="keyword">const</span>
|
||||
<span class="special">-></span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput"><span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Requires:</strong></span> The return type of expression
|
||||
<code class="computeroutput"><span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">)</span></code>
|
||||
is <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code>
|
||||
for some object or reference type <code class="computeroutput"><span class="identifier">U</span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><span class="keyword">if</span> <span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">);</span> <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">none</span><span class="special">;</span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Remarks:</strong></span> The return type of this function
|
||||
is <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
@ -422,6 +461,9 @@
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
<a name="reference_optional_ref_operator_bool"></a><div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">bool</span> <span class="identifier">has_value</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&>::</span><span class="keyword">operator</span> <span class="keyword">bool</span>
|
||||
<span class="special">()</span> <span class="keyword">const</span>
|
||||
<span class="keyword">noexcept</span><span class="special">;</span></code>
|
||||
@ -444,14 +486,9 @@
|
||||
<a name="reference_optional_ref_reset"></a><div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">void</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&>::</span><span class="identifier">reset</span><span class="special">()</span> <span class="keyword">noexcept</span><span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Effects:</strong></span> Use <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span> <span class="special">=</span> <span class="identifier">none</span></code> instead.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Remarks:</strong></span> This function is depprecated.
|
||||
</li>
|
||||
</ul></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
<span class="bold"><strong>Effects:</strong></span> Same as <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span> <span class="special">=</span> <span class="identifier">none</span></code>.
|
||||
</li></ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
@ -465,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"><</span><span class="identifier">R</span><span class="special">>(</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>
|
||||
@ -479,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>
|
||||
@ -495,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"><</span><span class="identifier">R</span><span class="special">>(</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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Detailed Semantics - Optional Values</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header <boost/optional/optional.hpp>">
|
||||
<link rel="prev" href="header_optional_optional_refs.html" title="Optional References">
|
||||
@ -301,7 +301,7 @@
|
||||
<span class="identifier">optional</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">T</span><span class="special">>(</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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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"><</span><span class="identifier">T</span><span class="special">>(</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"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">unique_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></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">
|
||||
@ -1199,8 +1199,8 @@
|
||||
<span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
<span class="bold"><strong>Deprecated:</strong></span> Same as <code class="computeroutput"><span class="keyword">operator</span><span class="special">=(</span>
|
||||
<span class="identifier">none_t</span> <span class="special">);</span></code>
|
||||
<span class="bold"><strong>Effects:</strong></span> Same as <code class="computeroutput"><span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">none_t</span>
|
||||
<span class="special">);</span></code>
|
||||
</li></ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
@ -1471,6 +1471,126 @@
|
||||
ref-qualifiers on member functions this overload is not present.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
<a name="reference_optional_map"></a><div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">-></span>
|
||||
</code><span class="emphasis"><em>see below</em></span><code class="computeroutput"> <span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">&</span> <span class="special">-></span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput">
|
||||
<span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
|
||||
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">);</span> <span class="keyword">else</span> <span class="keyword">return</span>
|
||||
<span class="identifier">none</span><span class="special">;</span></code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Notes:</strong></span> The return type of these overloads
|
||||
is <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">))></span></code>.
|
||||
On compilers that do not support ref-qualifiers on member functions,
|
||||
these two (as well as the next one) overloads are replaced with good
|
||||
old const and non-const overloads.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Example:</strong></span>
|
||||
<pre class="programlisting"><span class="keyword">auto</span> <span class="identifier">length</span> <span class="special">=</span> <span class="special">[](</span><span class="keyword">const</span> <span class="identifier">string</span><span class="special">&</span> <span class="identifier">s</span><span class="special">){</span> <span class="keyword">return</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">};</span>
|
||||
<span class="identifier">optional</span><span class="special"><</span><span class="identifier">string</span><span class="special">></span> <span class="identifier">o1</span> <span class="special">{},</span> <span class="identifier">o2</span> <span class="special">{</span><span class="string">"cat"</span><span class="special">};</span>
|
||||
<span class="identifier">optional</span><span class="special"><</span><span class="identifier">size_t</span><span class="special">></span> <span class="identifier">os1</span> <span class="special">=</span> <span class="identifier">o1</span><span class="special">.</span><span class="identifier">map</span><span class="special">(</span><span class="identifier">length</span><span class="special">),</span> <span class="identifier">os2</span> <span class="special">=</span> <span class="identifier">o2</span><span class="special">.</span><span class="identifier">map</span><span class="special">(</span><span class="identifier">length</span><span class="special">);</span>
|
||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">os1</span> <span class="special">)</span> <span class="special">;</span>
|
||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">os2</span> <span class="special">)</span> <span class="special">;</span>
|
||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">os2</span> <span class="special">==</span> <span class="number">3</span> <span class="special">)</span> <span class="special">;</span>
|
||||
</pre>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
<a name="reference_optional_map_move"></a><div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">&&</span>
|
||||
<span class="special">-></span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput">
|
||||
<span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
|
||||
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(**</span><span class="keyword">this</span><span class="special">));</span> <span class="keyword">else</span> <span class="keyword">return</span>
|
||||
<span class="identifier">none</span><span class="special">;</span></code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Notes:</strong></span> The return type of this overload
|
||||
is <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="identifier">istd</span><span class="special">::</span><span class="identifier">move</span><span class="special">(**</span><span class="keyword">this</span><span class="special">)))></span></code>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
<a name="reference_optional_flat_map"></a><div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">flat_map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">-></span>
|
||||
</code><span class="emphasis"><em>see below</em></span><code class="computeroutput"> <span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">flat_map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">&</span> <span class="special">-></span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput">
|
||||
<span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Requires:</strong></span> The return type of expression
|
||||
<code class="computeroutput"><span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">)</span></code>
|
||||
is <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code>
|
||||
for some object or reference type <code class="computeroutput"><span class="identifier">U</span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
|
||||
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(**</span><span class="keyword">this</span><span class="special">);</span> <span class="keyword">else</span> <span class="keyword">return</span>
|
||||
<span class="identifier">none</span><span class="special">;</span></code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Notes:</strong></span> The return type of these overloads
|
||||
is <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code>.
|
||||
On compilers that do not support ref-qualifiers on member functions,
|
||||
these two (as well as the next one) overloads are replaced with good
|
||||
old const and non-const overloads.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Example:</strong></span>
|
||||
<pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">char</span><span class="special">></span> <span class="identifier">first_char</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">string</span><span class="special">&</span> <span class="identifier">s</span><span class="special">)</span> <span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">?</span> <span class="identifier">none</span> <span class="special">:</span> <span class="identifier">optional</span><span class="special"><</span><span class="keyword">char</span><span class="special">>(</span><span class="identifier">s</span><span class="special">[</span><span class="number">0</span><span class="special">]);</span>
|
||||
<span class="special">};</span>
|
||||
<span class="identifier">optional</span><span class="special"><</span><span class="identifier">string</span><span class="special">></span> <span class="identifier">o1</span> <span class="special">{},</span> <span class="identifier">o2</span> <span class="special">{</span><span class="string">"cat"</span><span class="special">};</span>
|
||||
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">char</span><span class="special">></span> <span class="identifier">os1</span> <span class="special">=</span> <span class="identifier">o1</span><span class="special">.</span><span class="identifier">flat_map</span><span class="special">(</span><span class="identifier">first_char</span><span class="special">),</span> <span class="identifier">os2</span> <span class="special">=</span> <span class="identifier">o2</span><span class="special">.</span><span class="identifier">flat_map</span><span class="special">(</span><span class="identifier">first_char</span><span class="special">);</span>
|
||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">os1</span> <span class="special">)</span> <span class="special">;</span>
|
||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">os2</span> <span class="special">)</span> <span class="special">;</span>
|
||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">os2</span> <span class="special">==</span> <span class="char">'c'</span> <span class="special">)</span> <span class="special">;</span>
|
||||
</pre>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</li>
|
||||
</ul></div>
|
||||
<a name="reference_optional_flat_map_move"></a><div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">flat_map</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">&&</span>
|
||||
<span class="special">-></span> </code><span class="emphasis"><em>see below</em></span><code class="computeroutput">
|
||||
<span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Requires:</strong></span> The return type of expression
|
||||
<code class="computeroutput"><span class="identifier">f</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(**</span><span class="keyword">this</span><span class="special">))</span></code>
|
||||
is <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code>
|
||||
for some object or reference type <code class="computeroutput"><span class="identifier">U</span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
|
||||
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(**</span><span class="keyword">this</span><span class="special">));</span> <span class="keyword">else</span> <span class="keyword">return</span>
|
||||
<span class="identifier">none</span><span class="special">;</span></code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Notes:</strong></span> The return type of this overload
|
||||
is <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
<span class="inlinemediaobject"><img src="../../../images/space.png" alt="space"></span>
|
||||
</p>
|
||||
@ -1592,6 +1712,9 @@
|
||||
<span class="keyword">const</span> <span class="keyword">noexcept</span>
|
||||
<span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="blockquote"><blockquote class="blockquote"><p>
|
||||
<code class="computeroutput"><span class="keyword">bool</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">has_value</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span></code>
|
||||
</p></blockquote></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="identifier">get_ptr</span><span class="special">()</span> <span class="special">!=</span> <span class="number">0</span></code>.
|
||||
@ -1651,7 +1774,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Initialization tags</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header <boost/optional/optional.hpp>">
|
||||
<link rel="prev" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header <boost/optional/optional.hpp>">
|
||||
@ -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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Optional References</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header <boost/optional/optional.hpp>">
|
||||
<link rel="prev" href="header_optional_optional_values.html" title="Optional Values">
|
||||
@ -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"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></span> <span class="comment">// specilization for lvalue references</span>
|
||||
<span class="keyword">class</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></span> <span class="comment">// specialization for lvalue references</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span> <span class="special">:</span>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
|
||||
<span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">none_t</span> <span class="special">)</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_assign_none_t"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
|
||||
<span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_copy_assign"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span> <span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">&></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_assign_optional_U"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
@ -73,17 +72,22 @@
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">value_or_eval</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_value_or_eval"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">-></span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">flat_map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">-></span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_flat_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="identifier">T</span><span class="special">*</span> <span class="identifier">get_ptr</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_get_ptr"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">bool</span> <span class="identifier">has_value</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_operator_bool"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">explicit</span> <span class="keyword">operator</span> <span class="keyword">bool</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_operator_bool"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_operator_not"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="comment">// deprecated methods</span>
|
||||
|
||||
<span class="comment">// (deprecated)</span>
|
||||
<span class="keyword">void</span> <span class="identifier">reset</span><span class="special">()</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_reset"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="comment">// deprecated methods</span>
|
||||
|
||||
<span class="comment">// (deprecated)</span>
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">R</span><span class="special">></span> <span class="keyword">void</span> <span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">R</span> <span class="special">&&</span> <span class="identifier">r</span> <span class="special">)</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_references.html#reference_optional_ref_reset_value"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
@ -100,7 +104,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Optional Values</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../../optional/reference/header__boost_optional_optional_hpp_.html" title="Header <boost/optional/optional.hpp>">
|
||||
<link rel="prev" href="header_optional_in_place_init.html" title="Initialization tags">
|
||||
@ -105,18 +105,27 @@
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="identifier">T</span> <span class="identifier">value_or_eval</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_value_or_call"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="identifier">T</span> <span class="identifier">value_or_eval</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">&&</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_value_or_call_move"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">-></span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">&</span> <span class="special">-></span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">&&</span> <span class="special">-></span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_map_move"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">flat_map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">-></span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_flat_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">flat_map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">&</span> <span class="special">-></span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_flat_map"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> <span class="keyword">auto</span> <span class="identifier">flat_map</span><span class="special">(</span> <span class="identifier">F</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">&&</span> <span class="special">-></span> <span class="emphasis"><em>see below</em></span><span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_flat_map_move"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">get_ptr</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
<span class="identifier">T</span><span class="special">*</span> <span class="identifier">get_ptr</span><span class="special">()</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">bool</span> <span class="identifier">has_value</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_operator_bool"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">explicit</span> <span class="keyword">operator</span> <span class="keyword">bool</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_operator_bool"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_operator_not"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="comment">// deprecated methods</span>
|
||||
|
||||
<span class="comment">// (deprecated)</span>
|
||||
<span class="keyword">void</span> <span class="identifier">reset</span><span class="special">()</span> <span class="keyword">noexcept</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_reset"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="comment">// deprecated methods</span>
|
||||
|
||||
<span class="comment">// (deprecated)</span>
|
||||
<span class="keyword">void</span> <span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics___optional_values.html#reference_optional_reset_value"><span class="inlinemediaobject"><img src="../../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
@ -130,7 +139,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Header <boost/optional/optional_io.hpp></title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/reference.html" title="Reference">
|
||||
<link rel="prev" href="header__boost_optional_bad_optional_access_hpp_/detailed_semantics.html" title="Detailed semantics">
|
||||
@ -58,7 +58,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Detailed semantics</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../io_header.html" title="Header <boost/optional/optional_io.hpp>">
|
||||
<link rel="prev" href="../io_header.html" title="Header <boost/optional/optional_io.hpp>">
|
||||
@ -32,7 +32,7 @@
|
||||
<span class="special"><</span><span class="keyword">class</span>
|
||||
<span class="identifier">CharType</span><span class="special">,</span>
|
||||
<span class="keyword">class</span> <span class="identifier">CharTrait</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span></code>
|
||||
<br>     <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span></code> <br>     <code class="computeroutput"><span class="keyword">operator</span><span class="special"><<(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span>
|
||||
<br> <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span></code> <br> <code class="computeroutput"><span class="keyword">operator</span><span class="special"><<(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span>
|
||||
<span class="identifier">out</span><span class="special">,</span>
|
||||
<span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span><span class="special">);</span></code>
|
||||
</p>
|
||||
@ -53,8 +53,8 @@
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">CharType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">CharTrait</span><span class="special">,</span>
|
||||
<span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span></code> <br>     <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span></code>
|
||||
<br>     <code class="computeroutput"><span class="keyword">operator</span><span class="special"><<(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span> <span class="identifier">out</span><span class="special">,</span> <span class="identifier">none_t</span><span class="special">);</span></code>
|
||||
<span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span></code> <br> <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span></code>
|
||||
<br> <code class="computeroutput"><span class="keyword">operator</span><span class="special"><<(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span> <span class="identifier">out</span><span class="special">,</span> <span class="identifier">none_t</span><span class="special">);</span></code>
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
@ -70,8 +70,8 @@
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">CharType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">CharTrait</span><span class="special">,</span>
|
||||
<span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span></code> <br>     <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span></code>
|
||||
<br>     <code class="computeroutput"><span class="keyword">operator</span><span class="special">>>(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_istream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span> <span class="identifier">in</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>&</span> <span class="identifier">v</span><span class="special">);</span></code>
|
||||
<span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span></code> <br> <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_ostream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span></code>
|
||||
<br> <code class="computeroutput"><span class="keyword">operator</span><span class="special">>>(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_istream</span><span class="special"><</span><span class="identifier">CharType</span><span class="special">,</span> <span class="identifier">CharTrait</span><span class="special">>&</span> <span class="identifier">in</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>&</span> <span class="identifier">v</span><span class="special">);</span></code>
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
@ -98,7 +98,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Release Notes</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../index.html" title="Boost.Optional">
|
||||
<link rel="prev" href="dependencies_and_portability/optional_reference_binding.html" title="Optional Reference Binding">
|
||||
@ -28,6 +28,146 @@
|
||||
</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>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code> is <code class="computeroutput"><span class="keyword">constexpr</span></code>-declared.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Fixed <a href="https://github.com/boostorg/optional/issues/78" target="_top">issue
|
||||
#78</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.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>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
Fixed <a href="https://github.com/boostorg/optional/issues/78" target="_top">issue
|
||||
#78</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code> is now declared as an inline variable
|
||||
(on compilers that support it): there is only one instance of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code> across all translation units.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Fixed a number of compilation errors in GCC 4.4.7 in <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> for trivial <code class="computeroutput"><span class="identifier">T</span></code>s.
|
||||
Thanks to Robert Leahy for the fix. For details see <a href="https://github.com/boostorg/optional/pull/80" target="_top">pr
|
||||
#78</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Now 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.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>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
Remove deprecation mark from <code class="computeroutput"><span class="identifier">reset</span><span class="special">()</span></code> method (without arguments).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Fixed <a href="https://github.com/boostorg/optional/issues/59" target="_top">issue
|
||||
#59</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Fixed bug with initialization of certain wrapper types in clang with -std=c++03.
|
||||
See <a href="https://github.com/boostorg/optional/pull/64" target="_top">pr #64</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.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>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
Added member function <code class="computeroutput"><span class="identifier">has_value</span><span class="special">()</span></code> for compatibility with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">optional</span></code> (<a href="https://github.com/boostorg/optional/issues/52" target="_top">issue
|
||||
#52</a>).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Added member function <code class="computeroutput"><span class="identifier">map</span><span class="special">()</span></code> for transforming <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> into <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code> using a function of type <code class="computeroutput"><span class="identifier">T</span> <span class="special">-></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"><</span><span class="identifier">T</span><span class="special">></span></code> into <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code> using a function of type <code class="computeroutput"><span class="identifier">T</span> <span class="special">-></span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<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>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
Fixed <a href="https://github.com/boostorg/optional/issues/46" target="_top">issue
|
||||
#46</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Fixed <code class="computeroutput"><span class="special">-</span><span class="identifier">Wzero</span><span class="special">-</span><span class="identifier">as</span><span class="special">-</span><span class="identifier">null</span><span class="special">-</span><span class="identifier">pointer</span><span class="special">-</span><span class="identifier">constant</span></code> warnings.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.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>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
On newer compilers <code class="computeroutput"><span class="identifier">optional</span></code>
|
||||
is now trivially-copyable for scalar <code class="computeroutput"><span class="identifier">T</span></code>s.
|
||||
This uses a different storage (just <code class="computeroutput"><span class="identifier">T</span></code>
|
||||
rather than <code class="computeroutput"><span class="identifier">aligned_storage</span></code>).
|
||||
We require the compiler to support defaulted functions.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Changed the implementation of <code class="computeroutput"><span class="keyword">operator</span><span class="special">==</span></code> to get rid of the <code class="computeroutput"><span class="special">-</span><span class="identifier">Wmaybe</span><span class="special">-</span><span class="identifier">uninitialized</span></code> false-positive warning
|
||||
from GCC.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.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>
|
||||
@ -51,7 +191,7 @@
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h1"></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>
|
||||
@ -59,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.h2"></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>
|
||||
@ -80,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">
|
||||
@ -102,7 +242,7 @@
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h3"></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>
|
||||
@ -113,7 +253,7 @@
|
||||
#11203</a>.
|
||||
</li></ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h4"></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>
|
||||
@ -127,7 +267,7 @@
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h5"></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>
|
||||
@ -163,7 +303,7 @@
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h6"></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>
|
||||
@ -173,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.h7"></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>
|
||||
@ -230,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-2016 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>
|
||||
|
@ -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 -></a>
|
||||
</h6>
|
||||
<p>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Design Overview</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
|
||||
<link rel="prev" href="../../optional/tutorial.html" title="Tutorial">
|
||||
@ -65,8 +65,8 @@
|
||||
<code class="computeroutput"><span class="identifier">npos</span></code>, -1, etc... This is
|
||||
equivalent to adding the special value to the set of possible values of
|
||||
a given type. This super set of <code class="computeroutput"><span class="identifier">T</span></code>
|
||||
plus some <span class="emphasis"><em>nil_t</em></span>—where <code class="computeroutput"><span class="identifier">nil_t</span></code>
|
||||
is some stateless POD—can be modeled in modern languages as a <span class="bold"><strong>discriminated union</strong></span> of T and nil_t. Discriminated
|
||||
plus some <span class="emphasis"><em>nil_t</em></span>—where <code class="computeroutput"><span class="identifier">nil_t</span></code>
|
||||
is some stateless POD—can be modeled in modern languages as a <span class="bold"><strong>discriminated union</strong></span> of T and nil_t. Discriminated
|
||||
unions are often called <span class="emphasis"><em>variants</em></span>. A variant has a
|
||||
<span class="emphasis"><em>current type</em></span>, which in our case is either <code class="computeroutput"><span class="identifier">T</span></code> or <code class="computeroutput"><span class="identifier">nil_t</span></code>.
|
||||
Using the <a href="../../../../../variant/index.html" target="_top">Boost.Variant</a>
|
||||
@ -100,8 +100,8 @@
|
||||
</p>
|
||||
<p>
|
||||
In any event, both the discriminated-union or the single-element container
|
||||
models serve as a conceptual ground for a class representing optional—i.e.
|
||||
possibly uninitialized—objects. For instance, these models show the
|
||||
models serve as a conceptual ground for a class representing optional—i.e.
|
||||
possibly uninitialized—objects. For instance, these models show the
|
||||
<span class="emphasis"><em>exact</em></span> semantics required for a wrapper of optional
|
||||
values:
|
||||
</p>
|
||||
@ -170,7 +170,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>The Interface</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../design_overview.html" title="Design Overview">
|
||||
<link rel="prev" href="the_semantics.html" title="The semantics">
|
||||
@ -79,7 +79,7 @@
|
||||
facto</em></span> standard for handling optional objects because all you
|
||||
have to do to refer to a value which you don't really have is to use a
|
||||
null pointer value of the appropriate type. Pointers have been used for
|
||||
decades—from the days of C APIs to modern C++ libraries—to <span class="emphasis"><em>refer</em></span>
|
||||
decades—from the days of C APIs to modern C++ libraries—to <span class="emphasis"><em>refer</em></span>
|
||||
to optional (that is, possibly nonexistent) objects; particularly as optional
|
||||
arguments to a function, but also quite often as optional data members.
|
||||
</p>
|
||||
@ -93,7 +93,7 @@
|
||||
and this information is tied to the <span class="emphasis"><em>syntax</em></span> of the
|
||||
expressions. That is, the presence of operators <code class="computeroutput"><span class="special">*</span></code>
|
||||
and <code class="computeroutput"><span class="special">-></span></code> tell by themselves
|
||||
—without any additional context— that the expression will be undefined
|
||||
—without any additional context— that the expression will be undefined
|
||||
unless the implied pointee actually exist.
|
||||
</p>
|
||||
<p>
|
||||
@ -173,7 +173,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>The semantics</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../design_overview.html" title="Design Overview">
|
||||
<link rel="prev" href="../design_overview.html" title="Design Overview">
|
||||
@ -107,7 +107,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Exception Safety Guarantees</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
|
||||
<link rel="prev" href="gotchas/false_positive_with__wmaybe_uninitialized.html" title="False positive with -Wmaybe-uninitialized">
|
||||
@ -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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Gotchas</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
|
||||
<link rel="prev" href="in_place_factories.html" title="In-Place Factories">
|
||||
@ -37,7 +37,7 @@
|
||||
</p>
|
||||
<p>
|
||||
First, it is functionally similar to a tristate boolean (false, maybe,
|
||||
true) —such as <a href="../../../../../../doc/html/tribool.html" target="_top">boost::tribool</a>—
|
||||
true) —such as <a href="../../../../../../doc/html/tribool.html" target="_top">boost::tribool</a>—
|
||||
except that in a tristate boolean, the maybe state <span class="underline">represents
|
||||
a valid value</span>, unlike the corresponding state of an uninitialized
|
||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">bool</span><span class="special">></span></code>.
|
||||
@ -98,7 +98,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>False positive with -Wmaybe-uninitialized</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../gotchas.html" title="Gotchas">
|
||||
<link rel="prev" href="mixed_relational_comparisons.html" title="Mixed relational comparisons">
|
||||
@ -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"><</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">></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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Mixed relational comparisons</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../gotchas.html" title="Gotchas">
|
||||
<link rel="prev" href="moved_from__optional_.html" title="Moved-from optional">
|
||||
@ -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"><</span><span class="identifier">T</span><span class="special">></span></code>
|
||||
and because <code class="computeroutput"><span class="identifier">opiotnal</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>
|
||||
and because <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Moved-from optional</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../gotchas.html" title="Gotchas">
|
||||
<link rel="prev" href="../gotchas.html" title="Gotchas">
|
||||
@ -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"><</span><span class="identifier">T</span><span class="special">></span></code>
|
||||
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>In-Place Factories</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
|
||||
<link rel="prev" href="optional_references/rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references">
|
||||
@ -183,7 +183,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>IO operators</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
|
||||
<link rel="prev" href="relational_operators.html" title="Relational operators">
|
||||
@ -73,7 +73,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Optional references</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
|
||||
<link rel="prev" href="io_operators.html" title="IO operators">
|
||||
@ -59,7 +59,7 @@
|
||||
<p>
|
||||
Also, even though <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Rebinding semantics for assignment of optional references</title>
|
||||
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../optional_references.html" title="Optional references">
|
||||
<link rel="prev" href="../optional_references.html" title="Optional references">
|
||||
@ -133,7 +133,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Performance considerations</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
|
||||
<link rel="prev" href="type_requirements.html" title="Type requirements">
|
||||
@ -29,7 +29,8 @@
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Technical details aside, the memory layout of <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>
|
||||
is more-less this:
|
||||
for a generic <code class="computeroutput"><span class="identifier">T</span></code> is more-less
|
||||
this:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">optional</span>
|
||||
@ -39,8 +40,49 @@
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
But for the purpose of this analysis, considering memory layouts, we can
|
||||
think of it as:
|
||||
Lifetime of the <code class="computeroutput"><span class="identifier">T</span></code> inside
|
||||
<code class="computeroutput"><span class="identifier">_storage</span></code> is manually controlled
|
||||
with placement-<code class="computeroutput"><span class="keyword">new</span></code>s and pseudo-destructor
|
||||
calls. However, for scalar <code class="computeroutput"><span class="identifier">T</span></code>s
|
||||
we use a different way of storage, by simply holding a <code class="computeroutput"><span class="identifier">T</span></code>:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">optional</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">bool</span> <span class="identifier">_initialized</span><span class="special">;</span>
|
||||
<span class="identifier">T</span> <span class="identifier">_storage</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
We call it a <span class="emphasis"><em>direct</em></span> storage. This makes <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> a
|
||||
trivially-copyable type for scalar <code class="computeroutput"><span class="identifier">T</span></code>s.
|
||||
This only works for compilers that support defaulted functions (including
|
||||
defaulted move assignment and constructor). On compilers without defaulted
|
||||
functions we still use the direct storage, but <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></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 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">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>
|
||||
<span class="identifier">X</span><span class="special">()</span> <span class="special">{}</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">optional_config</span> <span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><></span> <span class="keyword">struct</span> <span class="identifier">optional_uses_direct_storage_for</span><span class="special"><</span><span class="identifier">X</span><span class="special">></span> <span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">true_type</span> <span class="special">{};</span>
|
||||
|
||||
<span class="special">}}</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="boost_optional.tutorial.performance_considerations.h0"></a>
|
||||
<span class="phrase"><a name="boost_optional.tutorial.performance_considerations.controlling_the_size"></a></span><a class="link" href="performance_considerations.html#boost_optional.tutorial.performance_considerations.controlling_the_size">Controlling
|
||||
the size</a>
|
||||
</h5>
|
||||
<p>
|
||||
For the purpose of the following analysis, considering memory layouts, we
|
||||
can think of it as:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">optional</span>
|
||||
@ -123,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>
|
||||
@ -143,7 +185,7 @@
|
||||
<span class="inlinemediaobject"><img src="../../images/opt_align4.png" alt="opt_align4"></span>
|
||||
</p>
|
||||
<h5>
|
||||
<a name="boost_optional.tutorial.performance_considerations.h0"></a>
|
||||
<a name="boost_optional.tutorial.performance_considerations.h1"></a>
|
||||
<span class="phrase"><a name="boost_optional.tutorial.performance_considerations.optional_function_parameters"></a></span><a class="link" href="performance_considerations.html#boost_optional.tutorial.performance_considerations.optional_function_parameters">Optional
|
||||
function parameters</a>
|
||||
</h5>
|
||||
@ -209,7 +251,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Relational operators</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
|
||||
<link rel="prev" href="when_to_use_optional.html" title="When to use Optional">
|
||||
@ -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"><</span><span class="identifier">T</span><span class="special">></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"><</span><span class="identifier">T</span><span class="special">></span></code>:
|
||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></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-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Type requirements</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
|
||||
<link rel="prev" href="exception_safety_guarantees.html" title="Exception Safety Guarantees">
|
||||
@ -95,7 +95,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>When to use Optional</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../../optional/tutorial.html" title="Tutorial">
|
||||
<link rel="prev" href="design_overview/the_interface.html" title="The Interface">
|
||||
@ -128,7 +128,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Boost.Optional</title>
|
||||
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="index.html" title="Boost.Optional">
|
||||
<link rel="next" href="boost_optional/quick_start.html" title="Quick Start">
|
||||
</head>
|
||||
@ -25,8 +25,8 @@
|
||||
<div><div class="author"><h3 class="author">
|
||||
<span class="firstname">Fernando Luis</span> <span class="surname">Cacciola Carballal</span>
|
||||
</h3></div></div>
|
||||
<div><p class="copyright">Copyright © 2003-2007 Fernando Luis Cacciola Carballal</p></div>
|
||||
<div><p class="copyright">Copyright © 2014-2016 Andrzej Krzemieński</p></div>
|
||||
<div><p class="copyright">Copyright © 2003-2007 Fernando Luis Cacciola Carballal</p></div>
|
||||
<div><p class="copyright">Copyright © 2014-2021 Andrzej Krzemieński</p></div>
|
||||
<div><div class="legalnotice">
|
||||
<a name="optional.legal"></a><p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
@ -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: March 22, 2017 at 21:55:47 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Reference</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../index.html" title="Boost.Optional">
|
||||
<link rel="prev" href="../boost_optional/tutorial/performance_considerations.html" title="Performance considerations">
|
||||
@ -54,7 +54,7 @@
|
||||
|
||||
<span class="keyword">class</span> <span class="identifier">none_t</span> <span class="special">{/*</span> <span class="identifier">see</span> <span class="identifier">below</span> <span class="special">*/};</span>
|
||||
|
||||
<span class="keyword">const</span> <span class="identifier">none_t</span> <span class="identifier">none</span> <span class="special">(/*</span> <span class="identifier">see</span> <span class="identifier">below</span> <span class="special">*/);</span>
|
||||
<span class="keyword">inline</span> <span class="keyword">constexpr</span> <span class="identifier">none_t</span> <span class="identifier">none</span> <span class="special">(/*</span> <span class="identifier">see</span> <span class="identifier">below</span> <span class="special">*/);</span>
|
||||
|
||||
<span class="special">}</span> <span class="comment">// namespace boost</span>
|
||||
</pre>
|
||||
@ -75,7 +75,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Header <boost/optional/optional.hpp></title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../reference.html" title="Reference">
|
||||
<link rel="prev" href="../../boost_optional/reference/header__boost_optional_optional_fwd_hpp_.html" title="Header <boost/optional/optional_fwd.hpp>">
|
||||
@ -65,8 +65,12 @@
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_make_optional_value"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="special">&&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_make_optional_rvalue"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_make_optional_bool_value"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">decay_t</span><span class="special"><</span><span class="identifier">T</span><span class="special">>></span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="special">&&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_make_optional_bool_rvalue"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">auto</span> <span class="identifier">get_optional_value_or</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">opt</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">reference_const_type</span> <span class="identifier">def</span> <span class="special">)</span> <span class="special">-></span> <span class="keyword">typename</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">reference_const_type</span><span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_free_get_value_or"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
|
||||
|
||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">auto</span> <span class="identifier">get_optional_value_or</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">opt</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">reference_type</span> <span class="identifier">def</span> <span class="special">)</span> <span class="special">-></span> <span class="keyword">typename</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">reference_type</span> <span class="special">;</span> <a class="link" href="../../boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html#reference_free_get_value_or"><span class="inlinemediaobject"><img src="../../images/callouts/R.png" alt="R"></span></a>
|
||||
@ -93,7 +97,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Tutorial</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
|
||||
<link rel="home" href="../index.html" title="Boost.Optional">
|
||||
<link rel="up" href="../index.html" title="Boost.Optional">
|
||||
<link rel="prev" href="../boost_optional/quick_start/storage_in_containers.html" title="Storage in containers">
|
||||
@ -139,7 +139,7 @@
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<br>Copyright © 2014-2016 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>
|
||||
|
@ -13,6 +13,7 @@
|
||||
#ifndef BOOST_NONE_17SEP2003_HPP
|
||||
#define BOOST_NONE_17SEP2003_HPP
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/none_t.hpp"
|
||||
|
||||
// NOTE: Borland users have to include this header outside any precompiled headers
|
||||
@ -23,7 +24,7 @@ namespace boost {
|
||||
|
||||
#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
|
||||
|
||||
none_t const none = (static_cast<none_t>(0)) ;
|
||||
BOOST_INLINE_VARIABLE none_t BOOST_CONSTEXPR_OR_CONST none = (static_cast<none_t>(0)) ;
|
||||
|
||||
#elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE
|
||||
|
||||
@ -35,7 +36,7 @@ namespace detail { namespace optional_detail {
|
||||
{
|
||||
static const T instance;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
const T none_instance<T>::instance = T(); // global, but because 'tis a template, no cpp file required
|
||||
|
||||
@ -44,16 +45,15 @@ namespace detail { namespace optional_detail {
|
||||
|
||||
namespace {
|
||||
// TU-local
|
||||
const none_t& none = detail::optional_detail::none_instance<none_t>::instance;
|
||||
const none_t& none = detail::optional_detail::none_instance<none_t>::instance;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
const none_t none ((none_t::init_tag()));
|
||||
BOOST_INLINE_VARIABLE BOOST_CONSTEXPR_OR_CONST none_t none ((none_t::init_tag()));
|
||||
|
||||
#endif // older definitions
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // header guard
|
||||
|
||||
|
@ -13,6 +13,16 @@
|
||||
#ifndef BOOST_NONE_T_17SEP2003_HPP
|
||||
#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 {
|
||||
|
||||
#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
|
||||
@ -29,7 +39,7 @@ class none_t {};
|
||||
struct none_t
|
||||
{
|
||||
struct init_tag{};
|
||||
explicit none_t(init_tag){} // to disable default constructor
|
||||
explicit BOOST_CONSTEXPR none_t(init_tag){} // to disable default constructor
|
||||
};
|
||||
|
||||
#endif // old implementation workarounds
|
||||
|
@ -19,6 +19,11 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
#endif
|
||||
|
||||
class bad_optional_access : public std::logic_error
|
||||
{
|
||||
public:
|
||||
@ -27,6 +32,10 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
104
include/boost/optional/detail/experimental_traits.hpp
Normal file
104
include/boost/optional/detail/experimental_traits.hpp
Normal file
@ -0,0 +1,104 @@
|
||||
// Copyright (C) 2017 Andrzej Krzemienski.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// akrzemi1@gmail.com
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP
|
||||
#define BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/predef.h>
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
// The condition to use POD implementation
|
||||
|
||||
#ifdef BOOST_OPTIONAL_CONFIG_NO_POD_SPEC
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
#elif defined BOOST_OPTIONAL_CONFIG_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
#elif !defined BOOST_HAS_TRIVIAL_CONSTRUCTOR
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
#elif !defined BOOST_HAS_TRIVIAL_MOVE_ASSIGN
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
#elif !defined BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
#elif !defined BOOST_HAS_TRIVIAL_COPY
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
#elif !defined BOOST_HAS_TRIVIAL_ASSIGN
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
#elif !defined BOOST_HAS_TRIVIAL_DESTRUCTOR
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
#elif BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
#endif
|
||||
|
||||
// GCC 5 or higher, or clang with libc++ or clang with libstdc++ 5 or higher
|
||||
#if __cplusplus >= 201103L
|
||||
# if BOOST_WORKAROUND(BOOST_GCC, >= 50000)
|
||||
# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
|
||||
# elif (defined BOOST_CLANG)
|
||||
# if BOOST_LIB_STD_CXX > 0
|
||||
# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
|
||||
# elif BOOST_LIB_STD_GNU >= 441200023 && BOOST_LIB_STD_GNU != 450600023 && BOOST_LIB_STD_GNU != 450600026 && BOOST_LIB_STD_GNU != 460800003 && BOOST_LIB_STD_GNU != 450400026 && BOOST_LIB_STD_GNU != 460700026
|
||||
# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
|
||||
# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) BOOST_HAS_TRIVIAL_CONSTRUCTOR(T)
|
||||
#else
|
||||
# include <type_traits>
|
||||
# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) std::is_trivially_default_constructible<T>::value
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost { namespace optional_detail {
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
template <typename T>
|
||||
struct is_type_trivially_copyable
|
||||
: boost::conditional<(boost::has_trivial_copy_constructor<T>::value &&
|
||||
boost::has_trivial_move_constructor<T>::value &&
|
||||
boost::has_trivial_destructor<T>::value &&
|
||||
boost::has_trivial_move_assign<T>::value &&
|
||||
boost::has_trivial_assign<T>::value),
|
||||
boost::true_type, boost::false_type>::type
|
||||
{};
|
||||
#else
|
||||
template <typename T>
|
||||
struct is_type_trivially_copyable
|
||||
: boost::conditional<(boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value),
|
||||
boost::true_type, boost::false_type>::type
|
||||
{};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
|
||||
template <typename T>
|
||||
struct optional_uses_direct_storage_for_
|
||||
: boost::conditional< (is_type_trivially_copyable<T>::value && BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T)) ||
|
||||
(boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value)
|
||||
, boost::true_type, boost::false_type>::type
|
||||
{};
|
||||
#else
|
||||
template <typename T>
|
||||
struct optional_uses_direct_storage_for_
|
||||
: boost::conditional<(boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value)
|
||||
, boost::true_type, boost::false_type>::type
|
||||
{};
|
||||
#endif
|
||||
|
||||
|
||||
}} // boost::optional_detail
|
||||
|
||||
#endif
|
@ -14,10 +14,10 @@
|
||||
#define BOOST_OPTIONAL_DETAIL_OLD_OPTIONAL_IMPLEMENTATION_AJK_28JAN2015_HPP
|
||||
|
||||
#include <boost/detail/reference_content.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/core/invoke_swap.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@ -80,7 +80,7 @@ class optional_base : public optional_tag
|
||||
private :
|
||||
|
||||
typedef
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
|
||||
BOOST_DEDUCED_TYPENAME
|
||||
#endif
|
||||
::boost::detail::make_reference_content<T>::type internal_type ;
|
||||
@ -96,13 +96,13 @@ class optional_base : public optional_tag
|
||||
|
||||
typedef T value_type ;
|
||||
|
||||
typedef mpl::true_ is_reference_tag ;
|
||||
typedef mpl::false_ is_not_reference_tag ;
|
||||
typedef true_type is_reference_tag ;
|
||||
typedef false_type is_not_reference_tag ;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME is_reference<T>::type is_reference_predicate ;
|
||||
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME mpl::if_<is_reference_predicate,types_when_ref,types_when_not_ref>::type types ;
|
||||
typedef BOOST_DEDUCED_TYPENAME conditional<is_reference_predicate::value,types_when_ref,types_when_not_ref>::type types ;
|
||||
|
||||
protected:
|
||||
typedef BOOST_DEDUCED_TYPENAME types::reference_type reference_type ;
|
||||
@ -147,7 +147,7 @@ class optional_base : public optional_tag
|
||||
}
|
||||
#endif
|
||||
|
||||
// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialzed optional<T>.
|
||||
// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional<T>.
|
||||
// Can throw if T::T(T const&) does
|
||||
optional_base ( bool cond, argument_type val )
|
||||
:
|
||||
@ -333,11 +333,11 @@ class optional_base : public optional_tag
|
||||
|
||||
public :
|
||||
|
||||
// **DEPPRECATED** Destroys the current value, if any, leaving this UNINITIALIZED
|
||||
// Destroys the current value, if any, leaving this UNINITIALIZED
|
||||
// No-throw (assuming T::~T() doesn't)
|
||||
void reset() BOOST_NOEXCEPT { destroy(); }
|
||||
|
||||
// **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,
|
||||
@ -422,7 +422,7 @@ class optional_base : public optional_tag
|
||||
template<class Expr>
|
||||
void construct ( Expr&& factory, in_place_factory_base const* )
|
||||
{
|
||||
BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ;
|
||||
BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
|
||||
boost_optional_detail::construct<value_type>(factory, m_storage.address());
|
||||
m_initialized = true ;
|
||||
}
|
||||
@ -431,7 +431,7 @@ class optional_base : public optional_tag
|
||||
template<class Expr>
|
||||
void construct ( Expr&& factory, typed_in_place_factory_base const* )
|
||||
{
|
||||
BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ;
|
||||
BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
|
||||
factory.apply(m_storage.address()) ;
|
||||
m_initialized = true ;
|
||||
}
|
||||
@ -456,7 +456,7 @@ class optional_base : public optional_tag
|
||||
template<class Expr>
|
||||
void construct ( Expr const& factory, in_place_factory_base const* )
|
||||
{
|
||||
BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ;
|
||||
BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
|
||||
boost_optional_detail::construct<value_type>(factory, m_storage.address());
|
||||
m_initialized = true ;
|
||||
}
|
||||
@ -465,7 +465,7 @@ class optional_base : public optional_tag
|
||||
template<class Expr>
|
||||
void construct ( Expr const& factory, typed_in_place_factory_base const* )
|
||||
{
|
||||
BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ;
|
||||
BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
|
||||
factory.apply(m_storage.address()) ;
|
||||
m_initialized = true ;
|
||||
}
|
||||
@ -543,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
|
||||
@ -620,7 +620,7 @@ class optional_base : public optional_tag
|
||||
reference_const_type dereference( internal_type const* p, is_reference_tag ) const { return p->get() ; }
|
||||
reference_type dereference( internal_type* p, is_reference_tag ) { return p->get() ; }
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581))
|
||||
void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->internal_type::~internal_type() ; m_initialized = false ; }
|
||||
#else
|
||||
void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->~T() ; m_initialized = false ; }
|
||||
@ -630,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() ; }
|
||||
@ -730,7 +730,7 @@ class optional : public optional_detail::optional_base<T>
|
||||
explicit optional ( Expr&& expr,
|
||||
BOOST_DEDUCED_TYPENAME boost::disable_if_c<
|
||||
(boost::is_base_of<optional_detail::optional_tag, BOOST_DEDUCED_TYPENAME boost::decay<Expr>::type>::value) ||
|
||||
boost::is_same<BOOST_DEDUCED_TYPENAME boost::decay<Expr>::type, none_t>::value >::type* = 0
|
||||
boost::is_same<BOOST_DEDUCED_TYPENAME boost::decay<Expr>::type, none_t>::value, bool >::type = true
|
||||
)
|
||||
: base(boost::forward<Expr>(expr),boost::addressof(expr))
|
||||
{optional_detail::prevent_binding_rvalue_ref_to_optional_lvalue_ref<T, Expr&&>();}
|
||||
@ -746,12 +746,12 @@ class optional : public optional_detail::optional_base<T>
|
||||
optional ( optional const& rhs ) : base( static_cast<base const&>(rhs) ) {}
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
// Creates a deep move of another optional<T>
|
||||
// Can throw if T::T(T&&) does
|
||||
optional ( optional && rhs )
|
||||
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value)
|
||||
: base( boost::move(rhs) )
|
||||
{}
|
||||
// Creates a deep move of another optional<T>
|
||||
// Can throw if T::T(T&&) does
|
||||
optional ( optional && rhs )
|
||||
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value)
|
||||
: base( boost::move(rhs) )
|
||||
{}
|
||||
|
||||
#endif
|
||||
// No-throw (assuming T::~T() doesn't)
|
||||
@ -819,7 +819,7 @@ class optional : public optional_detail::optional_base<T>
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
// Assigns from another optional<T> (deep-moves the rhs value)
|
||||
optional& operator= ( optional && rhs )
|
||||
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
|
||||
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
|
||||
{
|
||||
this->assign( static_cast<base &&>(rhs) ) ;
|
||||
return *this ;
|
||||
@ -892,10 +892,10 @@ class optional : public optional_detail::optional_base<T>
|
||||
#endif
|
||||
|
||||
void swap( optional & arg )
|
||||
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
|
||||
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
|
||||
{
|
||||
// allow for Koenig lookup
|
||||
boost::swap(*this, arg);
|
||||
boost::core::invoke_swap(*this, arg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,14 +25,10 @@ template <class T>
|
||||
class aligned_storage
|
||||
{
|
||||
// Borland ICEs if unnamed unions are used for this!
|
||||
union
|
||||
// This works around GCC warnings about breaking strict aliasing rules when casting storage address to T*
|
||||
#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
|
||||
__attribute__((__may_alias__))
|
||||
#endif
|
||||
dummy_u
|
||||
// BOOST_MAY_ALIAS works around GCC warnings about breaking strict aliasing rules when casting storage address to T*
|
||||
union BOOST_MAY_ALIAS dummy_u
|
||||
{
|
||||
char data[ sizeof(T) ];
|
||||
unsigned char data[ sizeof(T) ];
|
||||
BOOST_DEDUCED_TYPENAME type_with_alignment<
|
||||
::boost::alignment_of<T>::value >::type aligner_;
|
||||
} dummy_ ;
|
||||
@ -48,24 +44,24 @@ class aligned_storage
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
|
||||
// This workaround is supposed to silence GCC warnings about broken strict aliasing rules
|
||||
T const* ptr_ref() const
|
||||
{
|
||||
union { void const* ap_pvoid; T const* as_ptype; } caster = { address() };
|
||||
return caster.as_ptype;
|
||||
}
|
||||
T * ptr_ref()
|
||||
{
|
||||
union { void* ap_pvoid; T* as_ptype; } caster = { address() };
|
||||
return caster.as_ptype;
|
||||
}
|
||||
// This workaround is supposed to silence GCC warnings about broken strict aliasing rules
|
||||
T const* ptr_ref() const
|
||||
{
|
||||
union { void const* ap_pvoid; T const* as_ptype; } caster = { address() };
|
||||
return caster.as_ptype;
|
||||
}
|
||||
T * ptr_ref()
|
||||
{
|
||||
union { void* ap_pvoid; T* as_ptype; } caster = { address() };
|
||||
return caster.as_ptype;
|
||||
}
|
||||
#else
|
||||
T const* ptr_ref() const { return static_cast<T const*>(address()); }
|
||||
T * ptr_ref() { return static_cast<T *> (address()); }
|
||||
T const* ptr_ref() const { return static_cast<T const*>(address()); }
|
||||
T * ptr_ref() { return static_cast<T *> (address()); }
|
||||
#endif
|
||||
|
||||
T const& ref() const { return *ptr_ref(); }
|
||||
T & ref() { return *ptr_ref(); }
|
||||
T const& ref() const { return *ptr_ref(); }
|
||||
T & ref() { return *ptr_ref(); }
|
||||
|
||||
} ;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
|
||||
// Copyright (C) 2015 Andrzej Krzemienski.
|
||||
// Copyright (C) 2015 - 2017 Andrzej Krzemienski.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -28,7 +28,7 @@
|
||||
# define BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551)
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x551)
|
||||
// BCB (5.5.1) cannot parse the nested template struct in an inplace factory.
|
||||
# define BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
|
||||
#endif
|
||||
@ -44,16 +44,16 @@
|
||||
# define BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
|
||||
// GCC since 3.3 has may_alias attribute that helps to alleviate optimizer issues with
|
||||
// regard to violation of the strict aliasing rules. The optional< T > storage type is marked
|
||||
// with this attribute in order to let the compiler know that it will alias objects of type T
|
||||
// and silence compilation warnings.
|
||||
#if !defined(BOOST_NO_MAY_ALIAS)
|
||||
// GCC since 3.3 and some other compilers have may_alias attribute that helps to alleviate
|
||||
// optimizer issues with regard to violation of the strict aliasing rules. The optional< T >
|
||||
// storage type is marked with this attribute in order to let the compiler know that it will
|
||||
// alias objects of type T and silence compilation warnings.
|
||||
# define BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS
|
||||
#endif
|
||||
|
||||
#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
|
||||
@ -113,4 +113,23 @@
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS
|
||||
#endif
|
||||
|
||||
|
||||
// Detect support for defaulting move operations
|
||||
// (some older compilers implement rvalue references,
|
||||
// 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
|
||||
#elif BOOST_WORKAROUND(BOOST_MSVC, < 1900)
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
|
||||
#elif BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40600)
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BOOST_OPTIONAL_CONFIG_NO_DIRECT_STORAGE_SPEC
|
||||
# define BOOST_OPTIONAL_DETAIL_NO_DIRECT_STORAGE_SPEC
|
||||
#endif
|
||||
|
||||
|
||||
#endif // header guard
|
||||
|
49
include/boost/optional/detail/optional_hash.hpp
Normal file
49
include/boost/optional/detail/optional_hash.hpp
Normal 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
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2015-2016 Andrzej Krzemienski.
|
||||
// Copyright (C) 2015-2018 Andrzej Krzemienski.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -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,13 +130,13 @@ 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>::type* = 0) BOOST_NOEXCEPT
|
||||
explicit optional(U& rhs, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::is_same_decayed<T, U>::value && detail::is_const_integral_bad_for_conversion<U>::value, bool>::type = true) BOOST_NOEXCEPT
|
||||
: ptr_(boost::addressof(rhs)) {}
|
||||
|
||||
template <class U>
|
||||
optional(U& rhs, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::is_same_decayed<T, U>::value && !detail::is_const_integral_bad_for_conversion<U>::value>::type* = 0) BOOST_NOEXCEPT
|
||||
optional(U& rhs, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::is_same_decayed<T, U>::value && !detail::is_const_integral_bad_for_conversion<U>::value, bool>::type = true) BOOST_NOEXCEPT
|
||||
: ptr_(boost::addressof(rhs)) {}
|
||||
|
||||
optional& operator=(const optional& rhs) BOOST_NOEXCEPT { ptr_ = rhs.get_ptr(); return *this; }
|
||||
@ -151,7 +151,14 @@ public:
|
||||
T* get_ptr() const BOOST_NOEXCEPT { return ptr_; }
|
||||
T* operator->() const { BOOST_ASSERT(ptr_); return ptr_; }
|
||||
T& operator*() const { BOOST_ASSERT(ptr_); return *ptr_; }
|
||||
T& value() const { return ptr_ ? *ptr_ : (throw_exception(bad_optional_access()), *ptr_); }
|
||||
|
||||
T& value() const
|
||||
{
|
||||
if (this->is_initialized())
|
||||
return this->get();
|
||||
else
|
||||
throw_exception(bad_optional_access());
|
||||
}
|
||||
|
||||
bool operator!() const BOOST_NOEXCEPT { return ptr_ == 0; }
|
||||
BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
|
||||
@ -159,17 +166,36 @@ public:
|
||||
void reset() BOOST_NOEXCEPT { ptr_ = 0; }
|
||||
|
||||
bool is_initialized() const BOOST_NOEXCEPT { return ptr_ != 0; }
|
||||
bool has_value() const BOOST_NOEXCEPT { return ptr_ != 0; }
|
||||
|
||||
template <typename F>
|
||||
optional<typename boost::result_of<F(T&)>::type> map(F f) const
|
||||
{
|
||||
if (this->has_value())
|
||||
return f(this->get());
|
||||
else
|
||||
return none;
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
optional<typename optional_detail::optional_value_type<typename boost::result_of<F(T&)>::type>::type> flat_map(F f) const
|
||||
{
|
||||
if (this->has_value())
|
||||
return f(get());
|
||||
else
|
||||
return none;
|
||||
}
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
|
||||
optional(T&& /* rhs */) BOOST_NOEXCEPT { detail::prevent_binding_rvalue<T&&>(); }
|
||||
|
||||
template <class R>
|
||||
optional(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::no_unboxing_cond<T, R> >::type* = 0) BOOST_NOEXCEPT
|
||||
optional(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::no_unboxing_cond<T, R>, bool>::type = true) BOOST_NOEXCEPT
|
||||
: ptr_(boost::addressof(r)) { detail::prevent_binding_rvalue<R>(); }
|
||||
|
||||
template <class R>
|
||||
optional(bool cond, R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) BOOST_NOEXCEPT
|
||||
optional(bool cond, R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, bool>::type = true) BOOST_NOEXCEPT
|
||||
: ptr_(cond ? boost::addressof(r) : 0) { detail::prevent_binding_rvalue<R>(); }
|
||||
|
||||
template <class R>
|
||||
@ -177,19 +203,19 @@ public:
|
||||
operator=(R&& r) BOOST_NOEXCEPT { detail::prevent_binding_rvalue<R>(); ptr_ = boost::addressof(r); return *this; }
|
||||
|
||||
template <class R>
|
||||
void emplace(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) BOOST_NOEXCEPT
|
||||
void emplace(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, bool>::type = true) BOOST_NOEXCEPT
|
||||
{ detail::prevent_binding_rvalue<R>(); ptr_ = boost::addressof(r); }
|
||||
|
||||
template <class R>
|
||||
T& get_value_or(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) const BOOST_NOEXCEPT
|
||||
T& get_value_or(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, bool>::type = true) const BOOST_NOEXCEPT
|
||||
{ detail::prevent_binding_rvalue<R>(); return ptr_ ? *ptr_ : r; }
|
||||
|
||||
template <class R>
|
||||
T& value_or(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) const BOOST_NOEXCEPT
|
||||
T& value_or(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, bool>::type = true) const BOOST_NOEXCEPT
|
||||
{ detail::prevent_binding_rvalue<R>(); return ptr_ ? *ptr_ : r; }
|
||||
|
||||
template <class R>
|
||||
void reset(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R> >::type* = 0) BOOST_NOEXCEPT
|
||||
void reset(R&& r, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<R>, bool>::type = true) BOOST_NOEXCEPT
|
||||
{ detail::prevent_binding_rvalue<R>(); ptr_ = boost::addressof(r); }
|
||||
|
||||
template <class F>
|
||||
@ -200,15 +226,15 @@ public:
|
||||
|
||||
// the following two implement a 'conditionally explicit' constructor
|
||||
template <class U>
|
||||
explicit optional(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::no_unboxing_cond<T, U>::value && detail::is_const_integral_bad_for_conversion<U>::value >::type* = 0) BOOST_NOEXCEPT
|
||||
explicit optional(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::no_unboxing_cond<T, U>::value && detail::is_const_integral_bad_for_conversion<U>::value, bool>::type = true) BOOST_NOEXCEPT
|
||||
: ptr_(boost::addressof(v)) { }
|
||||
|
||||
template <class U>
|
||||
optional(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::no_unboxing_cond<T, U>::value && !detail::is_const_integral_bad_for_conversion<U>::value >::type* = 0) BOOST_NOEXCEPT
|
||||
optional(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if_c<detail::no_unboxing_cond<T, U>::value && !detail::is_const_integral_bad_for_conversion<U>::value, bool>::type = true) BOOST_NOEXCEPT
|
||||
: ptr_(boost::addressof(v)) { }
|
||||
|
||||
template <class U>
|
||||
optional(bool cond, U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT : ptr_(cond ? boost::addressof(v) : 0) {}
|
||||
optional(bool cond, U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, bool>::type = true) BOOST_NOEXCEPT : ptr_(cond ? boost::addressof(v) : 0) {}
|
||||
|
||||
template <class U>
|
||||
BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, optional<T&>&>::type
|
||||
@ -219,19 +245,19 @@ public:
|
||||
}
|
||||
|
||||
template <class U>
|
||||
void emplace(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT
|
||||
void emplace(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, bool>::type = true) BOOST_NOEXCEPT
|
||||
{ ptr_ = boost::addressof(v); }
|
||||
|
||||
template <class U>
|
||||
T& get_value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) const BOOST_NOEXCEPT
|
||||
T& get_value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, bool>::type = true) const BOOST_NOEXCEPT
|
||||
{ return ptr_ ? *ptr_ : v; }
|
||||
|
||||
template <class U>
|
||||
T& value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) const BOOST_NOEXCEPT
|
||||
T& value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, bool>::type = true) const BOOST_NOEXCEPT
|
||||
{ return ptr_ ? *ptr_ : v; }
|
||||
|
||||
template <class U>
|
||||
void reset(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT
|
||||
void reset(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, bool>::type = true) BOOST_NOEXCEPT
|
||||
{ ptr_ = boost::addressof(v); }
|
||||
|
||||
template <class F>
|
||||
|
@ -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.
|
||||
|
||||
|
||||
//
|
||||
@ -26,7 +26,7 @@ namespace boost {
|
||||
template<class T>
|
||||
inline
|
||||
bool operator == ( optional<T> const& x, optional<T> const& y )
|
||||
{ return equal_pointees(x,y); }
|
||||
{ return bool(x) && bool(y) ? *x == *y : bool(x) == bool(y); }
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -0,0 +1,510 @@
|
||||
// Copyright (C) 2017 Andrzej Krzemienski.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// akrzemi1@gmail.com
|
||||
|
||||
// trivially-copyable version of the storage
|
||||
|
||||
template<class T>
|
||||
class tc_optional_base : public optional_tag
|
||||
{
|
||||
private :
|
||||
|
||||
typedef tc_optional_base<T> this_type ;
|
||||
|
||||
protected :
|
||||
|
||||
typedef T value_type ;
|
||||
|
||||
protected:
|
||||
typedef T & reference_type ;
|
||||
typedef T const& reference_const_type ;
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
typedef T && rval_reference_type ;
|
||||
typedef T && reference_type_of_temporary_wrapper ;
|
||||
#endif
|
||||
typedef T * pointer_type ;
|
||||
typedef T const* pointer_const_type ;
|
||||
typedef T const& argument_type ;
|
||||
|
||||
tc_optional_base()
|
||||
:
|
||||
m_initialized(false) {}
|
||||
|
||||
tc_optional_base ( none_t )
|
||||
:
|
||||
m_initialized(false) {}
|
||||
|
||||
tc_optional_base ( init_value_tag, argument_type val )
|
||||
:
|
||||
m_initialized(true), m_storage(val) {}
|
||||
|
||||
tc_optional_base ( bool cond, argument_type val )
|
||||
:
|
||||
m_initialized(cond), m_storage(val) {}
|
||||
|
||||
// tc_optional_base ( tc_optional_base const& ) = default;
|
||||
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
|
||||
template<class Expr, class PtrExpr>
|
||||
explicit tc_optional_base ( Expr&& expr, PtrExpr const* tag )
|
||||
:
|
||||
m_initialized(false)
|
||||
{
|
||||
construct(boost::forward<Expr>(expr),tag);
|
||||
}
|
||||
|
||||
#else
|
||||
// This is used for both converting and in-place constructions.
|
||||
// Derived classes use the 'tag' to select the appropriate
|
||||
// implementation (the correct 'construct()' overload)
|
||||
template<class Expr>
|
||||
explicit tc_optional_base ( Expr const& expr, Expr const* tag )
|
||||
:
|
||||
m_initialized(false)
|
||||
{
|
||||
construct(expr,tag);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// tc_optional_base& operator= ( tc_optional_base const& ) = default;
|
||||
// ~tc_optional_base() = default;
|
||||
|
||||
// Assigns from another optional<T> (deep-copies the rhs value)
|
||||
void assign ( tc_optional_base const& rhs )
|
||||
{
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
// Assigns from another _convertible_ optional<U> (deep-copies the rhs value)
|
||||
template<class U>
|
||||
void assign ( optional<U> const& rhs )
|
||||
{
|
||||
if ( rhs.is_initialized() )
|
||||
#ifndef BOOST_OPTIONAL_CONFIG_RESTORE_ASSIGNMENT_OF_NONCONVERTIBLE_TYPES
|
||||
m_storage = rhs.get();
|
||||
#else
|
||||
m_storage = static_cast<value_type>(rhs.get());
|
||||
#endif
|
||||
|
||||
m_initialized = rhs.is_initialized();
|
||||
}
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
// move-assigns from another _convertible_ optional<U> (deep-moves from the rhs value)
|
||||
template<class U>
|
||||
void assign ( optional<U>&& rhs )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME optional<U>::rval_reference_type ref_type;
|
||||
if ( rhs.is_initialized() )
|
||||
m_storage = static_cast<ref_type>(rhs.get());
|
||||
m_initialized = rhs.is_initialized();
|
||||
}
|
||||
#endif
|
||||
|
||||
void assign ( argument_type val )
|
||||
{
|
||||
construct(val);
|
||||
}
|
||||
|
||||
void assign ( none_t ) { destroy(); }
|
||||
|
||||
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
template<class Expr, class ExprPtr>
|
||||
void assign_expr ( Expr&& expr, ExprPtr const* tag )
|
||||
{
|
||||
construct(boost::forward<Expr>(expr),tag);
|
||||
}
|
||||
#else
|
||||
template<class Expr>
|
||||
void assign_expr ( Expr const& expr, Expr const* tag )
|
||||
{
|
||||
construct(expr,tag);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
public :
|
||||
|
||||
// Destroys the current value, if any, leaving this UNINITIALIZED
|
||||
// No-throw (assuming T::~T() doesn't)
|
||||
void reset() BOOST_NOEXCEPT { destroy(); }
|
||||
|
||||
// **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,
|
||||
// returns NULL.
|
||||
// No-throw
|
||||
pointer_const_type get_ptr() const { return m_initialized ? get_ptr_impl() : 0 ; }
|
||||
pointer_type get_ptr() { return m_initialized ? get_ptr_impl() : 0 ; }
|
||||
|
||||
bool is_initialized() const { return m_initialized ; }
|
||||
|
||||
protected :
|
||||
|
||||
void construct ( argument_type val )
|
||||
{
|
||||
m_storage = val ;
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
|
||||
#if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
// Constructs in-place
|
||||
// upon exception *this is always uninitialized
|
||||
template<class... Args>
|
||||
void construct ( in_place_init_t, Args&&... args )
|
||||
{
|
||||
m_storage = value_type( boost::forward<Args>(args)... ) ;
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
template<class... Args>
|
||||
void emplace_assign ( Args&&... args )
|
||||
{
|
||||
construct(in_place_init, boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<class... Args>
|
||||
explicit tc_optional_base ( in_place_init_t, Args&&... args )
|
||||
:
|
||||
m_initialized(false)
|
||||
{
|
||||
construct(in_place_init, boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<class... Args>
|
||||
explicit tc_optional_base ( in_place_init_if_t, bool cond, Args&&... args )
|
||||
:
|
||||
m_initialized(false)
|
||||
{
|
||||
if ( cond )
|
||||
construct(in_place_init, boost::forward<Args>(args)...);
|
||||
}
|
||||
#elif (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
|
||||
template<class Arg>
|
||||
void construct ( in_place_init_t, Arg&& arg )
|
||||
{
|
||||
m_storage = value_type( boost::forward<Arg>(arg) );
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
void construct ( in_place_init_t )
|
||||
{
|
||||
m_storage = value_type();
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
void emplace_assign ( Arg&& arg )
|
||||
{
|
||||
construct(in_place_init, boost::forward<Arg>(arg)) ;
|
||||
}
|
||||
|
||||
void emplace_assign ()
|
||||
{
|
||||
construct(in_place_init) ;
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
explicit tc_optional_base ( in_place_init_t, Arg&& arg )
|
||||
:
|
||||
m_initialized(false)
|
||||
{
|
||||
construct(in_place_init, boost::forward<Arg>(arg));
|
||||
}
|
||||
|
||||
explicit tc_optional_base ( in_place_init_t )
|
||||
:
|
||||
m_initialized(false), m_storage() {}
|
||||
|
||||
template<class Arg>
|
||||
explicit tc_optional_base ( in_place_init_if_t, bool cond, Arg&& arg )
|
||||
:
|
||||
m_initialized(false)
|
||||
{
|
||||
if ( cond )
|
||||
construct(in_place_init, boost::forward<Arg>(arg));
|
||||
}
|
||||
|
||||
explicit tc_optional_base ( in_place_init_if_t, bool cond )
|
||||
:
|
||||
m_initialized(false)
|
||||
{
|
||||
if ( cond )
|
||||
construct(in_place_init);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class Arg>
|
||||
void construct ( in_place_init_t, const Arg& arg )
|
||||
{
|
||||
m_storage = value_type( arg );
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
void construct ( in_place_init_t, Arg& arg )
|
||||
{
|
||||
m_storage = value_type( arg );
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
void construct ( in_place_init_t )
|
||||
{
|
||||
m_storage = value_type();
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
void emplace_assign ( const Arg& arg )
|
||||
{
|
||||
construct(in_place_init, arg);
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
void emplace_assign ( Arg& arg )
|
||||
{
|
||||
construct(in_place_init, arg);
|
||||
}
|
||||
|
||||
void emplace_assign ()
|
||||
{
|
||||
construct(in_place_init);
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
explicit tc_optional_base ( in_place_init_t, const Arg& arg )
|
||||
: m_initialized(false)
|
||||
{
|
||||
construct(in_place_init, arg);
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
explicit tc_optional_base ( in_place_init_t, Arg& arg )
|
||||
: m_initialized(false)
|
||||
{
|
||||
construct(in_place_init, arg);
|
||||
}
|
||||
|
||||
explicit tc_optional_base ( in_place_init_t )
|
||||
: m_initialized(false)
|
||||
{
|
||||
construct(in_place_init);
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
explicit tc_optional_base ( in_place_init_if_t, bool cond, const Arg& arg )
|
||||
: m_initialized(false)
|
||||
{
|
||||
if ( cond )
|
||||
construct(in_place_init, arg);
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
explicit tc_optional_base ( in_place_init_if_t, bool cond, Arg& arg )
|
||||
: m_initialized(false)
|
||||
{
|
||||
if ( cond )
|
||||
construct(in_place_init, arg);
|
||||
}
|
||||
|
||||
explicit tc_optional_base ( in_place_init_if_t, bool cond )
|
||||
: m_initialized(false)
|
||||
{
|
||||
if ( cond )
|
||||
construct(in_place_init);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
// Constructs in-place using the given factory
|
||||
template<class Expr>
|
||||
void construct ( Expr&& factory, in_place_factory_base const* )
|
||||
{
|
||||
boost_optional_detail::construct<value_type>(factory, boost::addressof(m_storage));
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
// Constructs in-place using the given typed factory
|
||||
template<class Expr>
|
||||
void construct ( Expr&& factory, typed_in_place_factory_base const* )
|
||||
{
|
||||
factory.apply(boost::addressof(m_storage)) ;
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
template<class Expr>
|
||||
void assign_expr_to_initialized ( Expr&& factory, in_place_factory_base const* tag )
|
||||
{
|
||||
destroy();
|
||||
construct(factory,tag);
|
||||
}
|
||||
|
||||
// Constructs in-place using the given typed factory
|
||||
template<class Expr>
|
||||
void assign_expr_to_initialized ( Expr&& factory, typed_in_place_factory_base const* tag )
|
||||
{
|
||||
destroy();
|
||||
construct(factory,tag);
|
||||
}
|
||||
|
||||
#else
|
||||
// Constructs in-place using the given factory
|
||||
template<class Expr>
|
||||
void construct ( Expr const& factory, in_place_factory_base const* )
|
||||
{
|
||||
boost_optional_detail::construct<value_type>(factory, boost::addressof(m_storage));
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
// Constructs in-place using the given typed factory
|
||||
template<class Expr>
|
||||
void construct ( Expr const& factory, typed_in_place_factory_base const* )
|
||||
{
|
||||
factory.apply(boost::addressof(m_storage)) ;
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
template<class Expr>
|
||||
void assign_expr_to_initialized ( Expr const& factory, in_place_factory_base const* tag )
|
||||
{
|
||||
destroy();
|
||||
construct(factory,tag);
|
||||
}
|
||||
|
||||
// Constructs in-place using the given typed factory
|
||||
template<class Expr>
|
||||
void assign_expr_to_initialized ( Expr const& factory, typed_in_place_factory_base const* tag )
|
||||
{
|
||||
destroy();
|
||||
construct(factory,tag);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
// Constructs using any expression implicitly convertible to the single argument
|
||||
// of a one-argument T constructor.
|
||||
// Converting constructions of optional<T> from optional<U> uses this function with
|
||||
// 'Expr' being of type 'U' and relying on a converting constructor of T from U.
|
||||
template<class Expr>
|
||||
void construct ( Expr&& expr, void const* )
|
||||
{
|
||||
m_storage = value_type(boost::forward<Expr>(expr)) ;
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
// Assigns using a form any expression implicitly convertible to the single argument
|
||||
// of a T's assignment operator.
|
||||
// Converting assignments of optional<T> from optional<U> uses this function with
|
||||
// 'Expr' being of type 'U' and relying on a converting assignment of T from U.
|
||||
template<class Expr>
|
||||
void assign_expr_to_initialized ( Expr&& expr, void const* )
|
||||
{
|
||||
assign_value( boost::forward<Expr>(expr) );
|
||||
}
|
||||
#else
|
||||
// Constructs using any expression implicitly convertible to the single argument
|
||||
// of a one-argument T constructor.
|
||||
// Converting constructions of optional<T> from optional<U> uses this function with
|
||||
// 'Expr' being of type 'U' and relying on a converting constructor of T from U.
|
||||
template<class Expr>
|
||||
void construct ( Expr const& expr, void const* )
|
||||
{
|
||||
m_storage = value_type(expr) ;
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
// Assigns using a form any expression implicitly convertible to the single argument
|
||||
// of a T's assignment operator.
|
||||
// Converting assignments of optional<T> from optional<U> uses this function with
|
||||
// 'Expr' being of type 'U' and relying on a converting assignment of T from U.
|
||||
template<class Expr>
|
||||
void assign_expr_to_initialized ( Expr const& expr, void const* )
|
||||
{
|
||||
assign_value(expr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
|
||||
// BCB5.64 (and probably lower versions) workaround.
|
||||
// The in-place factories are supported by means of catch-all constructors
|
||||
// and assignment operators (the functions are parameterized in terms of
|
||||
// an arbitrary 'Expr' type)
|
||||
// This compiler incorrectly resolves the overload set and sinks optional<T> and optional<U>
|
||||
// to the 'Expr'-taking functions even though explicit overloads are present for them.
|
||||
// Thus, the following overload is needed to properly handle the case when the 'lhs'
|
||||
// is another optional.
|
||||
//
|
||||
// For VC<=70 compilers this workaround doesn't work because the compiler issues and error
|
||||
// instead of choosing the wrong overload
|
||||
//
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
// Notice that 'Expr' will be optional<T> or optional<U> (but not tc_optional_base<..>)
|
||||
template<class Expr>
|
||||
void construct ( Expr&& expr, optional_tag const* )
|
||||
{
|
||||
if ( expr.is_initialized() )
|
||||
{
|
||||
// An exception can be thrown here.
|
||||
// It it happens, THIS will be left uninitialized.
|
||||
m_storage = value_type(boost::move(expr.get())) ;
|
||||
m_initialized = true ;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Notice that 'Expr' will be optional<T> or optional<U> (but not tc_optional_base<..>)
|
||||
template<class Expr>
|
||||
void construct ( Expr const& expr, optional_tag const* )
|
||||
{
|
||||
if ( expr.is_initialized() )
|
||||
{
|
||||
// An exception can be thrown here.
|
||||
// It it happens, THIS will be left uninitialized.
|
||||
m_storage = value_type(expr.get()) ;
|
||||
m_initialized = true ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // defined BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
|
||||
|
||||
void assign_value ( argument_type val ) { m_storage = val; }
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
void assign_value ( rval_reference_type val ) { m_storage = static_cast<rval_reference_type>(val); }
|
||||
#endif
|
||||
|
||||
void destroy()
|
||||
{
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
reference_const_type get_impl() const { return m_storage ; }
|
||||
reference_type get_impl() { return m_storage ; }
|
||||
|
||||
pointer_const_type get_ptr_impl() const { return boost::addressof(m_storage); }
|
||||
pointer_type get_ptr_impl() { return boost::addressof(m_storage); }
|
||||
|
||||
private :
|
||||
|
||||
bool m_initialized ;
|
||||
T m_storage ;
|
||||
} ;
|
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
||||
|
@ -12,5 +12,6 @@
|
||||
"maintainers": [
|
||||
"Fernando Cacciola <fernando_cacciola -at- ciudad.com.ar>",
|
||||
"Andrzej Krzemienski <akrzemi1 -at- gmail.com>"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Boost.Optional Library test Jamfile
|
||||
#
|
||||
# Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
# Copyright (C) 2014 - 2016 Andrzej Krzemienski
|
||||
# Copyright (C) 2014 - 2017 Andrzej Krzemienski
|
||||
#
|
||||
# Use, modification, and distribution is subject to the Boost Software
|
||||
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -18,10 +18,16 @@ import testing ;
|
||||
{
|
||||
test-suite optional :
|
||||
[ run optional_test.cpp ]
|
||||
[ run optional_test_assign.cpp ]
|
||||
[ run optional_test_swap.cpp ]
|
||||
[ run optional_test_conversions_from_U.cpp ]
|
||||
[ run optional_test_convert_from_T.cpp ]
|
||||
[ run optional_test_convert_assign.cpp ]
|
||||
[ run optional_test_empty_braces.cpp ]
|
||||
[ run optional_test_make_optional.cpp ]
|
||||
[ run optional_test_flat_map.cpp ]
|
||||
[ run optional_test_hash.cpp ]
|
||||
[ run optional_test_map.cpp ]
|
||||
[ run optional_test_tie.cpp ]
|
||||
[ run optional_test_ref_assign_portable_minimum.cpp ]
|
||||
[ run optional_test_ref_assign_mutable_int.cpp ]
|
||||
@ -37,12 +43,17 @@ import testing ;
|
||||
[ run optional_test_io.cpp ]
|
||||
[ run optional_test_move.cpp ]
|
||||
[ run optional_test_noexcept_move.cpp ]
|
||||
[ run optional_test_old_impl.cpp ]
|
||||
[ run optional_test_equals_none.cpp ]
|
||||
[ run optional_test_value_access.cpp ]
|
||||
[ run optional_test_emplace.cpp ]
|
||||
[ run optional_test_minimum_requirements.cpp ]
|
||||
[ run optional_test_msvc_bug_workaround.cpp ]
|
||||
[ run optional_test_member_T.cpp ]
|
||||
[ run optional_test_tc_base.cpp ]
|
||||
[ compile optional_test_sfinae_friendly_ctor.cpp ]
|
||||
[ compile optional_test_path_assignment.cpp ]
|
||||
[ compile-fail optional_test_fail_const_swap.cpp ]
|
||||
[ compile-fail optional_test_ref_convert_assign_const_int_prevented.cpp ]
|
||||
[ compile-fail optional_test_fail1.cpp ]
|
||||
[ compile-fail optional_test_fail3a.cpp ]
|
||||
@ -65,6 +76,11 @@ import testing ;
|
||||
[ compile-fail optional_test_fail_io_without_io.cpp ]
|
||||
[ compile-fail optional_test_fail_none_io_without_io.cpp ]
|
||||
[ compile-fail optional_test_fail_convert_assign_of_enums.cpp ]
|
||||
[ run optional_test_static_properties.cpp ]
|
||||
[ compile optional_test_maybe_uninitialized_warning.cpp ]
|
||||
[ compile optional_test_deleted_default_ctor.cpp ]
|
||||
[ compile optional_test_constructible_from_other.cpp ]
|
||||
#[ run optional_xconfig_HACK_TO_LIST_PREDEFINED_MACROS.cpp ]
|
||||
[ run optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_pass.cpp ]
|
||||
[ run-fail optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_fail.cpp ]
|
||||
[ run optional_xconfig_NO_PROPER_CONVERT_FROM_CONST_INT_pass.cpp ]
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "boost/optional/optional.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef BOOST_BORLANDC
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
|
@ -12,7 +12,9 @@
|
||||
// Revisions:
|
||||
// 12 May 2008 (added more swap tests)
|
||||
//
|
||||
#ifndef BOOST_NO_IOSTREAM
|
||||
#include<iostream>
|
||||
#endif // BOOST_NO_IOSTREAM
|
||||
#include<stdexcept>
|
||||
#include<string>
|
||||
|
||||
@ -24,7 +26,7 @@
|
||||
|
||||
#include "boost/optional/optional.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef BOOST_BORLANDC
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
@ -32,7 +34,7 @@
|
||||
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "optional_test_common.cpp"
|
||||
#include "optional_test_common.hpp"
|
||||
|
||||
void test_implicit_construction ( optional<double> opt, double v, double z )
|
||||
{
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
30
test/optional_test_assign.cpp
Normal file
30
test/optional_test_assign.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2018 Andrzej Krzemienski.
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/lib/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// akrzemi1@gmail.com
|
||||
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/optional/optional.hpp"
|
||||
|
||||
void test_assignment_to_empty()
|
||||
{
|
||||
// this test used to fail on GCC 8.1.0/8.2.0/9.0.0 with -std=c++98
|
||||
boost::optional<int> oa, ob(1);
|
||||
BOOST_TEST(!oa);
|
||||
BOOST_TEST(ob);
|
||||
|
||||
oa = ob;
|
||||
BOOST_TEST(oa);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_assignment_to_empty();
|
||||
return boost::report_errors();
|
||||
}
|
@ -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
|
||||
{
|
||||
@ -194,6 +194,9 @@ inline void check_uninitialized_const ( optional<T> const& opt )
|
||||
BOOST_TEST( !opt ) ;
|
||||
BOOST_TEST( !get_pointer(opt) ) ;
|
||||
BOOST_TEST( !opt.get_ptr() ) ;
|
||||
BOOST_TEST( !opt.has_value() ) ;
|
||||
BOOST_TEST( !opt.is_initialized() ) ;
|
||||
BOOST_TEST( opt == boost::none ) ;
|
||||
}
|
||||
template<class T>
|
||||
inline void check_uninitialized ( optional<T>& opt )
|
||||
@ -204,6 +207,9 @@ inline void check_uninitialized ( optional<T>& opt )
|
||||
BOOST_TEST( !opt ) ;
|
||||
BOOST_TEST( !get_pointer(opt) ) ;
|
||||
BOOST_TEST( !opt.get_ptr() ) ;
|
||||
BOOST_TEST( !opt.has_value() ) ;
|
||||
BOOST_TEST( !opt.is_initialized() ) ;
|
||||
BOOST_TEST( opt == boost::none ) ;
|
||||
|
||||
check_uninitialized_const(opt);
|
||||
}
|
||||
@ -220,6 +226,9 @@ inline void check_initialized_const ( optional<T> const& opt )
|
||||
BOOST_TEST ( !!opt ) ;
|
||||
BOOST_TEST ( get_pointer(opt) ) ;
|
||||
BOOST_TEST ( opt.get_ptr() ) ;
|
||||
BOOST_TEST ( opt.has_value() ) ;
|
||||
BOOST_TEST ( opt.is_initialized() ) ;
|
||||
BOOST_TEST ( opt != boost::none ) ;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@ -234,6 +243,9 @@ inline void check_initialized ( optional<T>& opt )
|
||||
BOOST_TEST ( !!opt ) ;
|
||||
BOOST_TEST ( get_pointer(opt) ) ;
|
||||
BOOST_TEST ( opt.get_ptr() ) ;
|
||||
BOOST_TEST ( opt.has_value() ) ;
|
||||
BOOST_TEST ( opt.is_initialized() ) ;
|
||||
BOOST_TEST ( opt != boost::none ) ;
|
||||
|
||||
check_initialized_const(opt);
|
||||
}
|
59
test/optional_test_constructible_from_other.cpp
Normal file
59
test/optional_test_constructible_from_other.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
// Copyright (c) 2018 Andrey Semashev
|
||||
//
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// The test verifies that Boost.Optional copy constructors do not attempt to invoke
|
||||
// the element type initializing constructors from templated arguments
|
||||
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
|
||||
struct no_type
|
||||
{
|
||||
char data;
|
||||
};
|
||||
|
||||
struct yes_type
|
||||
{
|
||||
char data[2];
|
||||
};
|
||||
|
||||
template< unsigned int Size >
|
||||
struct size_tag {};
|
||||
|
||||
template< typename T, typename U >
|
||||
struct is_constructible
|
||||
{
|
||||
static U& get();
|
||||
|
||||
template< typename T1 >
|
||||
static yes_type check_helper(size_tag< sizeof(static_cast< T1 >(get())) >*);
|
||||
template< typename T1 >
|
||||
static no_type check_helper(...);
|
||||
|
||||
static const bool value = sizeof(check_helper< T >(0)) == sizeof(yes_type);
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
class wrapper
|
||||
{
|
||||
public:
|
||||
wrapper() {}
|
||||
wrapper(wrapper const&) {}
|
||||
template< typename U >
|
||||
wrapper(U const&, typename boost::enable_if_c< is_constructible< T, U >::value, int >::type = 0) {}
|
||||
};
|
||||
|
||||
inline boost::optional< wrapper< int > > foo()
|
||||
{
|
||||
return boost::optional< wrapper< int > >();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// Invokes boost::optional copy constructor. Should not invoke wrapper constructor from U.
|
||||
boost::optional< wrapper< int > > res = foo();
|
||||
return 0;
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "boost/optional/optional.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef BOOST_BORLANDC
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
|
57
test/optional_test_convert_assign.cpp
Normal file
57
test/optional_test_convert_assign.cpp
Normal 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();
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "boost/optional/optional.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef BOOST_BORLANDC
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
|
66
test/optional_test_deleted_default_ctor.cpp
Normal file
66
test/optional_test_deleted_default_ctor.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright 2017 Peter Dimov
|
||||
// Copyright 2017 Vinnie Falco
|
||||
// Copyright 2018 Andrzej Krzemienski
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <utility>
|
||||
|
||||
class basic_multi_buffer;
|
||||
|
||||
class const_buffers_type // a similar declaration in boost.beast had problem
|
||||
{ // with boost optional
|
||||
basic_multi_buffer const* b_;
|
||||
|
||||
friend class basic_multi_buffer;
|
||||
|
||||
explicit
|
||||
const_buffers_type(basic_multi_buffer const& b);
|
||||
|
||||
public:
|
||||
const_buffers_type() = delete;
|
||||
const_buffers_type(const_buffers_type const&) = default;
|
||||
const_buffers_type& operator=(const_buffers_type const&) = default;
|
||||
};
|
||||
|
||||
void test_beast_example()
|
||||
{
|
||||
// test if it even compiles
|
||||
boost::optional< std::pair<const_buffers_type, int> > opt, opt2;
|
||||
opt = opt2;
|
||||
(void)opt;
|
||||
}
|
||||
|
||||
struct NotDefaultConstructible // minimal class exposing the problem
|
||||
{
|
||||
NotDefaultConstructible() = delete;
|
||||
};
|
||||
|
||||
void test_assign_for_non_default_constructible()
|
||||
{
|
||||
// test if it even compiles
|
||||
boost::optional<NotDefaultConstructible> opt, opt2;
|
||||
opt = opt2;
|
||||
(void)opt;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_beast_example();
|
||||
test_assign_for_non_default_constructible();
|
||||
}
|
||||
|
||||
#endif
|
@ -11,10 +11,11 @@
|
||||
|
||||
#include "boost/optional/optional.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef BOOST_BORLANDC
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/none.hpp"
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user