Title
LWG 2756 breaks class template argument deduction for optional
Status
resolved
Section
[optional.optional]
Submitter
Richard Smith

Created on 2016-11-24.00:00:00 last changed 41 months ago

Messages

Date: 2020-11-09.22:09:58
Resolved by

Rationale:

P0433R2.
Date: 2020-11-09.00:00:00

[ 2020-11-09 Resolved for C++20. Status changed: Tentatively Resolved → Resolved. ]

Date: 2020-05-15.00:00:00

[ 2020-05-29; Billy Baker comments ]

At Kona 2017, P0433R2 was accepted and added Ville's deduction guide rather than one proposed in P0433R0.

Date: 2017-01-30.00:00:00

[ 2017-01-30 Ville comments: ]

Seems like the problem is resolved by a simple deduction guide:

template <class T> optional(T) -> optional<T>;

The paper p0433r0 seems to suggest a different guide,

template<class T> optional(T&& t) -> optional<remove_reference_t<T>>;

but I don't think the paper is up to speed with LWG 2756. There's no reason to use such an universal reference in the guide and remove_reference in its target, just guide with T, with the target optional<T>, optional's constructors do the right thing once the type has been deduced.

Date: 2017-01-27.00:00:00

[ 2017-01-27 Telecon ]

Priority 2

Date: 2016-11-24.00:00:00

LWG 2756 applies these changes:

constexpr optional(const T&);
constexpr optional(T&&);
template <class... Args> constexpr explicit optional(in_place_t, Args&&...);
template <class U, class... Args>
  constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...);
template <class U = T> EXPLICIT constexpr optional(U&&);
template <class U> EXPLICIT optional(const optional<U>&);
template <class U> EXPLICIT optional(optional<U>&&);

These break the ability for optional to perform class template argument deduction, as there is now no way to map from optional's argument to the template parameter T.

History
Date User Action Args
2020-11-09 22:09:58adminsetmessages: + msg11597
2020-05-31 09:54:47adminsetmessages: + msg11312
2020-05-31 09:54:47adminsetmessages: + msg11311
2020-05-31 09:54:47adminsetstatus: lewg -> resolved
2017-01-30 15:17:53adminsetmessages: + msg8803
2017-01-30 15:17:53adminsetmessages: + msg8802
2017-01-30 15:17:53adminsetstatus: new -> lewg
2016-11-24 00:00:00admincreate