Boost logo

Boost Users :

Subject: [Boost-users] [range] boost::size wrong return type?
From: Oswin Krause (Oswin.Krause_at_[hidden])
Date: 2012-06-22 09:28:56


Hi list,

I'm using boost 1.49 and get an annoying number of signed/unsigned
comparison warnings when i use boost::size. Which is because the return
type seems to be signed

When I look at boost/range/size.hpp, i get

template<class SinglePassRange>
  inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange>::type
<--signed
size(const SinglePassRange& rng)

But the documentation for random access ranges tells otherwise:

Expression:
boost::size(a)

Return Type:
boost::range_size<X>::type

and Forward Range defines range_size as:

boost::range_size<X>::type
An unsigned integral type that can represent any nonnegative value of
the Range's distance type.

assuming the documentation does not lie, I propose the following fix

template<class SinglePassRange>
inline BOOST_DEDUCED_TYPENAME range_size<SinglePassRange>::type
size(const SinglePassRange& rng)

Greetings,
Oswin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net