File: cxx11-test-variadic_templates.cpp

package info (click to toggle)
libvmime 0.9.2-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,604 kB
  • sloc: cpp: 55,417; ansic: 822; makefile: 88; sh: 8
file content (23 lines) | stat: -rw-r--r-- 345 bytes parent folder | download | duplicates (32)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
int Accumulate()
{
	return 0;
}

template<typename T, typename... Ts>
int Accumulate(T v, Ts... vs)
{
	return v + Accumulate(vs...);
}

template<int... Is>
int CountElements()
{
	return sizeof...(Is);
}

int main()
{
	int acc = Accumulate(1, 2, 3, 4, -5);
	int count = CountElements<1,2,3,4,5>();
	return ((acc == 5) && (count == 5)) ? 0 : 1;
}