libpnicore
unchecked_convertible.hpp
1 //
2 // (c) Copyright 2014 DESY, Eugen Wintersberger <eugen.wintersberger@desy.de>
3 //
4 // This file is part of libpnicore.
5 //
6 // libpnicore 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 2 of the License, or
9 // (at your option) any later version.
10 //
11 // libpnicore 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 libpnicore. If not, see <http://www.gnu.org/licenses/>.
18 //
19 // ============================================================================
20 //
21 // Created on: Dec 18, 2014
22 // Author: Eugen Wintersberger
23 //
24 #pragma once
25 
26 #include <boost/mpl/pair.hpp>
27 #include <boost/mpl/vector.hpp>
28 #include <boost/mpl/contains.hpp>
29 #include <boost/mpl/map.hpp>
30 #include <boost/mpl/at.hpp>
31 #include "id_type_map.hpp"
32 
33 namespace pni{
34 namespace core{
35 
42  typedef boost::mpl::map<
43  //-------------source type uint8--------------------------------------
44  boost::mpl::pair<
45  uint8,
46  boost::mpl::vector<uint8,uint16,uint32,uint64,
50  >,
51 
52  //----------------source type uint16----------------------------------
53  boost::mpl::pair<
54  uint16,
55  boost::mpl::vector<uint16,uint32,uint64,
56  int32,int64,
58  complex32,complex64,complex128>
59  >,
60 
61  //----------------------source type uint32----------------------------
62  boost::mpl::pair<
63  uint32,
64  boost::mpl::vector<uint32,uint64,
65  int64,
67  complex32,complex64,complex128>
68  >,
69 
70  //--------------------------source type uint64------------------------
71  boost::mpl::pair<
72  uint64,
73  boost::mpl::vector<uint64,
75  complex32,complex64,complex128>
76  >,
77 
78  //------------------------source type int8 ---------------------------
79  boost::mpl::pair<
80  int8,
81  boost::mpl::vector<int8,int16,int32,int64,
83  complex32,complex64,complex128>
84  >,
85 
86  //-----------------------source type int16----------------------------
87  boost::mpl::pair<
88  int16,
89  boost::mpl::vector<int16,int32,int64,
91  complex32,complex64,complex128>
92  >,
93 
94  //------------------------source type int32---------------------------
95  boost::mpl::pair<
96  int32,
97  boost::mpl::vector<int32,int64,
99  complex32,complex64,complex128>
100  >,
101 
102  //------------------------source type int64----------------------------
103  boost::mpl::pair<
104  int64,
105  boost::mpl::vector<int64,
107  complex32,complex64,complex128>
108  >,
109 
110  //-------------------------source type float32------------------------
111  boost::mpl::pair<
112  float32,
113  boost::mpl::vector<float32,float64,float128,
114  complex32,complex64,complex128>
115  >,
116 
117  //-------------------------source type float64------------------------
118  boost::mpl::pair<
119  float64,
120  boost::mpl::vector<float64,float128,complex64,
121  complex128>
122  >,
123 
124  //-------------------source type float128-----------------------------
125  boost::mpl::pair<float128,boost::mpl::vector<float128,complex128>>,
126 
127  //-------------------source type complex32----------------------------
128  boost::mpl::pair<
129  complex32,
130  boost::mpl::vector<complex32,complex64,complex128>
131  >,
132 
133  //-------------------source type complex64----------------------------
134  boost::mpl::pair<
135  complex64,
136  boost::mpl::vector<complex64,complex128>
137  >,
138 
139  //-------------------source type complex128---------------------------
140  boost::mpl::pair<complex128,boost::mpl::vector<complex128>>,
141 
142  //-------------------source type for string---------------------------
143  boost::mpl::pair<string,boost::mpl::vector<string>>,
144 
145  boost::mpl::pair<bool_t,boost::mpl::vector<bool_t>>,
146 
147  boost::mpl::pair<binary,boost::mpl::vector<binary>>
149 
150  //------------------------------------------------------------------------
160  template<
161  typename ST,
162  typename TT
163  >
165  {
167  typedef typename boost::mpl::at<unchecked_type_vectors,ST>::type map_element;
169  typedef boost::mpl::contains<map_element,TT> c;
171  static const bool value = c::value;
172  };
173 
174 //end of namespace
175 }
176 }
std::complex< float128 > complex128
128Bit complex floating point type
Definition: types/types.hpp:66
boost::mpl::at< unchecked_type_vectors, ST >::type map_element
select the map
Definition: unchecked_convertible.hpp:167
std::complex< float32 > complex32
32Bit complex floating point type
Definition: types/types.hpp:62
long double float128
128Bit IEEE floating point type
Definition: types/types.hpp:58
float float32
32Bit IEEE floating point type
Definition: types/types.hpp:57
Definition: add_op.hpp:29
std::complex< float64 > complex64
64Bit complex floating point type
Definition: types/types.hpp:64
int32_t int32
32Bit signed integer type
Definition: types/types.hpp:50
uint8_t uint8
8Bit unsigned integer type
Definition: types/types.hpp:47
check if a type is unchecked convertible
Definition: unchecked_convertible.hpp:164
boost::mpl::contains< map_element, TT > c
check if TT is in the map
Definition: unchecked_convertible.hpp:169
uint16_t uint16
16Bit unsigned integer type
Definition: types/types.hpp:49
uint64_t uint64
64Bit unsigned integer type
Definition: types/types.hpp:53
int64_t int64
64Bit signed integer type
Definition: types/types.hpp:52
double float64
64Bit IEEE floating point type
Definition: types/types.hpp:56
int16_t int16
16Bit signed integer type
Definition: types/types.hpp:48
int8_t int8
8Bit signed integer type
Definition: types/types.hpp:46
type erasure for POD data
Definition: value.hpp:46
uint32_t uint32
32Bit unsigned integer type
Definition: types/types.hpp:51
boost::mpl::map< boost::mpl::pair< uint8, boost::mpl::vector< uint8, uint16, uint32, uint64, int16, int32, int64, float32, float64, float128, complex32, complex64, complex128 > >, boost::mpl::pair< uint16, boost::mpl::vector< uint16, uint32, uint64, int32, int64, float32, float64, float128, complex32, complex64, complex128 > >, boost::mpl::pair< uint32, boost::mpl::vector< uint32, uint64, int64, float32, float64, float128, complex32, complex64, complex128 > >, boost::mpl::pair< uint64, boost::mpl::vector< uint64, float32, float64, float128, complex32, complex64, complex128 > >, boost::mpl::pair< int8, boost::mpl::vector< int8, int16, int32, int64, float32, float64, float128, complex32, complex64, complex128 > >, boost::mpl::pair< int16, boost::mpl::vector< int16, int32, int64, float32, float64, float128, complex32, complex64, complex128 > >, boost::mpl::pair< int32, boost::mpl::vector< int32, int64, float32, float64, float128, complex32, complex64, complex128 > >, boost::mpl::pair< int64, boost::mpl::vector< int64, float32, float64, float128, complex32, complex64, complex128 > >, boost::mpl::pair< float32, boost::mpl::vector< float32, float64, float128, complex32, complex64, complex128 > >, boost::mpl::pair< float64, boost::mpl::vector< float64, float128, complex64, complex128 > >, boost::mpl::pair< float128, boost::mpl::vector< float128, complex128 > >, boost::mpl::pair< complex32, boost::mpl::vector< complex32, complex64, complex128 > >, boost::mpl::pair< complex64, boost::mpl::vector< complex64, complex128 > >, boost::mpl::pair< complex128, boost::mpl::vector< complex128 > >, boost::mpl::pair< string, boost::mpl::vector< string > >, boost::mpl::pair< bool_t, boost::mpl::vector< bool_t > >, boost::mpl::pair< binary, boost::mpl::vector< binary > > > unchecked_type_vectors
unchecked convertible map
Definition: unchecked_convertible.hpp:148