为什么在C ++ 0x中有一个sizeof ...运算符? [英] Why is there a sizeof... operator in C++0x?
问题描述
我看到@GMan实施了 a版本的 sizeof ...
可变参数模板(据我所知)相当于内置的 sizeof .. 。
。这不符合第二个设计原则: 更喜欢图书馆
(N2080 = 06-0150),第6页:
虽然不是绝对必要的(我们可以实现
count
检查参数包的长度是一种常见的操作,值得一个简单的语法。此外,当可变参数模板与概念结合时,这种操作对于类型检查原因可能变得必要;见第3.3节。
(第3.3节谈到现在无关的概念。)
I saw that @GMan implemented a version of sizeof...
for variadic templates which (as far as I can tell) is equivalent to the built in sizeof...
. Doesn't this go against the second design principle: prefer libraries to language extensions?
From Variadic Templates (Revision 3) (N2080=06-0150), page 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.
(Section 3.3 talks about concepts which is irrelevant now.)
这篇关于为什么在C ++ 0x中有一个sizeof ...运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!