Why does a quoted string match bool method signature before a std::string?

前端 未结 3 1125
滥情空心
滥情空心 2020-12-06 05:49

Given the following methods:

// Method 1
void add(const std::string& header, bool replace);

//Method 2
void add(const std::string& name, const std::         


        
3条回答
  •  悲哀的现实
    2020-12-06 05:56

    My guess is the conversion from pointer to bool is an implicit primitive type conversion, where the conversion to std::string requires the call of a constructor and the construction of a temporary.

提交回复
热议问题