PPL  1.2
Result_inlines.hh
Go to the documentation of this file.
1 /* Result supporting functions implementation: inline functions.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Result_inlines_hh
25 #define PPL_Result_inlines_hh 1
26 
27 #include "assertions.hh"
28 
29 namespace Parma_Polyhedra_Library {
30 
32 inline Result
34  const unsigned res = static_cast<unsigned>(x) & static_cast<unsigned>(y);
35  return static_cast<Result>(res);
36 }
37 
39 inline Result
41  const unsigned res = static_cast<unsigned>(x) | static_cast<unsigned>(y);
42  return static_cast<Result>(res);
43 }
44 
46 inline Result
48  const Result y_neg = static_cast<Result>(~static_cast<unsigned>(y));
49  return x & y_neg;
50 }
51 
53 inline Result_Class
55  const Result rc = r & static_cast<Result>(VC_MASK);
56  return static_cast<Result_Class>(rc);
57 }
58 
60 inline Result_Relation
62  const Result rc = r & static_cast<Result>(VR_MASK);
63  return static_cast<Result_Relation>(rc);
64 }
65 
67 inline Result
69  return r & (static_cast<Result>(VR_MASK) | static_cast<Result>(VC_MASK));
70 }
71 
72 inline int
74  switch (result_class(r)) {
75  case VC_NORMAL:
76  switch (r) {
77  case V_LT_INF:
78  return -1;
79  case V_GT_SUP:
80  return 1;
81  default:
82  break;
83  }
84  break;
85  case VC_MINUS_INFINITY:
86  return -1;
87  case VC_PLUS_INFINITY:
88  return 1;
89  default:
90  break;
91  }
92  return 0;
93 }
94 
95 inline bool
97  return (r & V_UNREPRESENTABLE) != V_UNREPRESENTABLE;
98 }
99 
100 } // namespace Parma_Polyhedra_Library
101 
102 #endif // !defined(PPL_Result_inlines_hh)
A positive integer overflow occurred (rounding down).
Definition: Result_defs.hh:108
int result_overflow(Result r)
Result
Possible outcomes of a checked arithmetic computation.
Definition: Result_defs.hh:76
Negative infinity result class.
Definition: Result_defs.hh:34
Result_Relation result_relation(Result r)
I_Result operator&(I_Result a, I_Result b)
Positive infinity result class.
Definition: Result_defs.hh:37
Result_Class result_class(Result r)
The computed result is not representable.
Definition: Result_defs.hh:159
Representable number result class.
Definition: Result_defs.hh:31
I_Result operator|(I_Result a, I_Result b)
Result result_relation_class(Result r)
The entire library is confined to this namespace.
Definition: version.hh:61
Enable_If< Is_Singleton< T >::value, Interval< B, Info > >::type operator-(const Interval< B, Info > &x, const T &y)
bool result_representable(Result r)
A negative integer overflow occurred (rounding up).
Definition: Result_defs.hh:105