LogStreamVoidify() is a helper class used in the FB_LOG() and XLOG() macros.
Synopsis
Declared in <folly/logging/LogStreamProcessor.h>
template<bool Fatal>
class LogStreamVoidify;
Description
It's only purpose is to provide an & operator overload that returns void. This allows the log macros to expand roughly to:
(logEnabled) ? (void)0 : LogStreamVoidify{} & LogStreamProcessor{}.stream() << "msg";
This enables the right hand (':') side of the ternary ? expression to have a void type, and allows various streaming operator expressions to be placed on the right hand side of the expression.
Operator & is used since it has higher precedence than ?:, but lower precedence than <<.
This class is templated on whether the log message is fatal so that the operator& can be declared [[noreturn]]for fatal log messages. This prevents the compiler from complaining about functions that do not return a value after a fatal log statement.
Member Functions
Name |
Description |
In the default (non‐fatal) case, the & operator implementation is a no‐op. |
Specializations
Name |
Created with MrDocs