Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Boost Libraries take advantage of Move Semantics

Rvalue references and Move semantics are a major C++11 feature that can significantly speed up code by reducing unnecessary copies. The STL has been updated to use this new feature when a c++11/0x compiler is used (e.g. gcc 4.6)

Boost 1.48 introduced a new library in order to emulate move semantics on older C++03 compilers. This library works by introducing macros that expand to true rvalue references when code is compiled with C++11 compilers or emulated rvalue referneces when the code is compiled with C++03 compilers.

Apart from boost::container have any of the other boost libraries been updated to take advantage of move semantics yet?

Is there a roadmap detailing when / if move semantics will be added to other boost libraries?

boost::multi_index_container has mentioned addition of move semantics on the Boost.MultiIndex Future work, since it was introduced in version 1.31.

like image 967
mark Avatar asked Mar 09 '12 21:03

mark


1 Answers

As you said in the question, boost 1.48 introduced boost::move, a library that emulates move semantics with C++03. This was developed by Ion Gaztanaga, who also (mostly) wrote and currently maintains boost::intrusive and boost::container.

Both intrusive and container support move semantics - in fact boost::intrusive has to support move semantics for boost::container to, because boost::container is basically a bunch of non-intrusive containers implemented by wrapping their boost::intrusive counterparts. It looks to me like intrusive/container were the motivation for writing boost::move, so it's not surprising that they have a head start on the rest of boost.

But it's import to note here that there is no boost roadmap or committee - boost is just a collection of libraries that share distribution, a website, and a review/quality control process. You have to consider each library as a separate project, which will only be updated if and when the authors/maintainers are interested in doing the work (or of course, when you send them a patch!).

The boost 1.48/1.49/1.50/1.51/1.52 release notes are the best place to look for solid answers:

  • Boost.Interprocess has support since 1.45, both C++11 and C++03. Before 1.48, this contained the code that became boost.move.
  • Boost.Asio has support since 1.47; no emulation in C++03
  • Boost.Intrusive gained support via boost.move in 1.48 (C++11, C++03)
  • Boost.Container was new in 1.48 with support via boost.move (C++11, C++03)
  • Boost.Icl gained support via boost.move in 1.49 (C++11, C++03)
  • Boost.Unordered gained support via boost.move in 1.49 (C++11, with a #define to enable emulation in C++03)
  • Boost.Thread supports C++03 emulation w/boost.move since 1.50, older versions have C++11-only support
  • Boost.Function added C++11-only support in 1.52
like image 156
je4d Avatar answered Sep 20 '22 17:09

je4d