Re: The joy of type aliasing and C
"Alen Ladavac" <[email protected]>
| Newsgroups | gmane.games.devel.general |
|---|---|
| Message-ID | <[email protected]> |
> 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 ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click _______________________________________________ Gamedevlists-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gamedevlists-general Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=557