'Are standard conversion sequences include explicit conversions?
I am just trying to understand what does the standard mean by "standard conversion sequences"; and I have ended up with that "standard conversion sequences" are "sequences of standard implicit conversions". But I think that's not true for some contexts; for instance, from [expr.static.cast]/7:
[..] A program is ill-formed if it uses static_cast to perform the inverse of an ill-formed standard conversion sequence.
struct B { };
struct D : private B { };
void f() {
static_cast<D*>((B*)0); // error: B is a private base of D
// ..
}
And General[conv.general]/1 states:
Standard conversions are implicit conversions with built-in meaning. [..] A standard conversion sequence is a sequence of standard conversions in the following order:
- [..]
- (1.2) Zero or one conversion from the following set: integral promotions, floating-point promotion, integral conversions, floating-point conversions, floating-integral conversions, pointer conversions, pointer-to-member conversions, and boolean conversions.
- [..]
As I know, I think that a standard conversion sequence is only implicit conversions not including any explicit conversion. I mean the above conversion (B*)0 is explicit pointer conversion, even though the standard said that this conversion is ill-formed standard conversion sequance.
So if my thinking is true, why is this explicit cast expression (B*)0 is said to be standard conversion sequence and it is an implicit conversion not explicit?
From this answer on a some question:
the standard conversion is a set of built-in rules the compiler can apply when converting one type to another. Those built-in conversions include:
- No conversions
- Lvalue-to-rvalue conversion
- Array-to-pointer conversion
- Function-to-pointer conversion
- Qualification conversions
- Integral promotions
- Floating point promotion
- Integral conversions
- Floating point conversions
- Floating-integral conversions
- Pointer conversions
- Pointer to member conversions
- Boolean conversions
Given the conversions above, if those conversions are performed explicitly, do they still said to be standard conversion sequences?
In general, Are conversions performed explicitly (including C++ cast operators) said to be standard conversion sequences?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
