[core] A better boost::swap
Hi all,
Ion Gaztañaga implemented a very good swap that used move emulation when
possible and has all the features of boost::swap:
http://www.boost.org/doc/libs/develop/boost/move/adl_move_swap.hpp
I've tried to change default implementation of ::boost::swap to
#include
2014-12-26 12:05 GMT+01:00 Antony Polukhin
Hi all,
Ion Gaztañaga implemented a very good swap that used move emulation when possible and has all the features of boost::swap: http://www.boost.org/doc/libs/develop/boost/move/adl_move_swap.hpp
I've tried to change default implementation of ::boost::swap to
#include
namespace boost { template BOOST_GPU_ENABLED void swap(T1& left, T2& right) { ::boost::adl_move_swap(left, right); } } All the tests of the Boost.Swap passed. Ion's solution looks better than existing boost::swap.
Are there any reasons not to change the existing implementation of Boost.Swap to Ion's version?
-- Best regards, Antony Polukhin
You may find it a silly argument, and it goes back to these dependency graph discussions. If you look at the dependency report, like this one http://www.pdimov.com/tmp/report-d5ca5be/module-levels.html It says Boost.Core is level 2 (so, fairly primitive) while Boost.Move is Level 6. If you make Core depend on Move, it is not that primitive anymore. Of course, the idea with improving swap is sound. I just thought I would bring it up. Regards, &rzej
Andrzej Krzemienski wrote:
2014-12-26 12:05 GMT+01:00 Antony Polukhin
: Are there any reasons not to change the existing implementation of Boost.Swap to Ion's version?
You may find it a silly argument, and it goes back to these dependency graph discussions. If you look at the dependency report, like this one http://www.pdimov.com/tmp/report-d5ca5be/module-levels.html It says Boost.Core is level 2 (so, fairly primitive) while Boost.Move is Level 6.
It's in fact not a silly argument at all. Boost.Core is explicitly not allowed to acquire new dependencies - this was the reason for creating it. We can in principle extract Boost.Swap into its own module though.
On December 27, 2014 12:47:40 PM EST, Peter Dimov
Andrzej Krzemienski wrote:
2014-12-26 12:05 GMT+01:00 Antony Polukhin
: Are there any reasons not to change the existing implementation of Boost.Swap to Ion's version?
You may find it a silly argument, and it goes back to these dependency graph discussions. If you look at the dependency report, like this one http://www.pdimov.com/tmp/report-d5ca5be/module-levels.html It says Boost.Core is level 2 (so, fairly primitive) while Boost.Move is Level 6.
It's in fact not a silly argument at all. Boost.Core is explicitly not allowed to acquire new dependencies - this was the reason for creating it. We can in principle extract Boost.Swap into its own module though.
I'm sure Antony meant to change the implementation to match the ideas in Ion's code, not use the test implementation he showed. ___ Rob (Sent from my portable computation engine)
I'm sure Antony meant to change the implementation to match the ideas in Ion's code, not use >the test implementation he showed.
But isn't the whole idea to depend on Boost.Move so that swap can benefit from move emulation? As Peter said, a new Boost.Swap could depend on Move, but Core should not.
El 28/12/2014 a las 19:42, Pete Bartlett escribió:
I'm sure Antony meant to change the implementation to match the ideas in Ion's code, not use >the test implementation he showed.
But isn't the whole idea to depend on Boost.Move so that swap can benefit from move emulation? As Peter said, a new Boost.Swap could depend on Move, but Core should not.
The part used by adl_move_swap is about Level 2 (because it depends on BOOST_STATIC_ASSERT). Without BOOST_STATIC_ASSERT it would be Level 0. Boost.Move is Level 4 because some header depends on TypeTraits. Obviously the dependency report can't show this. Is the dependency report based on master or develop branch? I can't see any mention to this. It would be nice if the report could show this in the last "Generated on ...." line. Thanks Ion
On December 28, 2014 1:42:54 PM EST, Pete Bartlett
I'm sure Antony meant to change the implementation to match the ideas in Ion's code, not use the test implementation he showed.
But isn't the whole idea to depend on Boost.Move so that swap can benefit from move emulation? As Peter said, a new Boost.Swap could depend on Move, but Core should not.
It could be implemented based upon C++11 move semantics, when available. If there were a way to detect and use Boost.Move without requiring a reference to it, that would be ideal, of course. ___ Rob (Sent from my portable computation engine)
On Monday 29 December 2014 05:22:29 Rob Stewart wrote:
On December 28, 2014 1:42:54 PM EST, Pete Bartlett
wrote: I'm sure Antony meant to change the implementation to match the ideas
in Ion's code, not use the test implementation he showed.
But isn't the whole idea to depend on Boost.Move so that swap can benefit from move emulation? As Peter said, a new Boost.Swap could depend on Move, but Core should not.
It could be implemented based upon C++11 move semantics, when available. If there were a way to detect and use Boost.Move without requiring a reference to it, that would be ideal, of course.
The whole idea of using Boost.Move swap is to make use of move emulation in C++03. std::swap in C++11 already uses move constructors, so Boost.Core swap automatically uses move constructors through std::swap.
Andrzej Krzemienski wrote: ...
I've generated a new report at http://www.pdimov.com/tmp/report-b1adfee/module-levels.html
participants (7)
-
Andrey Semashev
-
Andrzej Krzemienski
-
Antony Polukhin
-
Ion Gaztañaga
-
Pete Bartlett
-
Peter Dimov
-
Rob Stewart