docs no longer mention perfect forwarding workarounds

This commit is contained in:
Andrzej Krzemienski
2024-09-27 16:10:56 +02:00
parent f91e03b35b
commit 1820ae55ef
3 changed files with 4 additions and 39 deletions

View File

@ -15,7 +15,7 @@ deductions for class template parameters.
std::optional<std::string> os2 = osv; // OK
os2 == osv; // OK
They are practical, ans sometimes stem from the argument for consistency:
They are practical, and sometimes stem from the argument for consistency:
if `(optT && *optT == u)` works then `(optT == u)` should also work.
However, these intelligent convenience functions sometimes produce results

View File

@ -233,7 +233,7 @@ __SPACE__
arguments `std::forward<Args>(args)...`.
* [*Postconditions:] `*this` is initialized.
* [*Throws:] Any exception thrown by the selected constructor of `T`.
* [*Notes: ] `T` need not be __MOVE_CONSTRUCTIBLE__. On compilers that do not support 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__.
* [*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 support 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__.
* [*Example:]
``
@ -502,7 +502,7 @@ __SPACE__
* [*Postconditions: ] `*this` is [_initialized].
* [*Throws:] Whatever the selected `T`'s constructor throws.
* [*Exception Safety:] If an exception is thrown during the initialization of `T`, `*this` is ['uninitialized].
* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`. On compilers that do not support 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`.
* [*Example:]
``
T v;

View File

@ -24,41 +24,6 @@ The implementation uses the following other Boost modules:
[endsect]
[section Emplace operations in older compilers][#optional_emplace_workaround]
Certain constructors and functions in the interface of `optional` perform a 'perfect forwarding' of arguments:
template<class... Args> optional(in_place_init_t, Args&&... args);
template<class... Args> optional(in_place_init_if_t, bool condition, Args&&... args);
template<class... Args> void emplace(Args&&... args);
On compilers that do not support variadic templates, each of these functions is substituted with two overloads, one forwarding a single argument, the other forwarding zero arguments. This forms the following set:
template<class Arg> optional(in_place_init_t, Arg&& arg);
optional(in_place_init_t);
template<class Arg> optional(in_place_init_if_t, bool condition, Arg&& arg);
optional(in_place_init_if_t, bool condition);
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 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);
optional(in_place_init_t);
template<class Arg> optional(in_place_init_if_t, bool condition, const Arg& arg);
template<class Arg> optional(in_place_init_if_t, bool condition, Arg& arg);
optional(in_place_init_if_t, bool condition);
template<class Arg> void emplace(const Arg& arg);
template<class Arg> void emplace(Arg& arg);
void emplace();
This workaround addresses about 40% of all use cases. If this is insufficient, you need to resort to using [link boost_optional.design.in_place_factories In-Place Factories].
[endsect]
[section Optional Reference Binding][#optional_reference_binding]