B
Belebele
Suppose that I want to write a (concrete) interface class (without
virtual functions) to classes that contain a method template
// --------------------------------------
class Interface {
public:
template <typename Wrapped>
Interface(Wrapped& );
// wraps a reference to another object
// that implements the method template
template <typename T>
bool foo(T ); // forwards the call to the wrapped object
};
// --------------------------------------
and then use it:
// --------------------------------------
class Bar {
public:
template <typename T>
bool foo(T );
};
....
Bar b;
Interface i(b);
// --------------------------------------
The problem is that I don't know how to implement this. I know how to
implement it without method templates (with table of function
pointers).
Any idea how to do it?
Thanks.
virtual functions) to classes that contain a method template
// --------------------------------------
class Interface {
public:
template <typename Wrapped>
Interface(Wrapped& );
// wraps a reference to another object
// that implements the method template
template <typename T>
bool foo(T ); // forwards the call to the wrapped object
};
// --------------------------------------
and then use it:
// --------------------------------------
class Bar {
public:
template <typename T>
bool foo(T );
};
....
Bar b;
Interface i(b);
// --------------------------------------
The problem is that I don't know how to implement this. I know how to
implement it without method templates (with table of function
pointers).
Any idea how to do it?
Thanks.