catchorg / catchorg/Catch2

fmtlib support

Open
#2,780 5 comments 11 reactions 0 assignees View on GitHub
Feature Request
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

**Description**
We have a codebase whose data structures can be printed via custom [fmtlib](https://github.com/fmtlib/fmt) formatters. It'd be great if Catch could detect these formatters automatically and use them.

**Additional context**
I've started experimenting with introducing this into your codebase - but wanted to check if it's even a desired feature of catch2 before proceeding:

Naively, the easiest approach to this would be to copy what's done for `operator<<` in catch_tostring.hpp - in addition to [IsStreamInsertable] (https://github.com/catchorg/Catch2/blob/53d0d913a422d356b23dd927547febdf69ee9081/src/catch2/catch_tostring.hpp#L68) used for streaming, we offer a "IsFmtFormattable" that calls [fmt::is_formattable](https://github.com/fmtlib/fmt/blob/274ba2645bdae12f6f0c7d7ca24659c4af670548/include/fmt/core.h#L1780) to see if something can be printed via fmtlib.

We could hook into `__has_include` to see if fmtlib is even present, and if not, `ifdef` all that stuff out.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.