This Question Determined That a Non-Copyable Type Can\'t Be Used With Boost Variant
Tree
class
template
Concerning the call to boost::bind()
, you should use boost::ref() when passing an object by reference to a function template that accepts the corresponding argument by value, otherwise a copy will be attempted (which results in a compiler error in this case, since the copy constructor is inaccessible):
boost::bind(TreeVisitor(), boost::ref(tree), val, keyIndex);
// ^^^^^^^^^^^^^^^^
However, there is a bigger problem here: boost::variant
can only hold types which are copy-constructible. From the Boost.Variant online documentation:
The requirements on a bounded type are as follows:
CopyConstructible
[20.1.3].Destructor upholds the no-throw exception-safety guarantee.
Complete at the point of variant template instantiation. (See
boost::recursive_wrapper
for a type wrapper that accepts incomplete types to enable recursive variant types.)Every type specified as a template argument to
variant
must at minimum fulfill the above requirements. [...]