Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-09-13 13:09:34


Eric Niebler <eric <at> boost-consulting.com> writes:

>
>
> Thorsten Ottosen wrote:
> >
> > Btw, my range_size uses this code
> >
> > template< class T >
> > struct add_unsigned;

> > Can anybody spot weaknesses in that approach?
> >
>
> Well, you haven't defined a primary template, so add_unsigned<unsigned>
> will not compile. IMO, your primary template should "typedef T type;".
> But depending on what you're trying to do, this may work, and it's a lot
> shorter:
>
> template< typename Int >
> struct add_unsigned {
> typedef typename boost::uint_t<
> sizeof(Int) * CHAR_BIT
> >::least type;
> };

right, it shorter.

I wanted to remove the need for specializing range_size<>
but apparently this relation does not hold for all implementations:

sizeof( container::size_type ) == sizeof( container::iterator::difference_type )

:-( what a shame.

-Thorsten


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