Created on 2023-02-10.00:00:00 last changed 22 months ago
Consider:
struct A { A(); virtual constexpr int f() { return 1; } }; struct B : A { virtual constexpr int f() { return 2; } }; B b; // not constexpr auto &id = typeid(b); // error, not constant
The example had been valid, but became invalid under P2280. The same happened for dynamic_cast. Furthermore, P2280 seems to be missing a change for static_cast from base to derived and for pointer-to-member access expressions, which both depend on the dynamic type and have historically been required to work.
Maybe a better rule would be that objects (not references) whose lifetime did not begin within E are treated as having a dynamic type that is their declared type.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-02-10 00:00:00 | admin | create |