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

RangeEquals doesn't support literal std::initializer_list #2915

Open
stk-ableton opened this issue Oct 8, 2024 · 0 comments
Open

RangeEquals doesn't support literal std::initializer_list #2915

stk-ableton opened this issue Oct 8, 2024 · 0 comments

Comments

@stk-ableton
Copy link

It would often be useful to write something like this:

  const auto v = calculateSomeVectorOfInts();
  CHECK_THAT(v, RangeEquals({1, 2, 3}));

This doesn't compile. It can be made to compile by adding an overload to RangeEquals that takes a std::initializer_list. Would a PR adding such an overload have a chance of being accepted?

It's not a huge issue since there are workarounds, including any of these:

  const auto expected = {1, 2, 3};
  CHECK_THAT(v, RangeEquals(expected));

  CHECK_THAT(v, RangeEquals(std::vector{1, 2, 3}));

  CHECK_THAT(v, RangeEquals(std::initializer_list<int>{1, 2, 3}));

Still, the convenience of writing the initializer_list inline without extra qualification would be nice.

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

1 participant