Re: [GD-General] The joy of type aliasing and C
Brought to you by:
vexxed72
|
From: Alen L. <ale...@cr...> - 2003-12-30 10:53:58
|
> int x = ( int & ) f; > int x = * ( int * ) &f; > > In both cases 'f' is an lvalue (in this example). But it doesn't have to be. int x = ( const int & ) f; int x = * ( const int * ) &f; would work just as well. Now, this depends on definition of lvalue. Perhaps (const int &) might be considered an lvalue, but according to the origin of the name, it should be rvalue (lvalue is by definition of name "value that can be used on the left side of assignment expression"). I didn't check the standard, but I guess that they define lvaue somewhat different, marking those two examples as "constant lvalue", and making my note pointless. Anyway, it was quite a digression. What might be of more interest is: What does C++98 say on using reinterpret_cast? i = reinterpret_cast<int&>(f); The reinterpret_cast operator is _designed_ to be used for type punning, isn't it? -- Alen |