Michael DOUBEZ wrote:
> std::vector<int> vect;
> //should work
> vect.insert(&array[0],&array[sizeof(array)/sizeof(int)]);
FWIW output with your version in VC7.1, gcc4.1 and VC8 ---> below.
Which vector::insert signature is it meant to be using?
regards
Andy Little
/*
..
..
..
*/
int main()
{
int array [] = {1,2,3,4,5};
std::vector<int> vect;
/* for_each(array,push_back(vect)); */
vect.insert(&array[0],&array[sizeof(array)/sizeof(int)]);
}
Test.cpp
VC7.1 output:
d:\Projects\Test\Test.cpp(80) : error C2664:
'std::vector<_Ty>::iterator
std::vector<_Ty>::insert(std::vector<_Ty>::iterato r,const _Ty &)' :
cannot convert parameter 2 from 'int *__w64 ' to 'const int &'
with
[
_Ty=int
]
Reason: cannot convert from 'int *__w64 ' to 'const int'
This conversion requires a reinterpret_cast, a C-style cast or
function-style cast
/////////////
gcc 4.1 output:
test.cpp: In function 'int main()':
test.cpp:80: error: no matching function for call to 'std::vector<int,
std::allo
cator<int> >::insert(int*, int*)'
/opt/conceptgcc-4.1.1-alpha-4/lib/gcc/i686-pc-cygwin/4.1.1/../../../../include/c
++/4.1.1/bits/vector.tcc:93: note: candidates are: typename
std::vector<_Tp, _Al
loc>::iterator std::vector<_Tp,
_Alloc>::insert(__gnu_cxx::__normal_iterator<typ
ename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type:

ointer,
std::vector<_Tp,
_Alloc> >, const _Tp&) [with _Tp = int, _Alloc = std::allocator<int>]
/opt/conceptgcc-4.1.1-alpha-4/lib/gcc/i686-pc-cygwin/4.1.1/../../../../include/c
++/4.1.1/bits/stl_vector.h:651: note: void std::vector<_Tp,
_Alloc>::insert(__g
nu_cxx::__normal_iterator<typename std::_Vector_base<_Tp,
_Alloc>::_Tp_alloc_typ
e:

ointer, std::vector<_Tp, _Alloc> >, size_t, const _Tp&) [with _Tp =
int, _Al
loc = std::allocator<int>]
make: *** [test.o] Error 1
//////////////////
VC8,=.o output:
..\test.cpp(80) : error C2664: 'std::_Vector_iterator<_Ty,_Alloc>
std::vector<_Ty>::insert(std::_Vector_iterator<_Ty ,_Alloc>,const _Ty
&)' : cannot convert parameter 1 from 'int *' to
'std::_Vector_iterator<_Ty,_Alloc>'
with
[
_Ty=int,
_Alloc=std::allocator<int>
]
No constructor could take the source type, or constructor
overload resolution was ambiguous