This is not duplicate to How to create two classes in C++ which use each other as data?
Here I want two instances to be bound to ecah other at compile-time
I have a template class (they are the same):
template <typename T>
class driver {
public:
driver(T& arg):ref(arg){};
private:
T& ref;
};
template <typename T>
class handler {
public:
handler(T& arg):ref(arg){};
private:
T& ref;
};
How to make two instances linked to ech other?
driver<?auto?> driver_instance{handler_instance}
handler<?auto?> handler_instance{driver_instnace};
Imagine I have a driver, which takes reference to some class 'handler' which handles driver's events. On the other hand 'handler' must have reference to 'driver' instance to make calls to driver. I want this two to bind to each other at compile time.