Skip to content

eve::algo::max_element on a slice of an array #1712

Discussion options

You must be logged in to vote

You need span to be a const value. Otherwise you might be in trouble.

https://godbolt.org/z/Y3Tf9Kd3n

int tst() {
  std::array a{1, 2, 3, 4};
  std::span s{&a[3], 2};
  return *eve::algo::max_value(s);
}

see std::ranges borrowed range for context https://en.cppreference.com/w/cpp/ranges/borrowed_range

Replies: 7 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by pauljurczak
Comment options

You must be logged in to vote
1 reply
@pauljurczak
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@pauljurczak
Comment options

Comment options

You must be logged in to vote
5 replies
@DenisYaroshevskiy
Comment options

@pauljurczak
Comment options

@DenisYaroshevskiy
Comment options

@DenisYaroshevskiy
Comment options

@pauljurczak
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants