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

<numeric>: std::reduce is missing static_assert for Mandates #4649

Closed
hewillk opened this issue May 2, 2024 · 2 comments
Closed

<numeric>: std::reduce is missing static_assert for Mandates #4649

hewillk opened this issue May 2, 2024 · 2 comments

Comments

@hewillk
Copy link
Contributor

hewillk commented May 2, 2024

#include <vector>
#include <string>
#include <numeric>
#include <execution>

struct Op {
  int operator()(int, std::string);
};

int main() {
  std::vector<std::string> v;
  return std::reduce(v.begin(), v.end(), 0, Op{});
}

https://godbolt.org/z/5T4cn95nv

According to the current wording, the above should be rejected as std::reduce has the following Mandates ([reduce]):

Mandates: All of
(5.1) - binary_op(init, *first),
(5.2) - binary_op(*first, init),
(5.3) - binary_op(init, init), and
(5.4) - binary_op(*first, *first)
are convertible to T.

Not sure if std::transform_reduce has the same issue.

@frederick-vs-ja
Copy link
Contributor

Duplicate of #4573 and #891?

@hewillk
Copy link
Contributor Author

hewillk commented May 3, 2024

Duplicate of #4573 and #891?

Yap, I think you are correct.

@hewillk hewillk closed this as completed May 3, 2024
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

No branches or pull requests

2 participants