Problème entre boost::array std::copy et les vector
Bonjour à tous.
J'ai un petit code, rien de bien compliqué mais ca plante quand même et je ne comprend pas pourquoi.
Voici le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <algorithm>
#include <iostream>
#include <vector>
#include <boost/array.hpp>
//using namespace boost::assign;
using namespace std;
int main()
{
boost::array<int,5> array1; array1.assign(42);
std::vector<int> result;
copy(array1.begin(),array1.end(),result.begin()); //la ligne fautive
cout<<"s: "<<result.size()<<endl;
for(int i=0;i<result.size();i++)
cout<<result[i]<<" "<<i<<endl;
return 0;
} |
Comme indiqué, ca cplante sur std::copy et je en comprend pas pourquoi.
Quelqu'un à t'il une idée ?
Annexe:
le backtrace de gdb:
Citation:
#0 0xb7da22f3 in memmove () from /lib/i686/cmov/libc.so.6
#1 0x08048e36 in std::__copy<true, std::random_access_iterator_tag>::copy<int>
()
#2 0x08048e71 in std::__copy_aux<int*, int*> ()
#3 0x08048ea1 in std::__copy_normal<false, true>::__copy_n<int*, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > > > ()
#4 0x08048eed in std::copy<int*, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > > > ()
#5 0x08048a85 in main ()
*Code compilé avec g++ 4.2.3 sous windows et linux.
Merci.
Edit: si je remplace le std::vector par un boost::array de taille suffissante, ca passe sans problème :aie: