c++ - typename参数包和auto参数包的区别?

标签 c++ c++11 templates variadic-templates

假设我有这两个定义。

template<typename... Ts>
struct S{};

template<auto... Ts>
struct S{};

这两个定义有什么区别?
我们什么时候应该选择一个或另一个?

最佳答案

他们有不同的目的,前者允许

S<int, char, float> s;

后者(仅自 C++17 起可用)允许

S<42, '*', 42U> s;

关于c++ - typename参数包和auto参数包的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66460463/

相关文章:

c++ - 实现结构化张量

c++ - Range-for-loops 和 std::vector<bool>

c++ - SIGILL 在 ideone 上运行,但在 Codeblocks 上运行时出现警告

c++ - 模板类的typedef

c++ - `std::enable_if` 是函数指针——怎么样?

javascript - 适用于客户端和服务器的 ASP.NET MVC 模板

c++ - 生成随机图

c++ - std::equal 给出 "Term doesnt evaluate to a function taking 2 arguments"

android - 使用 ndk arm-linux-androideabi-clang++ 编译器为 android 构建 grpc C++

CUDA 中的 C++11 别名模板