|
Boost : |
Subject: [boost] [Range] Confusing result of iterator_range::size()
From: Sergey Voropaev (serge-voropaev_at_[hidden])
Date: 2011-11-03 02:42:09
Hi,
I try use boost::iterator_range as replacement for some standard container in my
code. The function iterator_range::size() has non standart declaration:
difference_type size() const;
but not:
size_type size() const
When I compile code in VC++ 2010 I have a some warning and error. For example:
#include <boost/range.hpp>
#include <vector>
#include <algorithm>
int main()
{
int aaa[10] ={1,2,3,4,5,6,7,8,9,10};
std::vector<int> bbb(20);
boost::iterator_range<int*> arr(aaa);
if(bbb.size() > arr.size()) //warning C4018: '>' : signed/unsigned mismatch
{
}
const size_t lng = std::min(bbb.size(), arr.size());
//error C2780: 'const _Ty &std::min(const _Ty &,const _Ty &,_Pr)' : expects 3
arguments - 2 provided
//error C2782: 'const _Ty &std::min(const _Ty &,const _Ty &)' : template
parameter '_Ty' is ambiguous
// const size_t lng = std::min(bbb.size(), (size_t)arr.size()); //OK
for(size_t i = 0; i < lng; ++i)
{
bbb[i] = arr[i];
}
return 0;
}
I think declaration of boost::iterator_range must be fixed. Or there was some
reason for this non standard declaration?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk