Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template<int head, int... tail>
- struct total_struct {
- static int const value = head + total_struct<tail...>::value;
- };
- template<int head>
- struct total_struct<head> {
- static int const value = head;
- };
- template<int... list>
- int total()
- {
- return total_struct<list...>::value;
- }
- int main ()
- {
- cout << total<1,2,3,4,5,6,7,8,9>() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement