Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

What's the reason Approx is not default constructible?

Open ICreateYank opened this issue 1 year ago • 2 comments

Title, I saw this when creating an array of Approx

ICreateYank avatar Jun 05 '25 16:06 ICreateYank

What use cases require an array of such uninitialized objects?

BacCM avatar Feb 25 '26 16:02 BacCM

I don't quite remember but I can think of something:

std::array<Catch::Approx, 2> arr; // error
std::generate(arr, ...);

std::array expected = {1., 2.};
REQUIRE(arr == expected);

You could make an std::vector but then, if Approx is completely constexpr, you'd lose constexpr functionality and can no longer use static_assert

ICreateYank avatar Feb 25 '26 16:02 ICreateYank