Title
Class template expected synopsis contains declarations that do not match the detailed description
Status
c++23
Section
[expected.object.general]
Submitter
S. B. Tam

Created on 2022-08-23.00:00:00 last changed 13 months ago

Messages

Date: 2022-11-17.00:42:33

Proposed resolution:

This wording is relative to n4917.

  1. Change [expected.object.general] as indicated:

    // 22.8.6.2, constructors
    constexpr expected();
    constexpr expected(const expected&);
    constexpr expected(expected&&) noexcept(see below);
    template<class U, class G>
      constexpr explicit(see below) expected(const expected<U, G>&);
    template<class U, class G>
      constexpr explicit(see below) expected(expected<U, G>&&);
    
    template<class U = T>
      constexpr explicit(see below) expected(U&& v);
    
    template<class G>
      constexpr explicit(see below) expected(const unexpected<G>&);
    template<class G>
      constexpr explicit(see below) expected(unexpected<G>&&);
    
    template<class... Args>
      constexpr explicit expected(in_place_t, Args&&...);
    
  2. Change [expected.void.general] as indicated:

    // 22.8.7.2, constructors
    constexpr expected() noexcept;
    constexpr expected(const expected&);
    constexpr expected(expected&&) noexcept(see below);
    template<class U, class G>
      constexpr explicit(see below) expected(const expected<U, G>&&);
    
    template<class G>
      constexpr explicit(see below) expected(const unexpected<G>&);
    template<class G>
      constexpr explicit(see below) expected(unexpected<G>&&);
    
    constexpr explicit expected(in_place_t) noexcept;
    
Date: 2022-11-12.00:00:00

[ 2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Voting → WP. ]

Date: 2022-09-15.00:00:00

[ 2022-09-07; Moved to "Ready" at LWG telecon ]

Date: 2022-09-15.00:00:00

[ 2022-09-05; Jonathan Wakely provides wording ]

In n4910 the expected synopses had explicit(see below) on the copy and move constructors. That was fixed editorially, but this other inconsistency was not noticed.

Date: 2022-08-23.00:00:00

[expected.object.general] declares the following constructors:

template<class G>
  constexpr expected(const unexpected<G>&);
template<class G>
  constexpr expected(unexpected<G>&&);

But in [expected.object.ctor], these constructors are declared as:

template<class G>
  constexpr explicit(!is_convertible_v<const G&, E>) expected(const unexpected<G>& e);
template<class G>
  constexpr explicit(!is_convertible_v<G, E>) expected(unexpected<G>&& e);

Note that they have no explicit-specifiers in [expected.object.general], but are conditionally explicit in [expected.object.ctor].

I presume that [expected.object.general] is missing a few explicit(see below).

The same inconsistency exists in [expected.void].

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2022-11-17 00:42:33adminsetmessages: + msg13063
2022-11-17 00:42:33adminsetstatus: voting -> wp
2022-11-08 03:46:49adminsetstatus: ready -> voting
2022-09-07 17:14:22adminsetmessages: + msg12747
2022-09-07 17:14:22adminsetstatus: new -> ready
2022-09-07 08:38:53adminsetmessages: + msg12746
2022-09-07 08:38:53adminsetmessages: + msg12745
2022-08-23 00:00:00admincreate