std::string tmp;
tmp +=0;//compile error:ambiguous overload for 'operator+=' (operand types are 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' and 'int')
tmp +=1;//ok
tmp += '\0';//ok...expected
tmp +=INT_MAX;//ok
tmp +=int(INT_MAX);//still ok...what?
The first one argues that passing integer as argument, right? Why others passes compilation?I tested on Visual C++ and g++, and I got the same result above. So I believe I miss something defined by standard. What is it?
int
will be converted tochar
. but for0
its difficult to say whether itsNULL
orint 0