problems of unique_ptr

compiler : gcc4.6.2(minGW), vc2010
os : win7 64bits

1
2
3
4
5
6
7
int A[10];
	srand(0);
	std::generate(A, A + sizeof_array(A), [](){ return rand() % 100; } );
	std::vector< std::unique_ptr<int> > v;
	std::for_each(A, A + sizeof_array(A), [&](int const Cur){ v.push_back(std::unique_ptr<int>( new int(Cur) )); } );
	std::sort( v.begin(),v.end() ); //result {1,4,8}
	for(auto it = v.begin(); it != v.end(); ++it) std::cout<<**it<<std::endl;


Both of the compilers give me error results.
Is this a bug of g++ and vc2010?
Thanks

Last edited on
Topic archived. No new replies allowed.