报错类型如下:
E0304 没有与参数列表匹配的 重载函数 "min" 实例
C2784 “_Ty std::min(std::initializer_list<_Elem>,_Pr)”: 未能从“float”为“std::initializer_list<_Elem>”推导 模板 参数
C2780 “_Ty std::min(std::initializer_list<_Elem>)”: 应输入 1 个参数,却提供了 2 个
C2672 “std::min”: 未找到匹配的重载函数
C2780 “const _Ty &std::min(const _Ty &,const _Ty &,_Pr) noexcept(<expr>)”: 应输入 3 个参数,却提供了 2 个
C2782 “const _Ty &std::min(const _Ty &,const _Ty &) noexcept(<expr>)”: 模板 参数“_Ty”不明确
C2784 “const _Ty &std::min(const _Ty &,const _Ty &) noexcept(<expr>)”: 未能从“int”为“const _Ty &”推导 模板 参数
原因和解决办法
原因:min或max函数内的两个数的数据类型不一致,比如我的函数是min(float,int).
解决办法:将min/max函数内的数据转成相同的数据类型。即:int强制变成float,min(float,(float)int).