Make it possible to use objects and collections with fmtlib#931
Make it possible to use objects and collections with fmtlib#931tmadlener wants to merge 6 commits intoAIDASoft:masterfrom
Conversation
|
Would it be possible to define I briefly tried to add |
Is that possible on a technical level? 🤔 I hadn't thought about that, but I am trying to actually implement the whole thing now and so far I haven't seen anything that is not yet possible with |
I thought it could be done by adapting the contexts, but couldn't find anyone actually doing this, so perhaps it's not the greatest idea. Never mind |
8772bea to
a6d084b
Compare
| ExampleCluster cluster; | ||
| auto formatted = fmt::format("{}", cluster); | ||
| REQUIRE_FALSE(formatted.empty()); | ||
| REQUIRE(formatted != "[not avaialble]"); |
There was a problem hiding this comment.
My only comment would be that these tests are not very demanding but having to deal with multiline strings is a bit annoying.
There was a problem hiding this comment.
Yeah, they basically make sure things compile, not whether they make sense from an output point of view. We didn't have too many for operator<< either, apart from the ones in https://github.com/AIDASoft/podio/blob/master/tests/ostream_operator.cpp which also essentially make sure things compile and don't crash at runtime, but do not make any checks on the outputs themselves.
As a first step using the ostream_formatter adaptor to re-use the existing operator<<.
a6d084b to
5db02eb
Compare
BEGINRELEASENOTES
ostream_formatteradaptor from fmtlib.fmtlibis now a transitive dependency of podio, i.e. EDMs generated with podio will also depend on it. The necessary propagation of this dependency via CMake is handled here, but build environments might need adjustments.ENDRELEASENOTES
This is an intermediate step towards better support for using
fmt::format(and eventually hopefully alsostd::format). Currently this simply re-uses the existingoperator<<. In a next step I will implement proper formatting via the customization points thatfmtlibprovides. Thenoperator<<will be implemented in terms offmt::format. Ideally, that step would be compatible with<format>in which case we might be able do drop thefmtlibdependency.See also the discussion in #920 (comment)