|
Boost : |
From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2024-10-20 18:32:20
On Sun, Oct 20, 2024 at 11:13â¯AM Ivica Siladic via Boost <
boost_at_[hidden]> wrote:
> > What you could do here is to introduce a BOOST_MQTT5_ENABLE_BOOST_LOG
> macro
I don't like configuration macros. Because these create different
libraries, effectively creating separate object files which have the
potential to be incompatible at link-time. It is simpler for there to be
only one version of the library with no configurations.
> our goal is to find a more elegant, C++-style solution that achieves the
> same effect.
>
How do you feel about this?
template<
class Stream,
class Logger = int,
class TlsContext = std::monostate
>
class mqtt_client
{
Logger log_; // could use empty base optimization here
public:
void cancel() {
if constexpr(is_logger<Logger>)
log_("cancelling");
auto impl = _impl;
_impl = impl->dup();
impl->cancel();
}
...
To be honest though, I think you are being unnecessarily strict with the
"zero overhead." There is nothing wrong with adding a single if statement
to each function for logging. Really now, are you worried about the
performance of adding a branch to a function which invokes an initiating
function? I bet if you measure it, you will change your mind.
Thanks
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk