Article ID: 168404
Article Last Modified on 10/17/2003
//test1.cpp
//Compiler options needed: /GX
#include <list>
int main()
{
int INTARRAY[4] = {1, 2, 3, 4} ;
std::list<int> INTLIST(INTARRAY, INTARRAY + 4) ; //C2664 here
}
The exact error message for the above sample is:
The following sample demonstrates Workaround 1:
//test2.cpp
//Compiler options needed: /GX
#include <list>
int main()
{
int INTARRAY[4] = {1, 2, 3, 4} ;
std::list<int> INTLIST ;
for(int i = 0; i < 4; i++)
INTLIST.push_back(INTARRAY[i]) ;
return 0 ;
}
The following sample demonstrates Workaround 2:
//test3.cpp
//Compiler options needed: /GX
#include <list>
#include <algorithm>
int main()
{
int INTARRAY[4] = {1, 2, 3, 4} ;
std::list<int> INTLIST(4) ;
std::copy(INTARRAY, INTARRAY + 4, INTLIST.begin()) ;
return 0 ;
}
Additional query words: list copy push_back
Keywords: kbbug kbfix kbvc600fix kbprb kbcpponly kbcompiler KB168404