Fix: cpp-common/bt2c/logging.hpp: add missing `template` keyword
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Apr 2024 21:11:48 +0000 (17:11 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 25 Apr 2024 13:21:01 +0000 (09:21 -0400)
commite40ac8f6684dbeb4b6a0715baa7b25667b53f1e6
treecd8b1c6fabce698b80a73f39c0a8bcf9b8434c64
parenteced29fcde500cecbec69231bf8d4b1d9f8fe556
Fix: cpp-common/bt2c/logging.hpp: add missing `template` keyword

In very specific contexts, it's possible that a `bt2c::Logger` reference
is a dependent type, for example:

    template <typename T>
    struct X
    {
        const bt2c::Logger& logger() const noexcept
        {
            return /* some logger reference */;
        }

        void log()
        {
            BT_CPPLOGI_SPEC(this->logger(), "Hello!");
        }
    };

In that case, the BT_CPPLOGI_SPEC() macro eventually expands to
something like:

    this->logger().log<bt2c::Logger::Level::Info,
                       false>(__FILE__, __func__, __LINE__, "Hello!");

`this->logger()` is basically `X<T>::logger()`. Therefore, from the
log() method template point of view, the type of `this` depends on `T`,
that is, it's a dependent name. This example above won't build.

In that case, we need the `template` keyword to call the method:

    this->logger().template log<bt2c::Logger::Level::Info,
                                false>(__FILE__, __func__,
                                       __LINE__, "Hello!");

Using the `template` keyword or not would normally be a per-call
decision, but those BT_CPPLOG*() macros do the call themselves.

Knowing this, this patch adds the `template` keyword to all the logging
method calls from the BT_CPPLOG*() macros, just in case.

The current project builds because it doesn't have this specific
situation, but it could happen in the future.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I2847105746825d94cf71ed3abbd56fac0f160a2d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12477
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
src/cpp-common/bt2c/logging.hpp
This page took 0.032359 seconds and 4 git commands to generate.