You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a conversion can be interpreted in more than one way as a static_cast followed by a const_cast, the conversion is ill-formed.
In the following, we see that the choice of static_cast can differ between casting to an lvalue reference type or an rvalue reference type.
structA {};
structB : A {};
const B b;
voidf() {
(A &&)b; // ill-formed?const_cast<A &&>(static_cast<const A &>(b));
const_cast<A &&>(static_cast<constvolatile A &&>(b));
}
Suggested resolution:
If a conversion can be interpreted in more than one way as a static_cast, not arbitrarily adding cv-qualification and to an rvalue reference type if and only if converting to an rvalue reference type, followed by a const_cast, the conversion is ill-formed.