Skip to content

Commit ed2413e

Browse files
authored
Merge pull request #142 from steve-downey/fixdocs
Improve and repair some docs
2 parents e9cbfb1 + 5f01c39 commit ed2413e

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

include/beman/optional/optional.hpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,31 +1662,35 @@ class optional<T&> {
16621662

16631663
// \ref{optionalref.assign}, assignment
16641664
/**
1665-
* @brief Assignment operator.
1665+
* @brief Nullopt assignment operator.
16661666
*
16671667
* @return optional&
1668+
*
1669+
* @details
1670+
* Destroys the current value if there is one, and leaves the optional
1671+
* in an empty state.
16681672
*/
16691673
constexpr optional& operator=(nullopt_t) noexcept;
16701674

16711675
/**
1672-
* @brief Copy assignment operator.
1676+
* @brief Assignment operator.
16731677
*
16741678
* @param rhs
16751679
* @return optional&
1680+
* @details
1681+
* If `rhs` has a value, assigns it to the stored value. Otherwise resets
1682+
* the stored value in `*this`.
16761683
*/
16771684
constexpr optional& operator=(const optional& rhs) noexcept = default;
16781685

16791686
/**
1680-
* @brief Converting copy assignment operator.
1687+
* @brief Emplaces a new value in the optional, destroying the current one if
16811688
*
16821689
* @tparam U
16831690
* @param u
1684-
* @return optional&
1691+
* @return T&
16851692
* @details
1686-
* If `rhs` has a value, assigns it to the stored value. Otherwise resets
1687-
* the stored value in `*this`.
1688-
* If `T&` can be constructed from a temporary, this assignment operator
1689-
* is deleted to prevent binding a temporary to a reference.
1693+
* Constructs the stored value from `u` if it is convertible to `T&`.
16901694
*/
16911695
template <class U>
16921696
requires(std::is_constructible_v<T&, U> && !detail::reference_constructs_from_temporary_v<T&, U>)
@@ -1722,6 +1726,7 @@ class optional<T&> {
17221726
* @return T*
17231727
*/
17241728
constexpr T* operator->() const noexcept;
1729+
17251730
/**
17261731
* @brief Returns a reference to the stored value.
17271732
*
@@ -1735,6 +1740,7 @@ class optional<T&> {
17351740
* @return bool
17361741
*/
17371742
constexpr explicit operator bool() const noexcept;
1743+
17381744
/**
17391745
* @brief Checks if the optional has a value.
17401746
*
@@ -1766,6 +1772,10 @@ class optional<T&> {
17661772
* @tparam F
17671773
* @param f
17681774
* @return auto
1775+
*
1776+
* @details
1777+
* The return type is the same as \tcode{std::invoke_result_t<F, T&>},
1778+
* but wrapped in an optional. The function \p f must return an optional type.
17691779
*/
17701780
template <class F>
17711781
constexpr auto and_then(F&& f) const;
@@ -1776,6 +1786,10 @@ class optional<T&> {
17761786
* @tparam F
17771787
* @param f
17781788
* @return optional<std::invoke_result_t<F, T&>>
1789+
*
1790+
* @details
1791+
* The return type is the same as \tcode{std::invoke_result_t<F, T&>},
1792+
* but wrapped in an optional.
17791793
*/
17801794
template <class F>
17811795
constexpr optional<std::invoke_result_t<F, T&>> transform(F&& f) const;
@@ -1786,6 +1800,9 @@ class optional<T&> {
17861800
* @tparam F
17871801
* @param f
17881802
* @return optional
1803+
* @details
1804+
* The return type is the same as the return type of \p f, which must
1805+
* return an optional type.
17891806
*/
17901807
template <class F>
17911808
constexpr optional or_else(F&& f) const;

0 commit comments

Comments
 (0)