A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.github.io/LWG/issue4300 below:

Missing Returns: element in optional<T&>::emplace

This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4300. Missing Returns: element in optional<T&>::emplace

Section: 22.5.4.3 [optional.ref.assign] Status: New Submitter: Giuseppe D'Angelo Opened: 2025-07-15 Last modified: 2025-08-16

Priority: Not Prioritized

View all issues with New status.

Discussion:

The specification for optional<T&>::emplace in 22.5.4.3 [optional.ref.assign] is not specifying the returned value via a Returns: element; however the function does indeed return something (a T&). Such a Returns: element is there for the primary template's emplace (cf. 22.5.3.4 [optional.assign]).

Proposed resolution:

This wording is relative to N5014.

  1. Modify 22.5.4.3 [optional.ref.assign] as indicated:

    template<class U>
      constexpr T& emplace(U&& u) noexcept(is_nothrow_constructible_v<T&, U>);
    

    -4- Constraints: […]

    -5- Effects: Equivalent to: convert-ref-init-val(std::forward<U>(u)). -?- Returns: *val.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4