[C++0x unique_ptr] sorting a vector of unique_ptr fails
Ian Lance Taylor
iant@google.com
Mon Dec 15 19:30:00 GMT 2008
René Bürgel <rbuergel@web.de> writes:
> 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());
> }
I think it is supposed to work. The standard says that the value
must be Swappable, MoveConstructible, and MoveAssignable. I think
that std::unique_ptr meets those requirements.
I think this is a bug in libstdc++-v3. Looking at the code, I think
this means that __introsort_loop can't assume that it can pass values
to std::__median.
Ian
More information about the Gcc-help
mailing list