小编Abh*_*ith的帖子

这个模板元程序中的int***如何工作?

模板元编程如何在这里工作(static const int value = 1 + StarCounter<\U>::value;)打印出来3

#include <iostream>

template <typename T>
struct StarCounter
{
    static const int value = 0;
};

template <typename U>
struct StarCounter<U*>
{
    static const int value = 1 + StarCounter<U>::value;
};

int main()
{
    std::cout << StarCounter<int***>::value << std::endl;//How is it printing 3?
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ templates template-meta-programming

10
推荐指数
3
解决办法
2106
查看次数

标签 统计

c++ ×1

template-meta-programming ×1

templates ×1