Data structure with variadic templates
问题 I have a Menu<T> class, whose options are items of type T, and it may have submenus of type Menu<T> (with no limit to the depth of nested submenus). template <typename T> class Menu { private: class Option { const std::string name; const T item; Menu<T>* submenu; Option* next = nullptr; friend class Menu<T>; Option (const std::string& itemName, const T& t, Menu<T>* menu = nullptr) : name(itemName), item(t), submenu(menu) {} ~Option() {if (submenu) delete submenu;} inline T choose() const;