Re: [boost] [bitfield] Initial bitfield proposal available inthevault

"Emile Cormier" wrote
Martin is on to something about using pointers. I'm not sure I am. I was trying to explain (and failing) why structs may be larger than their embedded data. (By making the struct larger,
----Original Message---- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Andy Little Sent: 08 March 2006 03:42 To: boost@lists.boost.org Subject: Re: [boost] [bitfield] Initial bitfield proposal available inthevault the pointer can be smaller).
Surely any pointer must be capable of being converted to a void* which means void* has to know about the extra bits? How does that work?
sizeof(struct*) <= sizeof(void*) sizeof(char*)==sizeof(void*) Note that if you cast an unsigned char* to an arbitrary struct* and back, you are **NOT** guaranteed to get your original pointer back. On the other hand you are guaranteed that casting an arbitrary pointer to struct to another pointer to struct and back will return you the original value.
I would have thought it would be possible to reinterpret_cast (or somehow convert) the struct to the inbuilt type in these situations isnt it thus fooling the compiler into storing that type? The problem I see is that there seems to be two types of pointers here which doesnt seem to be standard C++ behaviour?
It is, oh it is! -- Martin Bonner Martin.Bonner@Pitechnology.com Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ, ENGLAND Tel: +44 (0)1223 203894
participants (1)
-
Martin Bonner