claw 1.9.0
 
Loading...
Searching...
No Matches
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*/
30
33
34#ifndef __CLAW_TYPES_HPP__
35#define __CLAW_TYPES_HPP__
36
37namespace claw
38{
39#ifdef CLAW_HAS_LONG_LONG
40
42 non_standard_signed_types;
43
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,
58 signed short,
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__
Structures for meta-programming.
Structures for meta-programmation.
Definition claw.hpp:76
This is the main namespace.
integer_of_size< 16 >::type int_16
An integer on 16 bits.
Definition types.hpp:144
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
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
unsigned_integer_of_size< 8 >::type u_int_8
An unsigned integer on 8 bits.
Definition types.hpp:132
unsigned_integer_of_size< 32 >::type u_int_32
An unsigned integer on 32 bits.
Definition types.hpp:138
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
integer_of_size< 8 >::type int_8
An integer on 8 bits.
Definition types.hpp:141
This meta class finds, in a list of types, the first type stored exactly with a given number of bits.
Definition types.hpp:80
meta::if_then_else< sizeof(head_type) *8==Size, head_type, typenamefind_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
Define the type of a signed integer stored with a given number of bits. Template parameters.
Definition types.hpp:112
find_type_by_size< Size, signed_integers >::type type
The integer type that matches the given size.
Definition types.hpp:114
This structure allows to do conditional typing.
Empty type.
Definition no_type.hpp:41
Use this class to make a list of types.
Definition type_list.hpp:60
Define the type of an unsigned integer stored with a given number of bits. Template parameters.
Definition types.hpp:125
find_type_by_size< Size, unsigned_integers >::type type
The integer type that matches the given size.
Definition types.hpp:127
Template classes for lists of types.