Joe Buck wrote: > On Wed, Apr 19, 2006 at 01:56:46PM -0700, Mark Mitchell wrote: >> Let's accept that both the bit-preserving and value-preserving >> conversions would be useful. How do we differentiate the two? >> >> In C++, we could invent __value_cast<T> and __bitwise_cast<T>. For >> example, __bitwise_cast<int>(3.0f) would be defined as equivalent to: >> >> ({ >> union { >> int i; >> float f; >> } temp; >> temp.f = 3.0f; >> temp.i; >> }) > > Those concepts roughly correspond to the existing static_cast and > reinterpret_cast.
Indeed. (Although reinterpret_cast<int>(3.0f) is not valid C++, IIRC.) However, I'd be very hesitant to break the correspondence between static_cast and C-style casts, and it looks like the existing vector specifications require that C-style casts behave like __bitwise_cast. A C-style cast is defined as one of a const_cast, static_cast, or reinterpret_cast, depending on the situation. So, it would be weird if static_cast did something different than a C-style cast; hence the need for __value_cast. It might be that we could safely extend reinterpret_cast to handle this case, though, making the only language addition __value_cast, which would be there to work around the language impurity introduced by the original vector specifications. -- Mark Mitchell CodeSourcery [EMAIL PROTECTED] (650) 331-3385 x713