El 07/09/2011 1:31, Daniel James escribió:
#include
#include<string> struct template_symbol { boost::container::vectorstd::string params; };
int main() { boost::container::vector
storage; template_symbol symbol; storage.push_back(symbol); }
That's a limitation of the move emulation explained in the documentation:
The macro BOOST_COPYABLE_AND_MOVABLE needs to define a copy constructor
for copyable_and_movable taking a non-const parameter in C++03 compilers:
//Generated by BOOST_COPYABLE_AND_MOVABLE
copyable_and_movable &operator=(copyable_and_movable&){/**/}
Since the non-const overload of the copy constructor is generated,
compiler-generated assignment operators for classes containing
copyable_and_movable will get the non-const copy constructor overload,
which will surely surprise users:
class holder
{
copyable_and_movable c;
};
void func(const holder& h)
{
holder copy_h(h); //<--- ERROR: can't convert 'const holder&' to
'holder&'
//Compiler-generated copy constructor is non-const:
// holder& operator(holder &)
//!!!
}
This limitation forces the user to define a const version of the copy
assignment, in all classes holding copyable and movable classes which
might annoying in some cases.
If you define the copy constructor you avoid the error. Annoying, but
I've not found any workaround. AFter adding such operations, this works.
#include