Bonjour à tous !
Je sollicite votre aide car j'ai eu les yeux plus gros que le ventre...
J'ai créé une classe qui permet de calculer sur des entiers "embrouillés".
L'idée est de manipuler des entiers qui ne sont pas "en clair" en mémoire, sans avoir à les désembrouiller.
Le principe est simple : mes entiers sont codés dans une base B mais stockés dans une base T.
Je m'explique (c'est un peu matheux, mais pas trop) :
Si X est un entier < B^N, alors son écriture en base B ressemble à :
Somme ( i dans 0..N-1 ) de x[i] * B^i
Le tableau x contient N entiers entre 0 et B-1.
Par exemple, dans notre bonne vieille base 10 :
X = 273 = 3 + 7*10 + 2*100 = 3*10^0 + 7*10^1 + 2*10^2
on a x[3] = { 3,7,2 }
Donc, partant de là, je me suis dis : pourquoi ne pas convertir mon nombre en base B puis le stocker en l’interprétant comme un nombre en base T (on doit avoir T >= B si on ne veut pas perdre d'information).
Exemple : 273(en base 10) = 2043 (en base 5)
en effet 3 + 4*5 + 0*5^2 + 2*5^3 = 3 + 20 + 2*125 = 273
Mais ce nombre 2043 peut aussi s’interpréter comme un nombre en base 7.
Dans ce cas, on a : 3 + 4*7 + 0*7^2 + 2*7^3 = 3 + 28 + 686 = 717
Et voilà comment 273 se retrouve "embrouillé" en 717.
L'astuce, c'est que je peux continuer à faire des calculs arithmétiques dessus.
Et tout ça, ça marche impec' avec un belle classe template dont les arguments sont :
le type d'entiers utiliser pour stocker mon nombre embrouillé et les bases B et T.
Si T est une puissance de 2, alors je peux optimiser puisque chaque chiffre de mon nombre est stocké dans un groupe de bits distincts.
En utilisant un petit peu de méta programmation, j'arrive à une classe qui détecte toute seule si T est une puissance de 2 et utilise un mode de calcul optimisé.
Maintenant que je vous ai bien ennuyé avec toute cette histoire, voici le problème :
Mon code compile (et fonctionne) parfaitement sous Visual 2010 (niveau de warning à 4), mais provoque une cascade d'erreurs avec gcc !
Et là, je coince...
J'aimerais avoir un code full compatible gcc mais je ne comprends rien à la bordée d'injures qu'il m'envoie.
J'aurais aimé (comme je le fais souvent sur ce forum) n'envoyer qu'un sous ensemble de mon code pour vous faciliter la lecture, mais là, rien à faire, c'est trop imbriqué...
Donc voici mon code dans son intégralité () suivi des messages de gcc :
et voici ce qu'en pense gcc :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359 // classe de base pour "meta programmer" les fonctions de bases de la classe integer dont elle hérite template<typename num,int coded_base,int stored_base,int ispow2> struct integer_base {} ; // spécialisation pour 'stored_base' qui n'est pas une puissance de 2 template<typename num,int coded_base,int stored_base> class integer_base<num,coded_base,stored_base,0> { public: typedef num type ; protected: type value ; static const int B = coded_base ; // base source : 0 <= digit < B static const int T = stored_base ; // base de stockage static int N ; // nb de digit dans un 'type' static const type max_type = (((type)1 << (sizeof( type )*4))-1)*(((type)1 << (sizeof( type )*4))+1) ; // astuce (n-1)*(n+1) == n*n - 1 static const int div_size = sizeof( type )*8+1 ; static type div [div_size] ; static int zero ; // ce membre n'est là que pour être initialisé par un appel à 'pre_compute' static int pre_compute () // je n'arrive pas à forcer l'appel à 'pre_compute' autrement... { type b = 1 ; type t = 1 ; type biggest = 0 ; for ( max = 0 , N = 0 ;; N++ , b *= B , t *= T ) { if (t > (max_type - biggest)/(B-1) ) break ; if ((N > 0) && (t/T != div[N-1])) break ; biggest += (B-1)*t ; max += (B-1)*b ; div[N] = t ; } return 0 ; } int d ( int i ) const // lecture du digit i { return i < N ? (int)(value/div[i] % T) : 0 ; } bool d ( int i , int x ) // écriture du digit i -> renvoie false en cas de dépassement { if (i >= N) return (x == 0) ; int y = (value/div[i]) % T ; if (x == y) return true ; if (y > x) value -= (type)(y-x)*div[i] ; else value += (type)(x-y)*div[i] ; return true ; } public: static type max ; } ; template<typename num,int coded_base,int stored_base> typename integer_base<num,coded_base,stored_base,0>::type integer_base<num,coded_base,stored_base,0>::div [] ; template<typename num,int coded_base,int stored_base> typename integer_base<num,coded_base,stored_base,0>::type integer_base<num,coded_base,stored_base,0>::max ; template<typename num,int coded_base,int stored_base> int integer_base<num,coded_base,stored_base,0>::N ; template<typename num,int coded_base,int stored_base> int integer_base<num,coded_base,stored_base,0>::zero = integer_base<num,coded_base,stored_base,0>::pre_compute() ; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // spécialisation pour 'stored_base' qui est une puissance de 2 template<typename num,int coded_base,int stored_base> class integer_base<num,coded_base,stored_base,1> { public: typedef num type ; protected: type value ; template<int X,int P> struct pow { static const num result = X*pow<X,P-1>::result ;} ; template<int X> struct pow<X,0> { static const num result = 1 ;} ; template<int X> struct log2 { static const num result = 1+log2<X/2>::result ;} ; template<> struct log2<0> { static const num result = 0 ;} ; static const int B = coded_base ; // base : 0 <= digit < B static const int T = log2<stored_base>::result ; // nb bit par digit static const int N = (int)(sizeof( type )*8/T) ; // nb de digit dans un 'type' static const int zero = 0 ; static const type max_type = (((type)1 << (sizeof( type )*4))-1)*(((type)1 << (sizeof( type )*4))+1) ; int d ( int i ) const { return i < N ? (int)((value >> i*T)%(1<<T)) : 0 ; } bool d ( int i , int x ) { if (i >= N) return (x == 0) ; value = (type)((value & ~((((type)1<<T)-1) << (i*T))) | ((type)x << (i*T))) ; return true ; } public: static const type max = pow<B,N>::result-1 ; } ; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // classe qui permet de calculer sur des entiers qui restent offusqués en mémoire template<typename num,int coded_base,int stored_base> class integer : public integer_base<num,coded_base,stored_base,(~(stored_base-1)&stored_base)==stored_base> { public: typedef num type ; integer ( unsigned x = 0 ) { *this = (unsigned)(x+zero) ; // utilisation du membre 'zero' pour forcer l'appel à 'pre_compute'... } integer ( const integer & x ) { value = x.value ; } integer operator= ( unsigned x ) { value = 0 ; for ( int i = 0 ; x > 0 ; x /= B , i++ ) if (!d( i,x%B )) { value = max_type ; break ; } return *this ; } integer operator= ( const integer & x ) { value = x.value ; return *this ; } bool error () const { return value == max_type ; } unsigned get () const { if (error()) return (unsigned)-1 ; type res = 0 ; type p = 1 ; for ( int i = 0 ; i < N ; i++ , p *= B ) res += (type)(d( i )*p) ; return (unsigned)res ; } integer operator+ ( const integer & x ) const { if (error() || x.error()) return integer(false) ; integer res ; int c = 0 ; for ( int i = 0 ; i <= N ; i++ ) { int b = d(i) + x.d(i) + c ; c = b/B ; if (!res.d( i,b%B )) return integer(false) ; } return res ; } integer operator* ( const integer & x ) const { if (error() || x.error()) return integer(false) ; integer res ; for ( int j = 0 ; j < N ; j++ ) { int dj = d(j) ; int c = 0 ; integer t ; for ( int i = 0 ; i <= N ; i++ ) { int b = dj * x.d(i) + c ; c = b/B ; if (!t.d( i+j,b%B )) return integer(false) ; } res = res+t ; if (res.error()) return res ; } return res ; } template <typename output> friend output & operator<< ( output & o , const integer & i ) { return i.error() ? o << "overflow" : o << i.get() ; } template <typename output> friend output & operator<< ( output & o , const integer * i ) { bool z = !true ; for ( int n = N-1 ; n >= 0 ; n-- ) { z = z && (i->d( n ) == 0) ; if (!z) { o << i->d( n ) ; if (n > 0) o << '.' ; } } if (z) o << 0 ; return o ; } protected: integer ( bool ) { value = max_type ;} // construit un 'integer' en état d'erreur } ; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///// tests //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include <stdlib.h> #include <iostream> using namespace std ; template <typename num,int coded,int stored> bool sub_test0 ( unsigned a , unsigned b , bool verbose = false ) { unsigned long long aa = a ; unsigned long long bb = b ; integer<num,coded,stored> x = a ; integer<num,coded,stored> y = x+b ; if (verbose) { cout << "sub_test0<" ; switch ( sizeof( num )) { case 8 : cout << "unsigned long long," ; break ; case 4 : cout << "unsigned," ; break ; case 2 : cout << "unsigned short," ; break ; case 1 : cout << "unsigned byte," ; break ; } cout << coded << ',' << stored << ">( " << a << ',' << b << " ) [" << x.max << "] " ; } if ( y.error() && (aa+bb <= x.max)) if (!verbose) return sub_test0<num,coded,stored>( a,b,true ) ; else { cout << "error but " << a << '+' << b << " = " << aa+bb << " <= " << x.max << endl ; return false ; } if (!y.error() && (aa+bb != y.get())) if (!verbose) return sub_test0<num,coded,stored>( a,b,true ) ; else { cout << "no error but " << a << '+' << b << " = " << aa+bb << " != " << y << endl ; return false ; } y = x*b ; if ( y.error() && (aa*bb > 0) && (aa*bb <= x.max)) if (!verbose) return sub_test0<num,coded,stored>( a,b,true ) ; else { cout << "error but " << a << '*' << b << " = " << aa*bb << " <= " << x.max << endl ; return false ; } if (!y.error() && (a*b != y.get())) if (!verbose) return sub_test0<num,coded,stored>( a,b,true ) ; else { cout << "no error but " << a << '*' << b << " = " << a*b << " != " << y << endl ; return false ; } return true ; } template <typename num,int a,int b> bool sub_test1 ( unsigned x , unsigned y ) { bool ok = true ; ok = ok && sub_test0<num,2+a ,2+b >( x,y ) ; ok = ok && sub_test0<num,2+a ,2+b+1>( x,y ) ; ok = ok && sub_test0<num,2+a+1,2+b+1>( x,y ) ; return ok ; } template <typename num,int a,int b> bool sub_test2 ( unsigned x , unsigned y ) { bool ok = true ; ok = ok && sub_test1<num,a ,b >( x,y ) ; ok = ok && sub_test1<num,a ,b+2>( x,y ) ; ok = ok && sub_test1<num,a+2,b+2>( x,y ) ; return ok ; } template <typename num,int a,int b> bool sub_test3 ( unsigned x , unsigned y ) { bool ok = true ; ok = ok && sub_test2<num,a ,b >( x,y ) ; ok = ok && sub_test2<num,a ,b+4>( x,y ) ; ok = ok && sub_test2<num,a+4,b+4>( x,y ) ; return ok ; } template <typename num,int a,int b> bool sub_test4 ( unsigned x , unsigned y ) { bool ok = true ; ok = ok && sub_test3<num,a ,b >( x,y ) ; ok = ok && sub_test3<num,a ,b+4>( x,y ) ; ok = ok && sub_test3<num,a+4,b+4>( x,y ) ; return ok ; } unsigned random ( int nbbit ) { unsigned res = ((rand()&0xff) << 24) | ((rand()&0xff) << 16) | ((rand()&0xff) << 8) | (rand()&0xff) ; while ( nbbit++ < 32 ) res >>= 1 ; return res ; } bool test () { for ( int nb = 0 ; nb < 10000 ; nb++ ) { unsigned x = random( 1+rand()%31 ) ; unsigned y = random( 1+rand()%31 ) ; bool ok = true ; ok = ok && sub_test4<unsigned long long,0,0>( x,y ) ; ok = ok && sub_test4<unsigned long ,0,0>( x,y ) ; ok = ok && sub_test4<unsigned short ,0,0>( x,y ) ; ok = ok && sub_test4<unsigned char ,0,0>( x,y ) ; if (!ok) return false ; } return true ; } ////////////////////////////////////////////////////////////////////////// int main () { if (test()) cout << "ok" << endl ; else cout << "ERROR !!!" << endl ; return 0 ; }
Si je sors la struct log2 de la classe, j'ai un peu moins d'erreur, mais je ne comprends pas pourquoi...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97 >gcc main.cpp -Wall -lstdc++ main.cpp:82:18: error: explicit specialization in non-namespace scope 'class integer_base<num, coded_base, stored_base, 1>' main.cpp:82:38: error: template parameters not used in partial specialization: main.cpp:82:38: error: 'num' main.cpp:82:38: error: 'coded_base' main.cpp:82:38: error: 'stored_base' main.cpp: In constructor 'integer<num, coded_base, stored_base>::integer(unsigned int)': main.cpp:117:34: error: 'zero' was not declared in this scope main.cpp: In copy constructor 'integer<num, coded_base, stored_base>::integer(const integer<num, coded_base, stored_base>&)': main.cpp:122:13: error: 'value' was not declared in this scope main.cpp: In member function 'integer<num, coded_base, stored_base> integer<num, coded_base, stored_base>::operator=(unsigned int)': main.cpp:127:13: error: 'value' was not declared in this scope main.cpp:128:44: error: 'B' was not declared in this scope main.cpp:129:31: error: there are no arguments to 'd' that depend on a template parameter, so a declaration of 'd' must be available main.cpp:129:31: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) main.cpp:131:29: error: 'max_type' was not declared in this scope main.cpp: In member function 'integer<num, coded_base, stored_base> integer<num, coded_base, stored_base>::operator=(const integer<num, coded_base, stored_base>&)': main.cpp:139:13: error: 'value' was not declared in this scope main.cpp: In member function 'bool integer<num, coded_base, stored_base>::error() const': main.cpp:145:20: error: 'value' was not declared in this scope main.cpp:145:29: error: 'max_type' was not declared in this scope main.cpp: In member function 'unsigned int integer<num, coded_base, stored_base>::get() const': main.cpp:153:35: error: 'N' was not declared in this scope main.cpp:153:50: error: 'B' was not declared in this scope main.cpp:154:36: error: there are no arguments to 'd' that depend on a template parameter, so a declaration of 'd' must be available main.cpp: In member function 'integer<num, coded_base, stored_base> integer<num, coded_base, stored_base>::operator+(const integer<num, coded_base, stored_base>&) const': main.cpp:163:36: error: 'N' was not declared in this scope main.cpp:165:28: error: there are no arguments to 'd' that depend on a template parameter, so a declaration of 'd' must be available main.cpp:166:23: error: 'B' was not declared in this scope main.cpp: In member function 'integer<num, coded_base, stored_base> integer<num, coded_base, stored_base>::operator*(const integer<num, coded_base, stored_base>&) const': main.cpp:177:35: error: 'N' was not declared in this scope main.cpp:179:32: error: there are no arguments to 'd' that depend on a template parameter, so a declaration of 'd' must be available main.cpp:185:27: error: 'B' was not declared in this scope main.cpp: In function 'output& operator<<(output&, const integer<num, coded_base, stored_base>*)': main.cpp:206:27: error: 'N' was not declared in this scope main.cpp: In constructor 'integer<num, coded_base, stored_base>::integer(bool)': main.cpp:220:29: error: 'value' was not declared in this scope main.cpp:220:37: error: 'max_type' was not declared in this scope main.cpp: In function 'bool sub_test0(unsigned int, unsigned int, bool)': main.cpp:252:8: warning: suggest explicit braces to avoid ambiguous 'else' main.cpp:261:8: warning: suggest explicit braces to avoid ambiguous 'else' main.cpp:271:8: warning: suggest explicit braces to avoid ambiguous 'else' main.cpp:280:8: warning: suggest explicit braces to avoid ambiguous 'else' main.cpp: At global scope: main.cpp:81:89: error: template instantiation depth exceeds maximum of 1024 (use -ftemplate-depth= to increase the maximum) instantiating 'integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: [ skipping 1014 instantiation contexts ] main.cpp:249:9: instantiated from 'bool sub_test0(unsigned int, unsigned int, bool) [with num = long long unsigned int, int coded = 2, int stored = 2]' main.cpp:295:5: instantiated from 'bool sub_test1(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:304:5: instantiated from 'bool sub_test2(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:313:5: instantiated from 'bool sub_test3(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:322:5: instantiated from 'bool sub_test4(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:342:59: instantiated from here main.cpp:81:89: error: template instantiation depth exceeds maximum of 1024 (use -ftemplate-depth= to increase the maximum) instantiating 'integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' main.cpp:81:89: [ skipping 1014 instantiation contexts ] main.cpp:249:9: instantiated from 'bool sub_test0(unsigned int, unsigned int, bool) [with num = long long unsigned int, int coded = 2, int stored = 2]' main.cpp:295:5: instantiated from 'bool sub_test1(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:304:5: instantiated from 'bool sub_test2(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:313:5: instantiated from 'bool sub_test3(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:322:5: instantiated from 'bool sub_test4(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:342:59: instantiated from here main.cpp:81:89: error: 'integer_base<long long unsigned int, 2, 2, 1>::log2<0>::result' cannot be initialized by a non-constant expression when being declared main.cpp: In instantiation of 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<1>::result': main.cpp:81:89: instantiated from 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<2>::result' main.cpp:85:49: instantiated from 'const int integer_base<long long unsigned int, 2, 2, 1>::T' main.cpp:86:54: instantiated from 'const int integer_base<long long unsigned int, 2, 2, 1>::N' main.cpp:103:50: instantiated from 'const integer_base<long long unsigned int, 2, 2, 1>::type integer_base<long long unsigned int, 2, 2, 1>::max' main.cpp:249:9: instantiated from 'bool sub_test0(unsigned int, unsigned int, bool) [with num = long long unsigned int, int coded = 2, int stored = 2]' main.cpp:295:5: instantiated from 'bool sub_test1(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:304:5: instantiated from 'bool sub_test2(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:313:5: instantiated from 'bool sub_test3(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:322:5: instantiated from 'bool sub_test4(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:342:59: instantiated from here main.cpp:81:89: error: 'integer_base<long long unsigned int, 2, 2, 1>::log2<1>::result' cannot be initialized by a non-constant expression when being declared main.cpp: In instantiation of 'const long long unsigned int integer_base<long long unsigned int, 2, 2, 1>::log2<2>::result': main.cpp:85:49: instantiated from 'const int integer_base<long long unsigned int, 2, 2, 1>::T' main.cpp:86:54: instantiated from 'const int integer_base<long long unsigned int, 2, 2, 1>::N' main.cpp:103:50: instantiated from 'const integer_base<long long unsigned int, 2, 2, 1>::type integer_base<long long unsigned int, 2, 2, 1>::max' main.cpp:249:9: instantiated from 'bool sub_test0(unsigned int, unsigned int, bool) [with num = long long unsigned int, int coded = 2, int stored = 2]' main.cpp:295:5: instantiated from 'bool sub_test1(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:304:5: instantiated from 'bool sub_test2(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:313:5: instantiated from 'bool sub_test3(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:322:5: instantiated from 'bool sub_test4(unsigned int, unsigned int) [with num = long long unsigned int, int a = 0, int b = 0]' main.cpp:342:59: instantiated from here main.cpp:81:89: error: 'integer_base<long long unsigned int, 2, 2, 1>::log2<2>::result' cannot be initialized by a non-constant expression when being declared
D'autant que pow juste à côté ne semble pas poser de problème...
Donc, ceux qui sont arrivés jusque là l'auront compris, les gcc' guys qui voudraient bien éclairer ma lanterne sont les biens venus...
Merci de m'avoir lu et encore plus de me répondre
Partager