Skip to content

Commit fa52755

Browse files
committed
docs update
1 parent 76be15b commit fa52755

5 files changed

Lines changed: 36 additions & 4 deletions

File tree

doc/11_development.qbk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ In the general case, the internal representation is something equivalent to:
5050
alignas(T) char _value [sizeof(T)];
5151
};
5252

53+
or:
54+
55+
template <typename T>
56+
class Optional
57+
{
58+
bool _has_value = false;
59+
union {
60+
T _value;
61+
DummyType _non_value;
62+
};
63+
};
64+
5365
Next, because we need to pass around these "optional" `int`s as normal `int`s,
5466
like returning them from functions, when copying, we need to copy `_has_value`,
5567
which indicates whether we have the value or not, and, if we do have value, and

doc/27_ref_optional_synopsis.qbk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ They are empty, trivially copyable classes with disabled default constructor.
198198
template<class F> constexpr auto flat_map( F f ) && -> ``['see below]``; ``[link reference_optional_flat_map_move __GO_TO__]``
199199

200200
constexpr operator optional<T&>() & noexcept; ``[link reference_optional_conversion_to_ref __GO_TO__]``
201-
constexpr operator optional<T const&&>() const& noexcept; ``[link reference_optional_conversion_to_ref __GO_TO__]``
201+
constexpr operator optional<T const&>() const& noexcept; ``[link reference_optional_conversion_to_ref __GO_TO__]``
202202

203203
T const* get_ptr() const ; ``[link reference_optional_get_ptr __GO_TO__]``
204204
T* get_ptr() ; ``[link reference_optional_get_ptr __GO_TO__]``

doc/28_ref_optional_semantics.qbk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ the parameter.
4747
* [*Example:]
4848
``
4949
#include <boost/none.hpp>
50+
5051
optional<T> n(none) ;
5152
assert ( !n ) ;
53+
assert ( n == none ) ;
5254
``
5355

5456
__SPACE__

doc/91_comparison_with_std.qbk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@
5656
void test(vector<optional<T>> rng, T val) {
5757
std::ranges::find(rng, make_optional(val));
5858
}
59-
```] [The same code for `std::optional` compiles but is ['undefined behavior] when `T` is itself an `optional`. ] ]
59+
```] [For `std::optional`, code without `make_optional()` compiles but is ['undefined behavior] when `T` is itself an `optional`. ] ]
6060

6161
]
6262

63-
6463
[endsect][/ std_comp]

doc/92_relnotes.qbk

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* In C++17 all constructors (including copy and move) become core constant expressions
2727
for co-operating types.
2828

29-
This addresses [@https://github.com/boostorg/optional/issues/143 issue #143].
29+
This addresses issues [@https://github.com/boostorg/optional/issues/132 #132] and [@https://github.com/boostorg/optional/issues/143 #143].
3030

3131
* *Breaking change.* In the said implementation, abandoned the mechanism for customizing
3232
`swap`. Hardly anyone knows about this mechanism and it was never documented.
@@ -43,6 +43,25 @@
4343
model concept `std::equality_comparable_with` (for `std::equality_comparable` `T`s),
4444
which means that you can `std::ranges::find(rng, boost::none)` for a range of optional objects.
4545

46+
* *Warning.* In the future releases we intend to introduce the range interface
47+
in `optional`, so that `std::ranges::range<optional<T>>` will be `true`.
48+
This may affect the overload resolution in programs that make decisions based
49+
on predicates such as `std::ranges::range`. For instance, the following code
50+
will start behaving differently:
51+
52+
```
53+
template <typename T>
54+
void serialize(T const& v)
55+
{
56+
if constexpr (std::ranges::range<T>)
57+
serialize_as_range(v);
58+
else if constexpr (custom::is_optional_like<T>)
59+
serialize_as_optional(v);
60+
else
61+
serialize_as_value(v);
62+
}
63+
```
64+
4665
[heading Boost Release 1.87]
4766

4867
* *Breaking change.* Dropped support for C++03. C++11 is now the required minimum; at least some C++11 features.

0 commit comments

Comments
 (0)