catchorg / Catch2

A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)
https://discord.gg/4CWS9zD
Boost Software License 1.0
18.79k stars 3.06k forks source link

Provide Catch2's StringMaker specialization behind extra level of indirection #2830

Open horenmar opened 9 months ago

horenmar commented 9 months ago

Right now, users cannot change how Catch2 stringifies types that it provides StringMaker specializations for, such as float or double. This is due to the stringification priority being StringMaker<T> -> operator<< -> fallbacks (enum handler, range handler, etc).

However, users often want to customize the output, e.g. the printed precision for floating point types.

There are three ways to handle this, none of them particularly great.

Of these three options, only the last one is reasonable to implement, but we need to measure the compile time overhead first, and decide based on the final values.

jan-moeller commented 2 months ago

Please also consider #2298 as a relevant issue here.