[C++0x unique_ptr] sorting a vector of unique_ptr fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

Is the following code supposed to work in C++0x-Mode or am i just doing something wrong?

#include <memory>
#include <vector>
#include <algorithm>

int main()
{
       std::vector<std::unique_ptr<int> > v;
       std::sort(v.begin(), v.end());
}


g++-4.4.0-alpha20081107 -std=c++0x bug.cpp gives me:

In file included from /usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081107/include/g++-v4/algorithm:67, from ../../bug.cpp:3: /usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081107/include/g++-v4/bits/unique_ptr.h: In function 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::unique_ptr<int, std::default_delete<int> >*, std::vector<std::unique_ptr<int, std::default_delete<int> >, std::allocator<std::unique_ptr<int, std::default_delete<int> > > > >, _Size = int]': /usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081107/include/g++-v4/bits/stl_algo.h:5152: instantiated from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<std::unique_ptr<int, std::default_delete<int> >*, std::vector<std::unique_ptr<int, std::default_delete<int> >, std::allocator<std::unique_ptr<int, std::default_delete<int> > > > >]' ../../bug.cpp:10: instantiated from here /usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081107/include/g++-v4/bits/unique_ptr.h:215: error: deleted function 'std::unique_ptr<_Tp, _Tp_Deleter>::unique_ptr(const std::unique_ptr<_Tp, _Tp_Deleter>&) [with _Tp = int, _Tp_Deleter = std::default_delete<int>]' /usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081107/include/g++-v4/bits/stl_algo.h:2249: error: used here
[...]


Thanks in advance
René

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux