stereomatching 17 Posting Whiz in Training

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.