我有一个代表数组引用的类(class array_ref
),另一个是(即保存/拥有/包含)数组(class array
)。
array_ref
的行为类似于引用。
将 std::decay
专门化为 class array_ref
为 array
是否有意义?
namespace std{
template<> class decay<arra_ref>{typedef array type;};
}
我还需要什么其他替代方法来告诉通用程序 array
是 array_ref
的“值类型”?
std::decay
是否用于任何 STL 算法?
最佳答案
标准库算法是否使用它并不重要。重要的是标准在 [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/