aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/syntax_test.cpp
blob: 1ff4267a0be7d26b23b44b43ea19a894b66b1371 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <meowpp/syntax.h>
#include <meowpp/debug/assert.h>

class SomeObj {
 private:
  int* flag;
 public:
  SomeObj(int* a_flag) : flag(a_flag) { (*flag) |= 1; }
  ~SomeObj() { (*flag) |= 2; }
};

int main() {
  int flag = 0;
  with (SomeObj obj(&flag)) {
    Assert(flag == 1, "No constructor?");
  }
  Assert(flag == 3, "No destructor?");

  flag = 0;
  with (SomeObj obj(&flag))
    Assert(flag == 1, "No constructor?");
  Assert(flag == 3, "No destructor?");
  return 0;
}