By @Dani-Hub , is_nothrow_convertible considers destruction of the converted object (if To is an object type) or the temporary (if To is a reference type and the temporary to bind would be created) by design. And known implementations (msvc, libc++, libstdc++) behave correctly.
For example, given a type Weird defined as
struct Weird {
Weird(int) noexcept {}
~Weird() noexcept(false) {}
};
Then std::is_nothrow_convertible_v<int, Weird> is false.
However, I suspect that wording in [meta.rel]/5 only requires the well-formedness, and whether the destruction after the initialization of To is considered as part of the conversion is not mentioned.
So "the conversion, as defined by is_convertible" in the specification of is_nothrow_convertible might not be precisely defined, and may lead to unintended comprehension, e.g. std::is_nothrow_convertible_v<int, Weird> can be true since the converting constructor itself is noexcept, although destruction of Weird is not.
By @Dani-Hub ,
is_nothrow_convertibleconsiders destruction of the converted object (ifTois an object type) or the temporary (ifTois a reference type and the temporary to bind would be created) by design. And known implementations (msvc, libc++, libstdc++) behave correctly.For example, given a type
Weirddefined asThen
std::is_nothrow_convertible_v<int, Weird>isfalse.However, I suspect that wording in [meta.rel]/5 only requires the well-formedness, and whether the destruction after the initialization of
Tois considered as part of the conversion is not mentioned.So "the conversion, as defined by
is_convertible" in the specification ofis_nothrow_convertiblemight not be precisely defined, and may lead to unintended comprehension, e.g.std::is_nothrow_convertible_v<int, Weird>can betruesince the converting constructor itself is noexcept, although destruction ofWeirdis not.