loguru icon indicating copy to clipboard operation
loguru copied to clipboard

Include fmt/ostream when using fmtlib

Open richardhozak opened this issue 5 years ago • 2 comments
trafficstars

This allows us to print user defined classes/struct that have only ostream operator defined.

richardhozak avatar Jun 16 '20 20:06 richardhozak

Could a user call #include <fmt/ostream.h> themselves before/after #include <loguru.hpp>? If so, I would prefer that.

One of the stated goals of Loguru is to keep the number of headers it includes down to a minimum (down to zero in the default case) to keep compile times down.

In the fmtlib path of Loguru there already are a few headers #included, but how much more gets included by this? If <fmt/ostream.h> is tiny (and doesn't include more itself) then this PR is probably fine.

You can use -E option to clang/gcc to measure how much extra code is #included to loguru.hpp by this.

emilk avatar Jun 17 '20 07:06 emilk

<fmt/ostream.h> includes fmt/format. which is already included in loguru.hpp and also includes <ostream>: https://github.com/fmtlib/fmt/blob/master/include/fmt/ostream.h.

One of the stated goals of Loguru is to keep the number of headers it includes down to a minimum (down to zero in the default case) to keep compile times down.

I get it, I chose loguru instead of spdlog because of this, I am migrating from it, so I used the fmtlib support in loguru, this is the last thing I need, so I do not have to include fmt/ostream everywhere. It behaves exactly like spdlog, but is a bit lighter.

richardhozak avatar Jun 17 '20 08:06 richardhozak