boost::bind
handles boost::shared_ptr
the same way as raw pointers.
QObject * object(new QObject);
boost::shared_ptr<QObject> sharedObject(new QObject);
bind(&QObject::setObjectName, object, _1)( "name" );
bind(&QObject::setObjectName, sharedObject, _1)( "name" );
I would love to have a boost::bind
that handles QPointers
as raw pointers pointer.
QPointer<QObject> guardedObject(new QObject);
// i want to write it like this
bind(&QObject::setObjectName, guardedObject, _1)( "name" );
//now i have to do it like this
bind(&QObject::setObjectName, bind(&QPointer<QObject>::data, guardedObject), _1)( "name" );
Is there anyone who has made the specialization for QPointer
?
If not do you know where to start or what needs to be specialized, so I can do it myself.
Adding this overload of the get_pointer
function should do the trick:
namespace boost {
template<typename T> T * get_pointer(QPointer<T> const& p)
{
return p;
}
}