$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2002-06-27 01:57:48
Gennaro Prota wrote:
>
> [Cool idea snipped]
> But I suspect there's not much interest in this.
At least it integrates with the current version easily:
--- declare array_traits like this (directly after 'namespace boost')
---
template< typename T, int D = 0 > class array_traits
{
private:
BOOST_STATIC_ASSERT( ::boost::is_array< T >::value );
typedef typename remove_bounds< T >::type base_type;
public:
typedef typename array_traits< base_type, D-1 >::value_type
value_type;
typedef typename array_traits< base_type, D-1 >::iterator
iterator;
typedef typename array_traits< base_type, D-1 >::reference
reference;
BOOST_STATIC_CONSTANT( std::size_t, size = sizeof( base_type ) /
sizeof( value_type ) );
};
--- make the old array_traits a specialization:
template< typename T > class array_traits< T, 0 >
{
...unchanged from previous version...
};
--- Add these functions where they belong ---
template< int D, typename T >
std::size_t
inline array_size( T& )
{
return ::boost::array_traits< T, D >::size;
}
template< int D, typename T, std::size_t N >
const char ( &array_to_sizeof( T(&)[N] ) )[ array_traits< D, T[N]
>::size ];
template< int D, typename T, std::size_t N >
const char ( &array_to_sizeof( const T(&)[N] ) )[ array_traits< D,
T[N] >::size ];
template< int D, typename T, std::size_t N >
const char ( &array_to_sizeof( volatile T(&)[N] ) )[ array_traits< D,
T[N] >::size ];
template< int D, typename T, std::size_t N >
const char ( &array_to_sizeof( const volatile T(&)[N] ) )[
array_traits< D, T[N] >::size ];
...
}
Merging it with the old source should be a problem, if it is, I could
post the complete code again...
The question that remains is: Is it useful? Does it have a good syntax?
Regards, Daniel
--
Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de