Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functional.h 类模板 identity 实现模板参数错误? #141

Open
LiuYuan-SHU opened this issue Dec 11, 2023 · 2 comments · May be fixed by #153
Open

functional.h 类模板 identity 实现模板参数错误? #141

LiuYuan-SHU opened this issue Dec 11, 2023 · 2 comments · May be fixed by #153

Comments

@LiuYuan-SHU
Copy link

请看代码, 此处实例化是否应当为:

template <class T> struct identity : public unarg_function<T, T> {
  const T &operator()(const T &x) const { return x; }
};

即将父类模板的第二个模板参数实例化为T而非bool

@Adeshen
Copy link

Adeshen commented Dec 11, 2023 via email

@frederick-vs-ja
Copy link
Contributor

我觉得它应该改成这样:

struct identity {
  template <class T>
  constexpr T &&operator()(T &&x) const noexcept { return (T&&)x; }
};

@frederick-vs-ja frederick-vs-ja linked a pull request Jul 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants