NiHu  2.0
integer.hpp
Go to the documentation of this file.
1 // This file is a part of NiHu, a C++ BEM template library.
2 //
3 // Copyright (C) 2012-2014 Peter Fiala <fiala@hit.bme.hu>
4 // Copyright (C) 2012-2014 Peter Rucz <rucz@hit.bme.hu>
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 //
20 // Copyright (C) 2012-2014 Peter Fiala <fiala@hit.bme.hu>
21 // Copyright (C) 2012-2014 Peter Rucz <rucz@hit.bme.hu>
22 //
23 // This program is free software: you can redistribute it and/or modify
24 // it under the terms of the GNU General Public License as published by
25 // the Free Software Foundation, either version 3 of the License, or
26 // (at your option) any later version.
27 //
28 // This program is distributed in the hope that it will be useful,
29 // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 // GNU General Public License for more details.
32 //
33 // You should have received a copy of the GNU General Public License
34 // along with this program. If not, see <http://www.gnu.org/licenses/>.
35 
42 #ifndef INTEGER_HPP_INCLUDED
43 #define INTEGER_HPP_INCLUDED
44 
45 #include "operator.hpp"
46 #include "relation.hpp"
47 
48 namespace tmp
49 {
53  template <class T, T N>
54  struct integer : std::integral_constant<T, N>
55  {
57  typedef integer type;
59  static T const next = N+1;
61  static T const prev = N-1;
62  };
63 
70  template <class T, T N>
71  struct next<integer<T, N> > : integer<T, integer<T, N>::next> {};
72 
79  template <class T, T N>
80  struct prev<integer<T, N> > : integer<T, integer<T, N>::prev> {};
81 
89  template <class T, T N, T M>
90  struct plus<integer<T, N>, integer<T, M> > : integer<T, N+M> {};
91 
99  template <class T, T N, T M>
100  struct minus<integer<T, N>, integer<T, M> > : integer<T, N-M> {};
101 
109  template <class T, T N, T M>
110  struct mul<integer<T, N>, integer<T, M> > : integer<T, N*M> {};
111 
119  template <class T, T N, T M>
120  struct less<integer<T, N>, integer<T, M> > : std::integral_constant<bool, (N<M) > {};
121 
129  template <class T, T N, T M>
130  struct greater<integer<T, N>, integer<T, M> > : std::integral_constant<bool, (N>M) > {};
131 }
132 
133 #endif /* INTEGER_HPP_INCLUDED */
134 
tmp::less
General declaration of the less oparation.
Definition: relation.hpp:41
tmp::mul
binary multiply
Definition: operator.hpp:51
tmp::integer
integer type representation
Definition: integer.hpp:54
tmp
template metaprogramming functions
Definition: asymptotic_types.hpp:101
tmp::plus
binary plus
Definition: operator.hpp:43
tmp::minus
binary minus
Definition: operator.hpp:47
tmp::prev
decrement operator
Definition: operator.hpp:39
relation.hpp
Template metaprograms for comparison.
tmp::integer::type
integer type
self returning metafunction
Definition: integer.hpp:57
operator.hpp
declaration of operator metafunctions
tmp::next
increment operator
Definition: operator.hpp:35