Implement `constexpr` generators or add the possibility for combining signature-based parametrised tests
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
## Description
There are various reasons why a class or function may have multiple non-type template parameters, including (but not limited to) compile-time feature toggling, guaranteed compile-time branch elimination, and [multidimensional spans](https://en.cppreference.com/w/cpp/container/mdspan.html) and containers with compile-time [extents](https://en.cppreference.com/w/cpp/container/mdspan/extents.html).
There are already two features that are close to the request, but none seem to satisfy it exactly:
1. [Generators](https://github.com/catchorg/Catch2/blob/9b3f508a1b1579f5366cf83d19822cb395f23528/docs/generators.md#data-generators) allow going through a Cartesian product of inputs.
2. [Type parametrised test cases](https://github.com/catchorg/Catch2/blob/devel/docs/test-cases-and-sections.md#type-parametrised-test-cases) have `TEMPLATE_PRODUCT_TEST_CASE` for combining types, and [signature-based parametrised tests](https://github.com/catchorg/Catch2/blob/devel/docs/test-cases-and-sections.md#signature-based-parametrised-test-cases) allow traversing compile-time constants.
3. `TEMPLATE_LIST_TEST_CASE` allows using an `std::tuple` to represent types. Using an `std::tuple` of `constexpr` values for `TEMPLATE_TEST_CASE_SIG` would allow for at least manual compile-time generation of all required combinations.
Evident limitations of these approaches in the context of the request:
1. Generators do not support `constexpr` values, so they cannot be used for non-type template parameters.
2. A signature-based parameterised test argument list grows exponentially with any additional argument that needs to be combined with the others.
3. The template list test case does not support values directly. However, there is [std::integral_constant](https://en.cppreference.com/w/cpp/types/integral_constant.html), which is sufficient for a lot of applications, but not all, because non-type template parameters are [not limited](https://en.cppreference.com/w/cpp/named_req/LiteralType.html) to integral constants.
## Additional context
Another user already made a [similar request](https://github.com/catchorg/Catch2/issues/1702) and was satisfied with the proposed solution, but I cannot reopen it and am unsure whether a comment in the closed issue would be lost.
Contributor guide
Assessment
This issue has not been assessed yet.