Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
power.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the gobelijn software.
3  * Gobelijn is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the
5  * Free Software Foundation, either version 3 of the License, or any later
6  * version. Gobelijn is distributed in the hope that it will be useful, but
7  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8  * or FITNESS FOR A PARTICULAR PURPOSE.
9  * See the GNU General Public License for details. You should have received
10  * a copy of the GNU General Public License along with the software. If not,
11  * see <http://www.gnu.org/licenses/>.
12  *
13  * Copyright 2012, Jan Broeckhove.
14  */
20 #include <iostream>
21 
22 // BEGIN_SNIPPET{FullSource}
24 template <int N>
25 struct power
26 {
27  static constexpr int value = 2 * power<N - 1>::value;
28 };
29 
31 template <>
32 struct power<0>
33 {
34  static constexpr int value = 1;
35 };
36 
37 int main()
38 {
39  int a[power<0>::value] = {1};
40  int b[power<3>::value] = {0, 0, 0, 0, 0, 0, 0, 0};
41  std::cout << a[0] << " --- " << b[0] << std::endl;
42  return 0;
43 }
44 // END_SNIPPET{FullSource}
int main()
Definition: power.cpp:37