std::decay 的这个实现是否正确?
template<class T>
T DecayType(T);
template<class T>
struct decay {
using type = decltype(DecayType(declval<T>()));
};
我问是因为我遇到的一切都使用一些模板分支来小心地操纵类型,而这似乎只是按照定义行事。
最佳答案
形成这样的函数调用需要按值传递,这需要复制/移动构造函数。该实现不够通用。
不过,这是 std::decay
的要点。
关于c++ - 这个 std::decay 的实现是正确的吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31566760/