optional_reference: fix documentation

This commit is contained in:
Charles Dang 2021-07-18 21:10:39 -04:00
parent 88873e3fae
commit aa37086572

View file

@ -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/
*/