$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
promotions.hh
1 // Copyright (C) 2006, 2007, 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef MLN_VALUE_BUILTIN_PROMOTIONS_HH
27 # define MLN_VALUE_BUILTIN_PROMOTIONS_HH
28 
34 # include <mln/trait/promote.hh>
35 # include <mln/metal/ret.hh>
36 
37 
38 # define mln_internal_set_promotion_(Builtin1, Builtin2, Result) \
39  \
40  template<> \
41  struct set_precise_binary_< promote, Builtin1, Builtin2 > \
42  { \
43  typedef Result ret; \
44  }; \
45  \
46  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n \
47 
48 
49 # define mln_internal_set_promotion_auto_(From, To) \
50  \
51  mln_internal_set_promotion_(From, To, To); \
52  mln_internal_set_promotion_(To, From, To); \
53  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
54 
55 
56 # define mln_internal_set_promotion_twice_(From, To) \
57  \
58  mln_internal_set_promotion_(From, From, To); \
59  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
60 
61 
62 # define mln_internal_set_promotion_bi_(From1, From2, To) \
63  \
64  mln_internal_set_promotion_(From1, From2, To); \
65  mln_internal_set_promotion_(From2, From1, To); \
66  struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
67 
68 
69 
70 namespace mln
71 {
72 
73  // Fwd decl.
74  namespace value { template <typename B> struct Built_In; }
75 
76 
77  namespace trait
78  {
79 
80  // Builtin binary traits.
81 
82 
83  mln_internal_set_promotion_bi_(unsigned char, signed char, int);
84  mln_internal_set_promotion_bi_(unsigned short, signed char, int);
85  mln_internal_set_promotion_bi_(unsigned int, signed char, int);
86  mln_internal_set_promotion_bi_(unsigned long, signed char, long);
87 
88  mln_internal_set_promotion_bi_(unsigned short, signed short, int);
89  mln_internal_set_promotion_bi_(unsigned int, signed short, int);
90  mln_internal_set_promotion_bi_(unsigned long, signed short, long);
91 
92  mln_internal_set_promotion_bi_(unsigned long, signed int, long);
93 
94 
95  mln_internal_set_promotion_twice_(unsigned char, unsigned);
96  mln_internal_set_promotion_twice_( signed char, int);
97  mln_internal_set_promotion_twice_(unsigned short, unsigned);
98  mln_internal_set_promotion_twice_( signed short, int);
99  mln_internal_set_promotion_twice_(unsigned int, unsigned);
100  mln_internal_set_promotion_twice_( signed int, int);
101  mln_internal_set_promotion_twice_(unsigned long, unsigned long);
102  mln_internal_set_promotion_twice_( signed long, long);
103 
104  mln_internal_set_promotion_twice_( float, float);
105  mln_internal_set_promotion_twice_( double, double);
106 
107 
108  mln_internal_set_promotion_auto_(unsigned char, unsigned short);
109  mln_internal_set_promotion_auto_(unsigned char, signed short);
110  mln_internal_set_promotion_auto_( signed char, signed short);
111 
112  mln_internal_set_promotion_auto_(unsigned char, unsigned int);
113  mln_internal_set_promotion_auto_(unsigned char, signed int);
114  mln_internal_set_promotion_auto_( signed char, signed int);
115  mln_internal_set_promotion_auto_(unsigned short, unsigned int);
116  mln_internal_set_promotion_auto_(unsigned short, signed int);
117  mln_internal_set_promotion_auto_( signed short, signed int);
118  mln_internal_set_promotion_auto_(unsigned int, signed int);
119 
120  mln_internal_set_promotion_auto_(unsigned char, unsigned long);
121  mln_internal_set_promotion_auto_(unsigned char, signed long);
122  mln_internal_set_promotion_auto_( signed char, signed long);
123  mln_internal_set_promotion_auto_(unsigned short, unsigned long);
124  mln_internal_set_promotion_auto_(unsigned short, signed long);
125  mln_internal_set_promotion_auto_( signed short, signed long);
126  mln_internal_set_promotion_auto_(unsigned int, unsigned long);
127  mln_internal_set_promotion_auto_(unsigned int, signed long);
128  mln_internal_set_promotion_auto_( signed int, signed long);
129 
130  mln_internal_set_promotion_auto_(unsigned char, float);
131  mln_internal_set_promotion_auto_( signed char, float);
132  mln_internal_set_promotion_auto_(unsigned short, float);
133  mln_internal_set_promotion_auto_( signed short, float);
134  mln_internal_set_promotion_auto_(unsigned int, float);
135  mln_internal_set_promotion_auto_( signed int, float);
136  mln_internal_set_promotion_auto_(unsigned long, float);
137  mln_internal_set_promotion_auto_( signed long, float);
138 
139  mln_internal_set_promotion_auto_(unsigned char, double);
140  mln_internal_set_promotion_auto_( signed char, double);
141  mln_internal_set_promotion_auto_(unsigned short, double);
142  mln_internal_set_promotion_auto_( signed short, double);
143  mln_internal_set_promotion_auto_(unsigned int, double);
144  mln_internal_set_promotion_auto_( signed int, double);
145  mln_internal_set_promotion_auto_(unsigned long, double);
146  mln_internal_set_promotion_auto_( signed long, double);
147 
148  mln_internal_set_promotion_auto_( float, double);
149 
150  } // end of namespace mln::trait
151 
152 } // end of namespace mln
153 
154 
155 #endif // ! MLN_VALUE_BUILTIN_PROMOTIONS_HH