17 May 2012 19:53
iter_swap on move_iterator
François Dumont <frs.dumont <at> gmail.com>
2012-05-17 17:53:55 GMT
2012-05-17 17:53:55 GMT
Hi
While working on removal of code duplications in algos
implementation I challenge them with move_iterator. I started with
stable_sort and it doesn't compile. I summarize the problem to the fact
that iter_swap can't be used on move_iterator. As, in C++11, iter_swap
simply forward to swap(*__a, *__b) it is normal that it can't accept
rvalue but shouldn't iter_swap be adapted to accept move_iterator ?
I also find the compilation error message surprising. I have added
a call to iter_swap in 24_iterators/move_iterator/greedy_ops.cc and the
error message is:
In file included from
/home/fdt/dev/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/char_traits.h:41:0,
from
/home/fdt/dev/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/ios:41,
from
/home/fdt/dev/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/ostream:40,
from
/home/fdt/dev/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/iterator:64,
from
/home/fdt/dev/gcc/libstdc++-v3/testsuite/24_iterators/move_iterator/greedy_ops.cc:20:
/home/fdt/dev/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:
(Continue reading)
RSS Feed