Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
small1.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  */
19 #include <iostream>
20 
21 // BEGIN_SNIPPET{FullSource}
23 template <typename T1, typename T2, bool b = (sizeof(T1) < sizeof(T2))>
24 struct smaller_select
25 {
26  using type = T1;
27 };
28 
30 template <typename T1, typename T2>
31 struct smaller_select<T1, T2, false>
32 {
33  using type = T2;
34 };
35 
36 int main()
37 {
38  smaller_select<float, long int>::type haha = 0;
39  smaller_select<long double, float>::type hoho = 1.0;
40  std::cout << haha << " ... " << hoho << std::endl;
41  return 0;
42 }
43 // END_SNIPPET{FullSource}
int main()
Definition: small1.cpp:36