Laziness in C++11
Do you know how to perform a lazy evaluation of string, like in this D snippet: void log(lazy string msg) { static if (fooBarCondition) writefln(…) /* something with msg */ } Actually, the problem might not need laziness at all since the static if. Maybe it’s possible to discard char const* strings when not used? Like, in C++: void log(char const *msg) { #ifdef DEBUG cout << … << endl; /* something with msg */ #else /* nothing at all */ #endif } Any idea? Thank you. #ifdef DEBUG #define log(msg) do { cout << … << endl; } while(0) #else #define log(msg) do { } while(0) #endif There are two ways