22-08-2024, 07:58 PM
Hello,
Rule 7.0.1 allows for an explicit cast from bool to T when T has a converting constructor with a parameter of type bool. The example for the rule shows:
struct A
{
explicit A ( bool );
};
A anA { true }; // Compliant - constructor
Yet, C++ requires a converting constructor to be non-explicit.
I'm not sure what the intent is, but perhaps the rule should allow for an explicit cast from B to T when T has an explicit constructor that takes a single parameter, a parameter of (possibly const-qualified) type bool.
Please advise. Thank you.
Rule 7.0.1 allows for an explicit cast from bool to T when T has a converting constructor with a parameter of type bool. The example for the rule shows:
struct A
{
explicit A ( bool );
};
A anA { true }; // Compliant - constructor
Yet, C++ requires a converting constructor to be non-explicit.
I'm not sure what the intent is, but perhaps the rule should allow for an explicit cast from B to T when T has an explicit constructor that takes a single parameter, a parameter of (possibly const-qualified) type bool.
Please advise. Thank you.