Re: [boost] offset_cast proposal

2002-11-25 Thread Terje Slettebø
>From: "Pavol Droba" <[EMAIL PROTECTED]> > On Mon, Nov 25, 2002 at 04:52:35PM +0100, Terje Sletteb? wrote: > > >From: "Pavol Droba" <[EMAIL PROTECTED]> > > > > > I can imagine it should be something like this: > > > > > > void modify_binary_header( void* pData ) > > > { > > > binary_struct b; > >

Re: [boost] offset_cast proposal

2002-11-25 Thread Pavol Droba
On Mon, Nov 25, 2002 at 04:52:35PM +0100, Terje Sletteb? wrote: > >From: "Pavol Droba" <[EMAIL PROTECTED]> > > > On Mon, Nov 25, 2002 at 02:47:54PM +0100, Terje Sletteb? wrote: > > > > > How did you do it on the ARM? As I understand, it requires > > > word-alignment > > > for words (and half-word

Re: [boost] offset_cast proposal

2002-11-25 Thread Terje Slettebø
>From: "Pavol Droba" <[EMAIL PROTECTED]> > On Mon, Nov 25, 2002 at 02:47:54PM +0100, Terje Sletteb? wrote: > > > How did you do it on the ARM? As I understand, it requires word-alignment > > for words (and half-word alignment for half-words, if that is supported on > > the given ARM version). > >

Re: [boost] offset_cast proposal

2002-11-25 Thread Pavol Droba
On Mon, Nov 25, 2002 at 02:47:54PM +0100, Terje Sletteb? wrote: [snip] > As you say, and as was pointed out at the start of the thread, it may work > on a specific platform (like x86). Perhaps it could be possible to have code > that detects the platform, and which could then report an error on >

Re: [boost] offset_cast proposal

2002-11-25 Thread Terje Slettebø
>From: "Pavol Droba" <[EMAIL PROTECTED]> > > > On Sun, Nov 24, 2002 at 07:27:42PM +0100, Terje Sletteb? wrote: > > > > For example, if you have a buffer like this (starting at an aligned > > address): > > > > +0 - One byte > > +1 - Number 1 > > +5 - Number 2 > > +9 - Number 3 > > > > Even if you h

Re: [boost] offset_cast proposal

2002-11-25 Thread Pavol Droba
On Sun, Nov 24, 2002 at 11:18:10PM +0100, Terje Sletteb? wrote: > > On Sun, Nov 24, 2002 at 07:27:42PM +0100, Terje Sletteb? wrote: > > > >From: "Pavol Droba" <[EMAIL PROTECTED]> > > > > > > > > Reinterpret-cast could be avoided like this: > > > > > > > > template< typename T > > > > > inline T* of

Re: [boost] offset_cast proposal

2002-11-24 Thread Terje Slettebø
> On Sun, Nov 24, 2002 at 07:27:42PM +0100, Terje Sletteb? wrote: > > >From: "Pavol Droba" <[EMAIL PROTECTED]> > > > > > > Reinterpret-cast could be avoided like this: > > > > > > template< typename T > > > > inline T* offset_cast( void* p, unsigned int offset=0 ) > > > { > > > return static_cas

Re: [boost] offset_cast proposal

2002-11-24 Thread Pavol Droba
On Sun, Nov 24, 2002 at 07:27:42PM +0100, Terje Sletteb? wrote: > >From: "Pavol Droba" <[EMAIL PROTECTED]> > > > > The prerequisite I haven't mentioned is that if you wan to use a structure > to > > map to such a buffer, it has to have 1 byte aligmnent. Most of the > compilers > > allow this kind o

Re: [boost] offset_cast proposal

2002-11-24 Thread Terje Slettebø
>From: "Pavol Droba" <[EMAIL PROTECTED]> Sorry for sending this as several mails. > template< typename T > > inline T offset_cast( void* p, unsigned int offset=0 ) > { > return reinterpret_cast< T >( static_cast( p )+offset ); > } There is also the issue of the interface. This "cast", unlike th

Re: [boost] offset_cast proposal

2002-11-24 Thread Terje Slettebø
>From: "Pavol Droba" <[EMAIL PROTECTED]> > > The prerequisite I haven't mentioned is that if you wan to use a structure to > map to such a buffer, it has to have 1 byte aligmnent. Most of the compilers > allow this kind of specification with pragmas. > > Reinterpret-cast could be avoided like this:

Re: [boost] offset_cast proposal

2002-11-24 Thread Pavol Droba
On Sun, Nov 24, 2002 at 04:59:45PM +0100, Terje Sletteb? wrote: > >From: "Pavol Droba" <[EMAIL PROTECTED]> > > > On Sun, Nov 24, 2002 at 01:26:05PM +0100, Terje Sletteb? wrote: > > > >From: "Pavol Droba" <[EMAIL PROTECTED]> > > > > > > > I have developed a simple cast function which I found very u

Re: [boost] offset_cast proposal

2002-11-24 Thread Terje Slettebø
>From: "Pavol Droba" <[EMAIL PROTECTED]> > On Sun, Nov 24, 2002 at 01:26:05PM +0100, Terje Sletteb? wrote: > > >From: "Pavol Droba" <[EMAIL PROTECTED]> > > > > > I have developed a simple cast function which I found very useful. Here it > > is: > > > > > > template< typename T > > > > inline T off

Re: [boost] offset_cast proposal

2002-11-24 Thread Pavol Droba
On Sun, Nov 24, 2002 at 01:26:05PM +0100, Terje Sletteb? wrote: > >From: "Pavol Droba" <[EMAIL PROTECTED]> > > > I have developed a simple cast function which I found very useful. Here it > is: > > > > template< typename T > > > inline T offset_cast( void* p, unsigned int offset=0 ) > > { > > ret

Re: [boost] offset_cast proposal

2002-11-24 Thread David Abrahams
Pavol Droba <[EMAIL PROTECTED]> writes: > Hi, > > I have developed a simple cast function which I found very useful. Here it is: > > template< typename T > > inline T offset_cast( void* p, unsigned int offset=0 ) > { > return reinterpret_cast< T >( static_cast( p )

Re: [boost] offset_cast proposal

2002-11-24 Thread Terje Slettebø
>From: "Pavol Droba" <[EMAIL PROTECTED]> > I have developed a simple cast function which I found very useful. Here it is: > > template< typename T > > inline T offset_cast( void* p, unsigned int offset=0 ) > { > return reinterpret_cast< T >( static_cast( p )+offset ); > } > > template< typename T

[boost] offset_cast proposal

2002-11-24 Thread Pavol Droba
Hi, I have developed a simple cast function which I found very useful. Here it is: template< typename T > inline T offset_cast( void* p, unsigned int offset=0 ) { return reinterpret_cast< T >( static_cast( p )+offset ); } templat