claw  1.9.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@stuff-o-matic.com
24 */
32 #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 meta::type_list<signed long long int, meta::no_type>
42  non_standard_signed_types;
43 
44  typedef meta::type_list<unsigned long long int, meta::no_type>
45  non_standard_unsigned_types;
46 
47 #else // !def CLAW_HAS_LONG_LONG
48 
49  typedef meta::no_type non_standard_signed_types;
50  typedef meta::no_type non_standard_unsigned_types;
51 
52 #endif // CLAW_HAS_LONG_LONG
53 
55  typedef meta::type_list<
56  signed char,
57  meta::type_list<
58  signed short,
59  meta::type_list<signed int, non_standard_signed_types> > >
61 
63  typedef meta::type_list<
64  unsigned char,
66  unsigned short,
69 
78  template <std::size_t Size, typename TypeList>
80  {
81  private:
82  typedef typename TypeList::head_type head_type;
83  typedef typename TypeList::queue_type queue_type;
84 
85  public:
89  typedef typename meta::if_then_else<
90  sizeof(head_type) * 8 == Size, head_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  {
115 
116  }; // struct integer_of_size
117 
123  template <std::size_t Size>
125  {
128 
129  }; // struct unsigned_integer_of_size
130 
133 
136 
139 
142 
145 
148 
149 }
150 
151 #endif // __CLAW_TYPES_HPP__
Define the type of a signed integer stored with a given number of bits. Template parameters.
Definition: types.hpp:111
This meta class finds, in a list of types, the first type stored exactly with a given number of bits...
Definition: types.hpp:79
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:68
unsigned_integer_of_size< 32 >::type u_int_32
An unsigned integer on 32 bits.
Definition: types.hpp:138
Define the type of an unsigned integer stored with a given number of bits. Template parameters...
Definition: types.hpp:124
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:91
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:60
find_type_by_size< Size, signed_integers >::type type
The integer type that matches the given size.
Definition: types.hpp:114
Structures for meta-programming.
unsigned_integer_of_size< 8 >::type u_int_8
An unsigned integer on 8 bits.
Definition: types.hpp:132
Template classes for lists of types.
unsigned_integer_of_size< 16 >::type u_int_16
An unsigned integer on 16 bits.
Definition: types.hpp:135
integer_of_size< 32 >::type int_32
An integer on 32 bits.
Definition: types.hpp:147
find_type_by_size< Size, unsigned_integers >::type type
The integer type that matches the given size.
Definition: types.hpp:127
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:144
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:141
This is the main namespace.
Definition: application.hpp:49