public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++0x unique_ptr] sorting a vector of unique_ptr fails
@ 2008-12-13 17:35 René Bürgel
  2008-12-15 19:30 ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: René Bürgel @ 2008-12-13 17:35 UTC (permalink / raw)
  To: gcc-help

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é

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-12-17  0:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-13 17:35 [C++0x unique_ptr] sorting a vector of unique_ptr fails René Bürgel
2008-12-15 19:30 ` Ian Lance Taylor
2008-12-15 20:22   ` Christopher Jefferson
2008-12-15 23:46     ` René Bürgel
2008-12-16  6:14       ` Ian Lance Taylor
2008-12-17  0:44         ` René Bürgel
2008-12-17  0:50           ` Diego Novillo
2008-12-17  1:06             ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).