相关疑难解决方法(0)

嵌套类模板专门化

一类:

template<typename C, typename T>
class A
{
    template <typename U>
    class Nested{};

    Nested<T> n;
};
Run Code Online (Sandbox Code Playgroud)

我想专攻Nested.这是我尝试过的:

template<typename C, typename T>
class A
{
    template <typename U>
    class Nested{};

    template <>
    class Nested<int>{}; // by my logic this should work by I have a compilation error "explicit specialization in non-namespace scope 'class A<C, T>'"

    Nested<T> n;
};
Run Code Online (Sandbox Code Playgroud)

我的下一次尝试:

template<typename C, typename T>
class A
{
    template <typename U>
    class Nested{};

    Nested<T> n;
};

template<>
A<>::Nested<int>{}; // What is …
Run Code Online (Sandbox Code Playgroud)

c++ templates template-specialization

17
推荐指数
1
解决办法
4118
查看次数

标签 统计

c++ ×1

template-specialization ×1

templates ×1