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

Fri, 23 Aug 2013 00:54:31 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 23 Aug 2013 00:54:31 +0300
changeset 476
baa35b4b67dc
parent 473
2a84149fe642
permissions
-rw-r--r--

fixed: front and back camera wouldn't render anything

473
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 int Accumulate()
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 {
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 return 0;
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 }
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 template<typename T, typename... Ts>
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 int Accumulate(T v, Ts... vs)
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 {
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 return v + Accumulate(vs...);
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 }
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 template<int... Is>
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 int CountElements()
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 {
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 return sizeof...(Is);
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 }
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 int main()
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 {
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 int acc = Accumulate(1, 2, 3, 4, -5);
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 int count = CountElements<1,2,3,4,5>();
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 return ((acc == 5) && (count == 5)) ? 0 : 1;
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 }

mercurial