Bug 23 - Callbacks cannot be created for member methods and Ptr<T> object instances
Callbacks cannot be created for member methods and Ptr<T> object instances
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
pre-release
PC Linux
: P1 blocker
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-05-13 03:52 UTC by Mathieu Lacage
Modified: 2008-07-01 13:32 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mathieu Lacage 2007-05-13 03:52:32 UTC
the following code will not compile:

Ptr<MyObject> p;
MakeCallback (&MyObject::MyMethod, p);

The solution probably would require us to define a CallbackTraits<T> template class and specialize it for the Ptr class:

template <typename T>
struct CallbackTraits
{
  typedef T * PointerType;
};

template <>
struct CallbackTraits<Ptr>
{
  typedef Ptr<T> PointerType
};

and use CallbackTraits<T>::PointerType in callback.h wherever we use T *.