title: Boost.Log macro expansion and conditional ternary operator
body: <p>I'm trying to compile:</p>
  
  <pre><code>#include &lt;boost/log/trivial.hpp&gt;
  
  int main(int argc, char* argv[]) {
    BOOST_LOG_TRIVIAL(info) &lt;&lt; "test Boost.Log";
    true ? 0 : BOOST_LOG_TRIVIAL(info) &lt;&lt; "this fails";
  }
  </code></pre>
  
  <p>Compilation command:</p>
  
  <pre><code>clang++ main.cc -o main \
    -lboost_log -lboost_log_setup -lboost_thread -lboost_system -pthread --static
  </code></pre>
  
  <p>Above throws an error:</p>
  
  <pre><code>main2.cc:5:18: error: expected expression
        true ? 0 : BOOST_LOG_TRIVIAL(info) &lt;&lt; "this fails";
                   ^
  /usr/local/include/boost/log/trivial.hpp:113:5: note: expanded from macro 'BOOST_LOG_TRIVIAL'
      BOOST_LOG_STREAM_WITH_PARAMS(::boost::log::trivial::logger::get(),\
      ^
  /usr/local/include/boost/log/sources/record_ostream.hpp:317:5: note: expanded from macro 'BOOST_LOG_STREAM_WITH_PARAMS'
      BOOST_LOG_STREAM_WITH_PARAMS_INTERNAL(logger, BOOST_LOG_UNIQUE_IDENTIFIER_NAME(_boost_log_record_), params_seq)
      ^
  /usr/local/include/boost/log/sources/record_ostream.hpp:306:5: note: expanded from macro 'BOOST_LOG_STREAM_WITH_PARAMS_INTERNAL'
      for (::boost::log::record rec_var = (logger).open_record((BOOST_PP_SEQ_ENUM(params_seq))); !!rec_var;)\
      ^
  1 error generated.
  </code></pre>
  
  <p>The above is a problem I've isolated when trying to create a macro:</p>
  
  <pre><code>#define LOG_IF(lvl, condition) \
    !(condition) ? 0 : BOOST_LOG_TRIVIAL(lvl)
  </code></pre>
  
  <p>When run g++ to expand macros (<code>g++ -E -C -P -o pre.cc main.cc</code>):</p>
  
  <pre><code>int main(int argc, char* argv[]) {
    for (::boost::log::record _boost_log_record_4 = (::boost::log::trivial::logger::get()).open_record((::boost::log::keywords::severity = ::boost::log::trivial::info)); !!_boost_log_record_4;) ::boost::log::aux::make_record_pump((::boost::log::trivial::logger::get()), _boost_log_record_4).stream() &lt;&lt; "test Boost.Log";
    true ? 0 : for (::boost::log::record _boost_log_record_5 = (::boost::log::trivial::logger::get()).open_record((::boost::log::keywords::severity = ::boost::log::trivial::info)); !!_boost_log_record_5;) ::boost::log::aux::make_record_pump((::boost::log::trivial::logger::get()), _boost_log_record_5).stream() &lt;&lt; "this fails";
  }
  </code></pre>
  
  <p>The reason why it fails it's obvious (form compilation error). But at this point I have no idea how to work around it.</p>