#2716·Catch2

How to compare two floating point vectors

Author: newyorker123Created Jul 8, 2023Updated Jul 12, 2026

Description RangeEquals works well on int vector. But how to compare two double vectors? I want to achieve the following effect:

vector<double> vec1;
vector<double> vec2;
for e1 in vec1, e2 in vec2:
    REQUIRE_THAT(e1, WithinABS(e2 , 0.0001))

Additional context I tried to use AllMatch. But i don't know how to pass the second vector element-wise to the matcher

REQUIRE_THAT(vec1,AllMatch(WithinAbs(vec2 ???,0.0001)));