2990. optional::value_type is not always a value type

Section: 23.6.3 [optional.optional] Status: New Submitter: Casey Carter Opened: 2017-06-27 Last modified: 2017-07-12

Priority: 3

View other active issues in [optional.optional].

View all other issues in [optional.optional].

View all issues with New status.

Discussion:

optional<T>::value_type is T, which can be a cv-qualified object type. This is inconsistent with the uses of the name value_type elsewhere in the standard. We should either require optional<T>::value_type to be remove_cv_t<T> — a true value type — or rename the type alias to element_type.

[2017-07 Toronto Tuesday PM issue prioritization]

Priority 3; may also affect array

Proposed resolution:

This wording is relative to N4659.

  1. Edit 23.6.3 [optional.optional], class template optional synopsis, as indicated:

    template <class T>
      class optional {
      public:
        using value_type = remove_cv_t<T>;
        […]
      };