我有一个基本上实现注册表设计模式的模板类。值通过 Keys 注册并存储在某个容器中:
template <typename Key, typename Value,
template <typename...> class Container >
class registry
{
public:
typedef Key key_type;
typedef Value value_type;
typedef std::pair<key_type, value_type> element_type;
typedef Container<element_type> container_type;
然后,我可以将它与这样的序列容器一起使用:
registry<const char*,void*, std::list> r1;
registry<const char*,void*, std::vector> r2;
我什至可以将它与别名一起使用:
template <typename T>
using alias_container = std::array<T, 10>;
registry<const char*,void*, alias_container > r4;
但我不知道如何将它与 typedef 一起使用,如下所示:
template <typename T>
class my_container2
{
typedef std::array<T,3> type;
};
我基本上想要这样的东西:
registry<const char*,void*, my_container2::type > r5;
非常感谢你的帮助。