News for hackers. Stuff that matters.
Re:A Perspective on C++ Standardization in 2018 by frabert on Saturday December 29, 2018 @07:51AM (#18783363)
I don't think that's necessarily true, using constexpr facilities you could make a function do nothing according to a compile-time variable value
Re:A Perspective on C++ Standardization in 2018 by Ace17 on Saturday December 29, 2018 @01:09PM (#18784852)
I agree ; however, the tricky part - I believe - is not computing the message string in case you're not going to print/record it.
Re:A Perspective on C++ Standardization in 2018 by xamolxix on Saturday December 29, 2018 @11:00AM (#18784151)
Is IO allowed in constexpr functions?
Re:A Perspective on C++ Standardization in 2018 by justbuchanan on Saturday December 29, 2018 @11:27AM (#18784281)
I don't think so, but for zero-cost logging you just need the conditional for your branch to be constexpr. If the branch is known not to be taken at compile time, the compiler can just throw it away.

Something like:

  void MyDebugLog(text) {
    if (<constepxr check if logging enabled>) {
      // actually log...
    }
  }