以下https://stackoverflow.com/a/9424211/3368959我正在尝试比较三个数字:
#include <iostream>
int main() {
std::cout << std::min({2,5,1}) << std::endl;
return 0;
}
但是编译器给我错误:
error: no matching function for call to ‘min(<brace-enclosed initializer list>)’
但是,代码在使用时编译得很好
std::min(std::min(2,5),1)
但是第一种方式应该适用于 c++11 标准。我做错了什么?