|
Boost-Build : |
Subject: [Boost-build] [range] size works only with random access ranges
From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2010-08-04 06:57:03
Hello,
Why the size primitive only works with random access range?
Shouldn't it be implemented generically?
It is implemented like this in boost 1.43.0:
template< class T >
inline BOOST_DEDUCED_TYPENAME range_difference<T>::type size( const T& r )
{
BOOST_ASSERT( (boost::end( r ) - boost::begin( r )) >= 0 &&
"reachability invariant broken!" );
return boost::end( r ) - boost::begin( r );
}
Which requires a binary operator- for the iterator type.
Regards,
-- Felipe Magno de Almeida
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk