wrong function being picked

后端 未结 3 1995
抹茶落季
抹茶落季 2021-01-03 19:38

I was trying to clean up some code that uses char* with std::string and ran into a problem that is illustrated by the following code.



        
3条回答
  •  没有蜡笔的小新
    2021-01-03 20:09

    One simple fix would be to change the bool to int - there is an implicit conversion from a pointer to bool, but not to int. bool to int is not a problem, so the existing code that passes bools will continue to work.

    Unfortunately this does impact the code readability a little by masking the parameter's intent.

提交回复
热议问题