memcpy로 vector복사

Tags:

#include <iostream>
#include <vector>
#include <iterator>

using namespace std;

int main()
{
    int values[] = { 1, 2, 3 };
    vector<int> vi(values, values + 3);

    int int_ary[3];
    memcpy(int_ary, &vi[0], sizeof(int) * vi.size());
    copy(int_ary, int_ary + 3, ostream_iterator<int>(cout, " "));

    return EXIT_SUCCESS;
}

으 정말 끝장;;;

mkseo@mkseo:~/tmp$ g++ cpy_test.cpp && ./a.out
1 2 3 mkseo@mkseo:~/tmp$