mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 04:34:40 +03:00
see #2: move non-type template param auto to ch02
This commit is contained in:
16
code/2/2.16.fold.expression.cpp
Normal file
16
code/2/2.16.fold.expression.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// 2.16.fold.expression.cpp
|
||||
// chapter 2 language usability
|
||||
// modern cpp tutorial
|
||||
//
|
||||
// created by changkun at changkun.de
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
template<typename ... T>
|
||||
auto sum(T ... t) {
|
||||
return (t + ...);
|
||||
}
|
||||
int main() {
|
||||
std::cout << sum(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user