Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-12-08 01:40:32

"Reece Dunn" <msclrhd_at_[hidden]> wrote in message

> >the problem is often that you want the size of a variable and not a
> >type, eg,
> >sizer( my_array_variable );
> >which makes the code look a lot different.
> In this case, you need a macro:
> #define BOOST_ARRAYSIZE( a ) ( sizeof( a ) / sizeof( a[ 0 ] ))
> I can't see any other way of doing this on a variable.

the scheme as done in the old array_traits and as done in collection traits
is something like this:

template< typename T, size_t sz >
give_size<sz> sizer( const (T&)[sz] ); // no definition necessary

and we can use it like

sizeof( sizer( array_var ) );



Boost list run by bdawes at, gregod at, cpdaniel at, john at