作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个表示数组引用的类 (class array_ref
) 和另一个是(即持有/拥有/包含)数组(class array
)。array_ref
的行为类似于引用。
将 std::decay
特化为 class array_ref
是否有意义?
namespace std{
template<> class decay<arra_ref>{typedef array type;};
}
我还有什么其他选择可以告诉通用程序 array
是 array_ref
的“值类型”?
是否在任何 STL 算法中使用了 std::decay
?
最佳答案
标准库算法是否使用它并不重要。重要的是标准在 [meta.type.synop]/1 中所说的内容:
The behavior of a program that adds specializations for any of the templates defined in this subclause is undefined unless otherwise specified.
“本子条款”中包含所有类型特征类,包括decay
。所以不要专门化它。曾经。
关于c++ - 专门化 std::decay 有意义吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41029092/
我有一个带有模板函数的基类,该函数具有通用模板类型和专用版本。 #ifndef BASE_CLASS #define BASE_CLASS #include using namespace std;
我有这个 3D vector 模板 template class Vec3TYPE{ public: union{ struct{ TYPE x,y,z; }; struct{ TY
我是一名优秀的程序员,十分优秀!