Paragraph 4 of [expr.cast] (in the latest draft of the C++ standard available at the time of writing) which describes the behaviour of a C-style cast says the following:
The conversions performed by
- a
const_cast,- a
static_cast,- a
static_castfollowed by aconst_cast,- a
reinterpret_cast, or- a
reinterpret_castfollowed by aconst_cast,can be performed using the cast notation of explicit type conversion. The same semantic restrictions and behaviors apply, with the exception that in performing a
static_castin the following situations the conversion is valid even if the base class is inaccessible:
- a pointer to an object of derived class type or an lvalue or rvalue of derived class type may be explicitly converted to a pointer or reference to an unambiguous base class type, respectively;
- a pointer to member of derived class type may be explicitly converted to a pointer to member of an unambiguous non-virtual base class type;
- a pointer to an object of an unambiguous non-virtual base class type, a glvalue of an unambiguous non-virtual base class type, or a pointer to member of an unambiguous non-virtual base class type may be explicitly converted to a pointer, a reference, or a pointer to member of a derived class type, respectively.
If a conversion can be interpreted in more than one of the ways listed above, the interpretation that appears first in the list is used, even if a cast resulting from that interpretation is ill-formed. If a conversion can be interpreted in more than one way as a
static_castfollowed by aconst_cast, the conversion is ill-formed. [...]
My question is how can "a conversion be interpreted in more than one way as a static_cast followed by a const_cast"?
Thank you.
int const **and another toint* const *. The C-style cast is toint**Demo - Igor Tandetnik