Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing template into boost function

template <class EventType>
class IEvent;

class IEventable;

typedef boost::function<void (IEventable&, IEvent&)> behaviorRef;

What is the right way for passing template class IEvent into boost function? With this code I get: error: functional cast expression list treated as compound expression error: template argument 1 is invalid error: invalid type in declaration before ‘;’ token

like image 428
Max Frai Avatar asked Aug 31 '26 20:08

Max Frai


1 Answers

boost::function needs a type, so you cannot pass it a template's name, it has to be a template instance. So either use a specific instance

typedef boost::function<void (IEventable&, IEvent<SomeEventType>&)> behaviorRef;

or put the whole thing itself into a template:

template< typename EventType >
struct foo {
  typedef boost::function<void (IEventable&, IEvent<EventType >&)> behaviorRef;
};
like image 75
sbi Avatar answered Sep 03 '26 10:09

sbi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!