]> www.ginac.de Git - cln.git/blob - src/integer/misc/cl_I_as.cc
Avoid some "suggest explicit braces to avoid ambiguous ‘else’" warnings.
[cln.git] / src / integer / misc / cl_I_as.cc
1 // cl_I_As().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/integer.h"
8
9
10 // Implementation.
11
12 #include "base/cl_N.h"
13
14 namespace cln {
15
16 // Cf. cl_I_p in cl_I_ring.cc.
17 // But here, for better inlining in g++, it is preferrable to finish every
18 // alternative with either "return true;" or "return false;".
19
20 inline bool cl_I_p (const cl_number& x)
21 {
22         if (!x.pointer_p())
23                 switch (x.nonpointer_tag()) {
24                 case cl_FN_tag:
25                         return true;
26                 }
27         else
28                 if (x.pointer_type() == &cl_class_bignum)
29                         return true;
30         return false;
31 }
32
33 const cl_I& cl_I_As (const cl_number& x, const char * filename, int line)
34 {
35         if (cl_I_p(x)) {
36                 DeclareType(cl_I,x);
37                 return x;
38         } else
39                 throw as_exception(x,"an integer",filename,line);
40 }
41
42 }  // namespace cln