optional_reference: fix documentation
This commit is contained in:
parent
88873e3fae
commit
aa37086572
1 changed files with 5 additions and 4 deletions
|
@ -22,13 +22,14 @@ namespace utils
|
|||
* A simple wrapper class for optional reference types.
|
||||
*
|
||||
* Since std::optional (as of C++17 at least) does not support reference types (see [1]),
|
||||
* the only way to use those is std::optional<std::reference_wrapper>. However, this makes
|
||||
* the only way to use those is std::optional<std::reference_wrapper<T>>. However, this makes
|
||||
* the interace messy, as to access the referenced object you need an extra get() call to
|
||||
* access the value stored in the reference wrapper.
|
||||
*
|
||||
* This does not rebind operator=() as std::optional does. Instead, assigning a value
|
||||
* to this object will simply change the object to which it points. To change the value
|
||||
* of the referred to object, use value() or one of the other operators.
|
||||
* This rebinds operator=() as boost::optional does. Assigning a value to this wrapper will
|
||||
* simply change the object to which it points instead of assigning a value to the referenced
|
||||
* object. To change the value of the referenced object, perform an assignment on value()
|
||||
* or operator*.
|
||||
*
|
||||
* [1] https://www.fluentcpp.com/2018/10/05/pros-cons-optional-references/
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue