#include <iostream>
using namespace std;
int main()
{
cout << std::max({1, 2, 3, 4}) << endl;
}
이게 왜 g++ c++14에서 에러가 날까
In function 'int main()': 7:34: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 7:34: note: candidates are: In file included from /usr/include/c++/4.9/bits/char_traits.h:39:0, from /usr/include/c++/4.9/ios:40, from /usr/include/c++/4.9/ostream:38, from /usr/include/c++/4.9/iostream:39, from 2: /usr/include/c++/4.9/bits/stl_algobase.h:217:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.9/bits/stl_algobase.h:217:5: note: template argument deduction/substitution failed: 7:34: note: candidate expects 2 arguments, 1 provided In file included from /usr/include/c++/4.9/bits/char_traits.h:39:0, from /usr/include/c++/4.9/ios:40, from /usr/include/c++/4.9/ostream:38, from /usr/include/c++/4.9/iostream:39, from 2: /usr/include/c++/4.9/bits/stl_algobase.h:261:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.9/bits/stl_algobase.h:261:5: note: template argument deduction/substitution failed: 7:34: note: candidate expects 3 arguments, 1 provided
에러메시지는 이럼.
vs2015에선 돌아가는데? 왜이럴가
ㅅㅂ algorithm include 했어야되네