Boost logo

Boost :

Subject: [boost] [fusion] move-enabled containers?
From: Gabriel Redner (gredner_at_[hidden])
Date: 2012-08-20 13:53:06


Hi folks,

I have been starting to ease into C++11, and am currently looking to
add move-awareness to some classes which have members of boost::fusion
container types. However, it seems that fusion containers are not
move-aware. For a minimal example, take the code below:

==========
#include <boost/fusion/include/vector.hpp>
#include <iostream>

class noisy
{
public:
  noisy() { std::cout << "noisy()\n"; }
  noisy(const noisy&) { std::cout << "noisy(const noisy&)\n"; }
  noisy(noisy&&) { std::cout << "noisy(noisy&&)\n"; }
};

int main()
{
  typedef boost::fusion::vector<noisy, noisy> noisyVector;

  noisyVector n;
  std::cout << '\n';

  noisyVector n2(n);
  std::cout << '\n';

  noisyVector n3(std::move(n));
}
==========

I was hoping that the output would be:
==========
noisy()
noisy()

noisy(const noisy&)
noisy(const noisy&)

noisy(noisy&&)
noisy(noisy&&)
==========

But instead I get:
==========
noisy()
noisy()

noisy(const noisy&)
noisy(const noisy&)

noisy(const noisy&)
noisy(const noisy&)
==========

It is a simple matter to add move-awareness to fusion containers, or
is there some technical reason why it cannot been done? Or (perhaps
more likely), am I misunderstanding something about the situation?

Thanks,
-Gabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk