Claw  1.7.3
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:
90  typedef
91  typename meta::if_then_else
92  < sizeof(head_type) * 8 == Size, head_type,
94 
95  }; // find_type_by_size
96 
98  template<std::size_t Size>
99  struct find_type_by_size<Size, meta::no_type>
100  {
103  struct type;
104  }; // find_type_by_size
105 
112  template<std::size_t Size>
114  {
117 
118  }; // struct integer_of_size
119 
126  template<std::size_t Size>
128  {
131 
132  }; // struct unsigned_integer_of_size
133 
136 
139 
142 
145 
148 
151 
152 } // namespace claw
153 
154 #endif // __CLAW_TYPES_HPP__
Define the type of a signed integer stored with a given number of bits. Template parameters.
Definition: types.hpp:113
This meta class finds, in a list of types, the first type stored exactly with a given number of bits.
Definition: types.hpp:81
unsigned_integer_of_size< 32 >::type u_int_32
An unsigned integer on 32 bits.
Definition: types.hpp:141
Define the type of an unsigned integer stored with a given number of bits. Template parameters.
Definition: types.hpp:127
find_type_by_size< Size, signed_integers >::type type
The integer type that matches the given size.
Definition: types.hpp:116
Structures for meta-programming.
unsigned_integer_of_size< 8 >::type u_int_8
An unsigned integer on 8 bits.
Definition: types.hpp:135
meta::if_then_else< sizeof(head_type) *8==Size, head_type, typename find_type_by_size< Size, queue_type >::type >::result type
If the size of head_type matches the desired one, then the result is head_type, otherwise we search t...
Definition: types.hpp:93
meta::type_list< signed char, meta::type_list< signed short, meta::type_list< signed int, non_standard_signed_types > > > signed_integers
This is the list of c++ signed integer types.
Definition: types.hpp:62
meta::type_list< unsigned char, meta::type_list< unsigned short, meta::type_list< unsigned int, non_standard_unsigned_types > > > unsigned_integers
This is the list of c++ unsigned integer types.
Definition: types.hpp:70
Template classes for lists of types.
unsigned_integer_of_size< 16 >::type u_int_16
An unsigned integer on 16 bits.
Definition: types.hpp:138
integer_of_size< 32 >::type int_32
An integer on 32 bits.
Definition: types.hpp:150
find_type_by_size< Size, unsigned_integers >::type type
The integer type that matches the given size.
Definition: types.hpp:130
Use this class to make a list of types.
Definition: type_list.hpp:59
integer_of_size< 16 >::type int_16
An integer on 16 bits.
Definition: types.hpp:147
This structure allows to do conditional typing.
Definition: conditional.hpp:50
integer_of_size< 8 >::type int_8
An integer on 8 bits.
Definition: types.hpp:144
This is the main namespace.
Definition: algorithm.hpp:33