Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2002-11-24 14:40:04


On Sun, Nov 24, 2002 at 06:30:46PM +0100, Dirk Gerrits wrote:
> Pavol Droba wrote:
>
> > 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 );
> > }
> >
> > template< typename T >
> > inline T offset_cast( const void* p, unsigned int offset=0 )
> > {
> > return reinterpret_cast< T >( static_cast( p )+offset );
> > }
>
> Why only unsigned offsets?

That was what I needed, but there is no reason why not to support negative
offset as well.

Pavol


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk