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)};
-
LogStreamConsumeris a class used for handling log messages or streams. -
gLogFatalis an instance of theLogStreamConsumerclass. It is being initialized with the result of LOG_FATAL(gLogger). -
LOG_FATALis a inline function customize thegLogger -
gLoggeris an instance of a Logger class or object. -
Initialization: Theuniform initializationsyntax 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: