isl_schedule_tree.h: fix typo in comment
[isl.git] / interface / isl-noexceptions.h.pre
blobb45eb24d0afa86195a7e526bc8674b0b6e8d4ade
2 #include <functional>
3 #include <string>
5 namespace isl {
6 inline namespace noexceptions {
8 #define ISLPP_STRINGIZE_(X) #X
9 #define ISLPP_STRINGIZE(X) ISLPP_STRINGIZE_(X)
11 #define ISLPP_ASSERT(test, message)                          \
12   do {                                                       \
13     if (test)                                                \
14       break;                                                 \
15     fputs("Assertion \"" #test "\" failed at " __FILE__      \
16       ":" ISLPP_STRINGIZE(__LINE__) "\n  " message "\n",     \
17       stderr);                                               \
18   } while (0)
20 class boolean {
21 private:
22   isl_bool val;
24   friend isl::boolean manage(isl_bool val);
25   boolean(isl_bool val): val(val) {}
26 public:
27   boolean()
28       : val(isl_bool_error) {}
30   /* implicit */ boolean(bool val)
31       : val(val ? isl_bool_true : isl_bool_false) {}
33   bool is_error() const { return val == isl_bool_error; }
34   bool is_false() const { return val == isl_bool_false; }
35   bool is_true() const { return val == isl_bool_true; }
37   explicit operator bool() const {
38     ISLPP_ASSERT(!is_error(), "IMPLEMENTATION ERROR: Unhandled error state");
39     return is_true();
40   }
42   boolean operator!() const {
43     if (is_error())
44       return *this;
45     return !is_true();
46   }
49 inline isl::boolean manage(isl_bool val) {
50   return isl::boolean(val);
53 class ctx {
54   isl_ctx *ptr;
55 public:
56   /* implicit */ ctx(isl_ctx *ctx)
57       : ptr(ctx) {}
58   isl_ctx *release() {
59     auto tmp = ptr;
60     ptr = nullptr;
61     return tmp;
62   }
63   isl_ctx *get() {
64     return ptr;
65   }
68 enum class stat {
69   ok = isl_stat_ok,
70   error = isl_stat_error
74 } // namespace isl