MyTinySTL
MyTinySTL copied to clipboard
functional.h 类模板 `identity` 实现模板参数错误?
请看代码, 此处实例化是否应当为:
template <class T> struct identity : public unarg_function<T, T> {
const T &operator()(const T &x) const { return x; }
};
即将父类模板的第二个模板参数实例化为T
而非bool
。
已经收到您的邮件!!!
我觉得它应该改成这样:
struct identity {
template <class T>
constexpr T &&operator()(T &&x) const noexcept { return (T&&)x; }
};