cmake/c++11-test-variadic_templates-N2555.cpp

Fri, 23 Aug 2013 01:20:09 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 23 Aug 2013 01:20:09 +0300
changeset 478
c7f8989c995f
parent 473
2a84149fe642
permissions
-rw-r--r--

bit of a clarification

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;
}

mercurial