gpt4 book ai didi

c++ - 为什么在 C++0x 中有一个 sizeof... 运算符?

转载 作者:可可西里 更新时间:2023-11-01 16:36:37 26 4
gpt4 key购买 nike

我看到@GMan 实现了 a version of sizeof...对于可变参数模板,它(据我所知)相当于内置的 sizeof...。这不违背第二个设计原则吗:prefer libraries to language extensions

最佳答案

来自 Variadic Templates (Revision 3)(N2080=06-0150) , 第 6 页:

Although not strictly necessary (we can implement count without this feature), checking the length of a parameter pack is a common operation that deserves a simple syntax. Moreover, this operation may become necessary for type-checking reasons when variadic templates are combined with concepts; see Section 3.3.

(3.3节讲的是现在无关紧要的概念。)

关于c++ - 为什么在 C++0x 中有一个 sizeof... 运算符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2771016/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com