C++ addition overload ambiguity

前端 未结 5 1361
时光说笑
时光说笑 2020-12-21 13:14

I am coming up against a vexing conundrum in my code base. I can\'t quite tell why my code generates this error, but (for example) std::string does not.

cla         


        
5条回答
  •  滥情空心
    2020-12-21 14:02

    Template and non-template functions follow different rules. The template functions are selected on the actual parameter types, without any conversions being applied. In the case of the non-template (i.e. your code) an implicit conversion can be applied. Thus the templated stuff in basic_string is not ambiguous, but yours is.

提交回复
热议问题