No viable conversion from 'bool' to 'std::string'

后端 未结 4 2115
感动是毒
感动是毒 2021-01-29 13:44

I have some code that looks like this:

static std::string Foo(const std::string& blah)
{
   if ( someWierdEdgeCase() ){
      return false;  // <-- this l         


        
4条回答
  •  青春惊慌失措
    2021-01-29 14:15

    static std::string Foo(const std::string& blah)
    {
       std::string resourcePath = "";
       if ( someWierdEdgeCase() ){
          return resourcePath; // <-- Now you're returning a string
       }
    
       resourcePath.append("/assets/");
       return resourcePath; 
    }  
    

提交回复
热议问题