Boost logo

Boost :

Subject: [boost] [alogrithm] compile error with VS2008 in debug build (boost 1.38)
From: Hansi (hansipet_at_[hidden])
Date: 2009-02-18 06:52:38


Hello,

I have a strange problem. When I make a debug build from my program
which uses minmax_element I get the following compile error:

1>c:\program files\microsoft visual studio 9.0\vc\include\utility(57) :
error C2664: 'std::_Vector_iterator<_Ty,_Alloc>::_Vector_iterator(const
std::_Vector_iterator<_Ty,_Alloc> &)' : cannot convert parameter 1 from
'int *const ' to 'const std::_Vector_iterator<_Ty,_Alloc> &'
1> with
1> [
1> _Ty=int,
1> _Alloc=std::allocator<int>
1> ]
1> Reason: cannot convert from 'int *const ' to 'const
std::_Vector_iterator<_Ty,_Alloc>'
1> with
1> [
1> _Ty=int,
1> _Alloc=std::allocator<int>
1> ]
1> No constructor could take the source type, or constructor
overload resolution was ambiguous
1> d:\projects\sandbox\boosttests\statistic\statistic.cpp(43) :
see reference to function template instantiation
'std::pair<_Ty1,_Ty2>::pair<int*,int*>(const std::pair<int *,int *> &)'
being compiled
1> with
1> [
1> _Ty1=std::_Vector_iterator<int,std::allocator<int>>,
1> _Ty2=std::_Vector_iterator<int,std::allocator<int>>
1> ]
1>c:\program files\microsoft visual studio 9.0\vc\include\utility(57) :
error C2664: 'std::_Vector_iterator<_Ty,_Alloc>::_Vector_iterator(const
std::_Vector_iterator<_Ty,_Alloc> &)' : cannot convert parameter 1 from
'int *const ' to 'const std::_Vector_iterator<_Ty,_Alloc> &'
1> with
1> [
1> _Ty=int,
1> _Alloc=std::allocator<int>
1> ]
1> Reason: cannot convert from 'int *const ' to 'const
std::_Vector_iterator<_Ty,_Alloc>'
1> with
1> [
1> _Ty=int,
1> _Alloc=std::allocator<int>
1> ]
1> No constructor could take the source type, or constructor
overload resolution was ambiguous

Is this a know issue. Is something wrong in my program?

Best regards

Hansjörg

#include <algorithm>
#include <vector>
#include <iostream>
#include <boost/algorithm/minmax_element.hpp>
#include <boost/array.hpp>
#include <boost/timer.hpp>

using namespace boost;
using namespace std;

typedef array<int,100000000> dataarray;

void do_tests(dataarray& data)
{
   {
     timer t;
        std::pair< std::vector<int>::iterator, std::vector<int>::iterator >
result = boost::minmax_element(data.begin(), data.end());
     cout<<"min_max: minmax_element:"<<t.elapsed()<<endl;
     cout<<"minVal="<<*result.first<<",maxVal="<<*result.second<<endl;
   }
}

dataarray data;

int main(int argc, char const* const* argv)
{

   cout << "sorted array:" << endl;

   for(unsigned int i = 0; i< data.size();i++)
   {
     data[i] = i;
   }

   do_tests(data);

   cout << "random array:" << endl;

   std::srand(0);

   for(unsigned int i = 0; i< data.size();i++)
   {
     data[i] = std::rand();
   }

   do_tests(data);

   return 0;
}


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