Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2006-11-26 14:39:36


When I was adding tests to a bignum class, I ran into a problem with:

//========================================================================
std::size_t const biggest = 27u, length = biggest + 1u;
boost::counting_iterator<bignum> const cb( 0u ), ce( length );
std::vector<bignum> inputs;

inputs.reserve( length );
std::copy( cb, ce, std::back_inserter(inputs) );
//========================================================================

There is a conversion from uintmax_t, but not TO any numeric built-in type.
It also has a numeric_limits specialization. This is giving me an error,
saying that it wants to convert my type to int, which isn't possible. It
seems that my implementation of std::copy exploits random-access iterators,
which a counting-iterator usually is, and takes a difference, which uses a
difference_type of int, which chokes due to my type not having a suitable
conversion. [Looking at the docs....] I guess that I need to change the
CategoryOrTraversal and/or Difference parameters to counting_iterator,
right? For now, I just have a manual loop:

//========================================================================
for ( boost::counting_iterator<bignum> i = cb ; ce != i ; ++i )
{
    inputs.push_back( *i );
}
//========================================================================

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

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