B
Boris
I was making a part of an application more and more generic when I suddenly
ended up with code like this:
template <class T>
struct MenuItems {
T &m;
MenuItems(T &m);
};
template <class T>
struct Menu {
T items;
Menu() : items(*this) { }
};
template <class T>
MenuItems<T>::MenuItems(T &m) : m(m) { }
If these classes were no templates the code would compile without any
problems. But now with these templates it's impossible to instantiate them
with each other. You end up with something like
Menu<MenuItems<Menu<MenuItems<Menu ... Is there any trick or I went a bit
too far and have to go back to complete types?
Boris
ended up with code like this:
template <class T>
struct MenuItems {
T &m;
MenuItems(T &m);
};
template <class T>
struct Menu {
T items;
Menu() : items(*this) { }
};
template <class T>
MenuItems<T>::MenuItems(T &m) : m(m) { }
If these classes were no templates the code would compile without any
problems. But now with these templates it's impossible to instantiate them
with each other. You end up with something like
Menu<MenuItems<Menu<MenuItems<Menu ... Is there any trick or I went a bit
too far and have to go back to complete types?
Boris