Details
-
Epic
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
None
-
C++20 explicit(bool) @ Qt
Description
C++20 added support for an optional argument to explicit, similar to noexcept, which can evaluate to true or false.
This is mainly useful in implementation of wrapper types such as pair, tuple, variant and optional to "copy" the explicit'ness of the wapped-type's constructors to the wrapper's constructors.
There are two immediate effects:
- you can use explicit(false) as a moniker for /* implicit */, and, indeed, we already have Q_IMPLICIT, which does exactly that, which leads to the obvious coding rule that each ctor you define should be either explicit or Q_IMPLICIT.
- it should prompt us to inspect our own wrapper types (do we have any?) for consistent explicit copying. The effect of explicit(bool) can be emulated in C++17 by defining the same ctor twice, one with explicit and once without and SFINAE'ing out one or the other, depending on the same condition you'd put into explicit(bool).
Both of these can be done already.
Attachments
Issue Links
- is required for
-
QTBUG-99243 Initiative: Qt and C++20
- Open
-
QTBUG-109362 C++20 is mandatory for users of Qt (Phase III)
- Open