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.
Section: 22.5.9 [optional.specalg] Status: New Submitter: Jiang An Opened: 2021-10-23 Last modified: 2021-10-24
View all issues with New status.
Three std::make_optional overloads are specified in 22.5.9 [optional.specalg]. The first one is specified by "Returns:" and the other two are specified by "Effects: Equivalent to:". According to 18.104.22.168 [structure.specifications]/4, such uses of "Effects: Equivalent to:" propagate the Constraints specified for constructors. As the selected constructor for the first overload has "Constraints:" (22.214.171.124 [optional.ctor]/22), it seems that inconsistency is introduced here.Existing implementations are inconsistent: libstdc++ constrains all three overloads, while libc++ and MSVC STL do not constrain any of them. IMO all three overloads should be constrained.
[2022-01-29; Reflector poll]
Set priority to 3 after reflector poll.
This wording is relative to N4901.
Modify 22.5.9 [optional.specalg] as indicated:
template<class T> constexpr optional<decay_t<T>> make_optional(T&& v);
Returns: optional<decay_t<T>>(std::forward<T>(v)) .