KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm using a logging module that can have reporting enabled/disabled at runtime. Calls generally go something like: WARN( "Danger Will Robinson! There are " + boost::lexical_cast<string>(minutes) + " minutes of oxygen left!" ); I'm using an inline function for WARN, but I'm curious as to how much optimization is going on behind the scenes -- evaluation of the arguments throughout the entire program would be costly. The WARN function goes something like this: bool WARNINGS_ENABLED = false; inline void WARN(const string &message) { if (!WARNINGS_ENABLED) { return; } // ... } Given that constructing the string argument has no side-effects, will the compiler optimize it out? Is a certain level of optimization required ( -Ox in g++ for some x )?
Tags (comma-separated)
Save Edits
Cancel