I am trying to create a object using boost object_pool, but trying to use the move constructor of the desired object, but on Visual 2013, I am always getting:
error C2664: 'MyObject::MyObject(const MyObject &)' : cannot convert argument 1 from 'MyObject (__cdecl &)(void)' to 'MyObject &&'
The error happens because boost pool construct method always assume a const parameter.
Sample code:
#include <boost/pool/object_pool.hpp>
class MyObject
{
public:
MyObject():
m_iData(0)
{
}
MyObject(MyObject &&other):
m_iData(std::move(other.m_iData))
{
other.m_iData = 0;
}
MyObject(const MyObject &rhs) = delete;
MyObject &operator=(const MyObject &rhs) = delete;
private:
int m_iData;
};
int main(int, char**)
{
boost::object_pool<MyObject> pool;
MyObject obj;
MyObject *pObj = pool.construct(std::move(obj));
}
Is there any way to invoke the move constructor using boost::object_pool?
Thanks