Learn C++ 1: Initializing Objects with Functions
As a newbie to C++, I came across many challenges when working on a project with this versatile language. Learn by doing, these blogs (Learn C++) are the record of practical examples I collected.
I was confused by the following line, when reading the implementation of logger
in TensorRT examples.
LogStreamConsumer gLogFatal{LOG_FATAL(gLogger)};
-
LogStreamConsumer
is a class used for handling log messages or streams. -
gLogFatal
is an instance of theLogStreamConsumer
class. It is being initialized with the result of LOG_FATAL(gLogger
). -
LOG_FATAL
is a inline function customize thegLogger
-
gLogger
is an instance of a Logger class or object. -
Initialization
: Theuniform initialization
syntax is used:type var_name{arg1, arg2, ....arg n}
The gLogFatal object is being initialized with the result of calling LOG_FATAL with gLogger as an argument. This suggests that LOG_FATAL is constructing a LogStreamConsumer object, possibly based on the severity level of gLogger.
Enjoy Reading This Article?
Here are some more articles you might like to read next: