C++ 如何绕过a<&书信电报;仿佛在呼唤#ifndef调试“;c+中的宏+;?

C++ 如何绕过a<&书信电报;仿佛在呼唤#ifndef调试“;c+中的宏+;?,c++,macros,iostream,ostream,conditional-compilation,C++,Macros,Iostream,Ostream,Conditional Compilation,我为自己编写了一个小日志库,它接受两种形式的调用 一个喜欢正常的函数调用,另一个喜欢std::ostream为什么不生成操作符为什么不生成操作符是一个(可能)在优化版本中不生成代码的解决方案好吗?是一个(可能)在优化版本中不生成代码的解决方案好吗?多亏了@Botje,我试试你的第二种方法。我用你的方法得到了我想要的!非常感谢你!多亏了@Botje,我会试试你的第二种方法。我用你的方法2得到了我想要的!非常感谢你! #ifdef DEBUG #define LOG_DEBUG( strLogBod

我为自己编写了一个小日志库,它接受两种形式的调用


一个喜欢正常的函数调用,另一个喜欢std::ostream为什么不生成
操作符为什么不生成
操作符是一个(可能)在优化版本中不生成代码的解决方案好吗?是一个(可能)在优化版本中不生成代码的解决方案好吗?多亏了@Botje,我试试你的第二种方法。我用你的方法得到了我想要的!非常感谢你!多亏了@Botje,我会试试你的第二种方法。我用你的方法2得到了我想要的!非常感谢你!
#ifdef DEBUG
#define LOG_DEBUG( strLogBody )  appendLog( leon_log::LogLevel_e::ellDebug,  std::string( __func__ ) + "()," + ( strLogBody ) )
#define LOG_INFOR( strLogBody ) appendLog( leon_log::LogLevel_e::ellInfor,  std::string( __func__ ) + "()," + ( strLogBody ) )
#define log_debug ( Logger_t( LogLevel_e::ellDebug ) << __func__ << "()," )
#define log_infor ( Logger_t( LogLevel_e::ellInfor ) << __func__ << "()," )
//...more for other log-levels

#else

#define LOG_DEBUG( strLogBody )
#define LOG_INFOR( strLogBody ) appendLog( leon_log::LogLevel_e::ellInfor, ( strLogBody ) )
#define log_debug ( Logger_t( LogLevel_e::ellDebug ) )
#define log_infor ( Logger_t( LogLevel_e::ellInfor ) )
//...more for other log-levels
#endif
template <typename T>
inline Logger_t& operator<<( Logger_t& lgr, const T& body ) {
   if ( lgr.m_LogLevel >= g_ellLogLevel )
      dynamic_cast<std::ostringstream&>( lgr ) << body;

   return lgr;
};
#ifndef DEBUG
struct Logger_t {
  template <class T>
  Logger_t& operator <<(const T& o) { return *this; }
};
#endif
#define log_debug false && Logger_t{}