annotate 3rdparty/vmime/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp @ 0:a4671277546c tip

created the repository for the thymian project
author ferencd
date Tue, 17 Aug 2021 11:19:54 +0200
parents
children
rev   line source
ferencd@0 1 int Accumulate()
ferencd@0 2 {
ferencd@0 3 return 0;
ferencd@0 4 }
ferencd@0 5
ferencd@0 6 template<typename T, typename... Ts>
ferencd@0 7 int Accumulate(T v, Ts... vs)
ferencd@0 8 {
ferencd@0 9 return v + Accumulate(vs...);
ferencd@0 10 }
ferencd@0 11
ferencd@0 12 template<int... Is>
ferencd@0 13 int CountElements()
ferencd@0 14 {
ferencd@0 15 return sizeof...(Is);
ferencd@0 16 }
ferencd@0 17
ferencd@0 18 int main()
ferencd@0 19 {
ferencd@0 20 int acc = Accumulate(1, 2, 3, 4, -5);
ferencd@0 21 int count = CountElements<1,2,3,4,5>();
ferencd@0 22 return ((acc == 5) && (count == 5)) ? 0 : 1;
ferencd@0 23 }