std::to_string - more than instance of overloaded function matches the argument list

后端 未结 2 966
南笙
南笙 2020-11-27 16:36

counter is an int

void SentryManager::add(std::string name,std::shared_ptr){
    name = name + std::to_string(counter         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 17:28

    You have tripped over C++ DR 1261, which reads in part

    The code "int i; to_string(i);" fails to compile, as 'int' is ambiguous between 'long long' and 'long long unsigned'. It seems unreasonable to expect users to cast numbers up to a larger type just to use to_string.

    The proposed resolution is to add more overloads. GCC has implemented this already; I guess MSVC hasn't.

提交回复
热议问题