C++ assert(0)
assert(0)
In TensorRT/samples/common/logging.h
the LogStreamConsumer:: severityPrefix
use of assert(0)
:
class LogStreamConsumer : protected LogStreamConsumerBase, public std::ostream
{
//...
private:
static std::string severityPrefix(Severity severity)
{
switch (severity)
{
//F for FATAL?
case Severity::kINTERNAL_ERROR: return "[F] ";
case Severity::kERROR: return "[E] ";
case Severity::kWARNING: return "[W] ";
case Severity::kINFO: return "[I] ";
case Severity::kVERBOSE: return "[V] ";
default: assert(0); return "";
}
}
//...
};
Reference ? The What does the Assert (0) Mean , assert(0)
is used to mark the "only reachable if there is a bug in my code" part with, that is, under normal circumstances, the program should not come to default
this branch; if to this branch, it shows the presence of a bug in the code.