简体   繁体   English

声明嵌套类模板的静态对象

[英]Declare static object of a nested class template

I'm trying to declare a static object of a nested class template inside the first class template, like so: 我试图在第一个类模板中声明一个嵌套类模板的静态对象,如下所示:

template <typename... a_t>
class A {
private:
    template <typename... b_t>
    class B {

    };

    static B<a_t...> b;
};

This is the code I'd expect would make this work, but causes compilation errors, despite this answer here , which works for non-templated members inside the second class template: 这是我期望的代码,可以完成这项工作,但是会导致编译错误,尽管这里此答案 ,但它适用于第二个类模板中的非模板成员:

template <typename... a_t>
template <typename... b_t>
A<a_t...>::B<b_t...> A<a_t...>::b; //incorrect?

What is the correct syntax that would accomplish this? 什么是正确的语法可以做到这一点?

You forgot typename keyword: 您忘记了typename关键字:

template <typename... a_t>
typename A<a_t...>::B<a_t...> A<a_t...>::b;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM