I am trying to create a variant of non-copyable types possibly using the recursive wrapper, such as in the following code:
#include "boost/variant.hpp"
using namespace std;
using namespace boost;
struct A
{
A() {}
A(A &&) noexcept {}
A& operator=(A &&) noexcept {}
A(A const &) = delete;
A& operator=(A const &) = delete;
};
struct B;
typedef variant<A, recursive_wrapper<B>> ABC;
struct B
{
B() {}
B(B &&) noexcept {}
B& operator=(B &&) noexcept {}
B(B const &) = delete;
B& operator=(B const &) = delete;
};
int main(int argc, char** argv)
{
ABC _a, _b;
_b = std::move(_a);
}
The issue is that the recursive wrapper expects the objects to be copy constructible if I code a move assignment. This is the compilation error I get:
/usr/include/boost/variant/recursive_wrapper.hpp:116:32: error: use of deleted function 'B::B(const B&)'
: p_(new T( operand.get() ))
Does anybody see where is the problem?