Claw  1.7.0
types.hpp
Go to the documentation of this file.
1 /*
2  CLAW - a C++ Library Absolutely Wonderful
3 
4  CLAW is a free library without any particular aim but being useful to
5  anyone.
6 
7  Copyright (C) 2005-2011 Julien Jorge
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23  contact: julien.jorge@gamned.org
24 */
31 #include <claw/meta/type_list.hpp>
33 
34 #ifndef __CLAW_TYPES_HPP__
35 #define __CLAW_TYPES_HPP__
36 
37 namespace claw
38 {
39 #ifdef CLAW_HAS_LONG_LONG
40 
41  typedef
42  meta::type_list<signed long long int, meta::no_type>
43  non_standard_signed_types;
44 
45  typedef
46  meta::type_list<unsigned long long int, meta::no_type>
47  non_standard_unsigned_types;
48 
49 #else // !def CLAW_HAS_LONG_LONG
50 
51  typedef meta::no_type non_standard_signed_types;
52  typedef meta::no_type non_standard_unsigned_types;
53 
54 #endif // CLAW_HAS_LONG_LONG
55 
57  typedef meta::type_list
58  < signed char,
59  meta::type_list
60  < signed short,
61  meta::type_list<signed int, non_standard_signed_types>
63 
65  typedef meta::type_list
66  < unsigned char,
68  < unsigned short,
71 
80  template<std::size_t Size, typename TypeList>
82  {
83  private:
84  typedef typename TypeList::head_type head_type;
85  typedef typename TypeList::queue_type queue_type;
86 
87  public:
88  typedef
89  typename meta::if_then_else
90  < sizeof(head_type) * 8 == Size, head_type,
91  typename find_type_by_size<Size, queue_type>::type >::result type;
92 
93  }; // find_type_by_size
94 
96  template<std::size_t Size>
97  struct find_type_by_size<Size, meta::no_type>
98  {
101  struct type;
102  }; // find_type_by_size
103 
110  template<std::size_t Size>
112  {
113  typedef typename find_type_by_size<Size, signed_integers>::type type;
114  }; // struct integer_of_size
115 
122  template<std::size_t Size>
124  {
125  typedef typename find_type_by_size<Size, unsigned_integers>::type type;
126  }; // struct unsigned_integer_of_size
127 
128  typedef unsigned_integer_of_size<8>::type u_int_8;
129  typedef unsigned_integer_of_size<16>::type u_int_16;
130  typedef unsigned_integer_of_size<32>::type u_int_32;
131 
132  typedef integer_of_size<8>::type int_8;
133  typedef integer_of_size<16>::type int_16;
134  typedef integer_of_size<32>::type int_32;
135 
136 } // namespace claw
137 
138 #endif // __CLAW_TYPES_HPP__