프로그래밍/코드 조각
c++17 fold expression 예제
제페
2017. 12. 3. 13:15
반응형
#include <iostream>
using namespace std;
template < typename ...Types >
auto fold_sum(Types... types)
{
return (... + types);
}
int main()
{
auto res = fold_sum(1, 2, 3, 4, 5);
cout << "result: " << res << endl;
return 0;
}
vs2017에선 아직 지원을 안 한다. wandbox에서 돌려봤다.
반응형