C++ 如何从模板别名切换到typedef?

C++ 如何从模板别名切换到typedef?,c++,templates,c++11,template-aliases,C++,Templates,C++11,Template Aliases,我有一个基本上实现注册表设计模式的模板类。 值使用键注册并存储在某些容器中: template <typename Key, typename Value, template <typename...> class Container > class registry { public: typedef Key key_type; typedef Value value_type; typedef std::pair<key

我有一个基本上实现注册表设计模式的模板类。 值使用键注册并存储在某些容器中:

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;
模板
类注册表
{
公众:
typedef Key_type;
类型定义值\u类型;
typedef std::pair element_type;
类型定义容器容器类型;
然后,我可以将其用于序列容器,如下所示:

registry<const char*,void*, std::list> r1;
registry<const char*,void*, std::vector> r2;
template <typename T>
class my_container2 
{
    typedef std::array<T,3> type;
};
registry<const char*,void*, my_container2::type > r5;
注册表r1;
登记处r2;
我甚至可以将其与alias一起使用:

template <typename T>
using alias_container = std::array<T, 10>;

registry<const char*,void*, alias_container > r4;
模板
使用别名_container=std::array;
注册r4;
但我不知道如何将其与typedef一起使用,如下所示:

registry<const char*,void*, std::list> r1;
registry<const char*,void*, std::vector> r2;
template <typename T>
class my_container2 
{
    typedef std::array<T,3> type;
};
registry<const char*,void*, my_container2::type > r5;
模板
分类我的集装箱2
{
typedef std::数组类型;
};
我基本上想要这样的东西:

registry<const char*,void*, std::list> r1;
registry<const char*,void*, std::vector> r2;
template <typename T>
class my_container2 
{
    typedef std::array<T,3> type;
};
registry<const char*,void*, my_container2::type > r5;
registryr5;

非常感谢您的帮助。

类型取决于提供给
my_container2
的模板类型。要使用它,您需要指定如下模板参数

registry<const char*,void*, my_container2<some_type>::type > r4;
                                          ^^^^^^^^^ template type here
注册表r4;
^^^^^^^^^模板类型在这里

这与标准类型的迭代器的概念相同。不能使用
container\u type::iterator
。必须使用
container\u type::iterator

类型取决于提供给
my\u container2
的模板类型。要使用它,需要指定如下模板参数

registry<const char*,void*, my_container2<some_type>::type > r4;
                                          ^^^^^^^^^ template type here
注册表r4;
^^^^^^^^^模板类型在这里

这与标准类型的迭代器的概念相同。你不能使用
container\u type::iterator
。你必须使用
container\u type::iterator

我认为你做不到。typedef不是模板。我认为你做不到。typedef不是模板。内森,谢谢你的回答。在我的情况下,我会被删除注册表模板:应该是STD::但是,我更不想明确地指定它。@ YakovGerlovin——你不能做你想做的事情。没有模板TyWupe这样的东西。C++的作者研究了这一点,发现了很多问题。在C++中使用弥敦,谢谢你的回答。在我的情况下,将注销注册表模板:它应该是STD::对,但我宁愿不明确地指定它。@ YakovGerlovin -你不能做你想要的。没有这样的东西模板Type。他们添加了别名模板的概念,它使用
和alias\u name=some\u type\u-templated;