I'd like to include some very simple logging in my app - removable at
compile time.
Avoiding macros .. I want to make sure this nonsense would be
optimized away by the compiler if I don't need it.
template<bool b>
void
log(const char* msg)
{
if (b == true)
{
std::cout << msg << std::endl;
}
}
....
const bool is_log_on = false;
int
main(int argc, char* argv)
{
...
log<is_log_on>("I am here.");
...
}
Since "is_log_on" evaluates to false at compile time, I'm hoping the
compiler optimizes it away so there is absolutely no affect on
performance. Is there a well-known problem with this approach or
extending it into a full blown out logging template class?
<offtopic>
Google and my ISPs newsgroup servers are so slow. Can anyone recommend
a free or relatively inexpensive good newgroup server to use?
</offtopic>
Thanks,
-Luther