How to require all elements of a parameter pack to satisfy a concept?

See this code:

1
2
3
4
5
6
7
template<typename...T> requires is_arithmetic_v<T>...
int sum_by_fold(T...v)
{
	return (v + ... + 0);	// add all elements of v starting with 0
}

int x = sum_by_fold(1, 2.4, 78, 'a');


How can I ensure every parameter in the pack is arithmetic?

Thank you in advance
Use a fold expression:
requires (is_arithmetic_v<T> && ...)
thanks!!!

Topic archived. No new replies allowed.