Variadic template resolution in VS2013 - Error C3520

前端 未结 2 1439
野的像风
野的像风 2021-01-26 18:44

What\'s wrong with this code?

enum LogLevel {
    LogLevel_Error = 1,
    LogLevel_Warning = 2,
    LogLevel_Info = 3,
    LogLevel_Debug = 4
};

LogLevel GetLog         


        
相关标签:
2条回答
  • 2021-01-26 18:54

    You probably need

    Write(level, ss, rest...);
    //                   ^^^ Note these dots!
    
    0 讨论(0)
  • 2021-01-26 19:19

    I see the following issues:

    1. rest needs to be expanded:

      Write(level, ss, rest...);
      
    2. Write is supposed to take a log level as its first argument:

      Write(GetLogLevel(), std::stringstream(), "Hello", (const char*)" World!", 1);
      
    3. You can't pass a temporary std::stringstream to an lvalue reference:

      std::stringstream ss;
      Write(GetLogLevel(), ss, "Hello", (const char*)" World!", 1);
      
    0 讨论(0)
提交回复
热议问题