Skip to content

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

@stk-ableton

Description

@stk-ableton

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions