Andrew Pinski <[EMAIL PROTECTED]> writes: | > You can work around this by using union's of pointers of both non-const | > and const types, but the reinterpret_cast solution would be more attractive. | > | > Thoughts? | | This has nothing to do with const vs non-const but rather | a<int> and a<const int> are two seperate types which are not related in any way. | The C++ standard defines these two types as seperate types and are not compatiable | in any way for aliasing.
??? 3.10/15: If a program attempts to access the stored value of an object through an lvalue of other than one of the following types the behavior is undefined48): -- the dynamic type of the object, -- *a cv-qualified version of the dynamic type of the object*, -- a type that is the signed or unsigned type corresponding to the dynamic type of the object, -- a type that is the signed or unsigned type corresponding to a cv-qualified version of the dynamic type of the object, -- an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union), -- a type that is a (possibly cv-qualified) base class type of the dynamic type of the object, -- a char or unsigned char type. -- Gaby