简体   繁体   中英

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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