2

I was reading the code from spdlog(C++ logging library) in github and i come up to the following template:

template<typename Factory>
SPDLOG_INLINE std::shared_ptr<logger> stdout_color_mt(const std::string &logger_name, color_mode mode)
{
    return Factory::template create<sinks::stdout_color_sink_mt>(logger_name, mode);
}

My general understanding of the code is that this will produce a function that will return a smart pointer using the another template called create. My confusion is about the meaning of Factory::template after the return statement.

Theo Niko
  • 27
  • 5
  • 1
    TL;DR of the dupe: `Factory` is a template type so `create` is a dependent name. Since it is a template, you need that there to inform the compiler what it is. – NathanOliver Jun 21 '19 at 12:31
  • 1
    Summarized, if you have a type `T` which has a template function `create()` it's not sufficient to say `T::create()`, you have to say `T::template create()`. – Stack Danny Jun 21 '19 at 12:34

0 Answers0