-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexclude.cc
55 lines (48 loc) · 1.07 KB
/
exclude.cc
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
/*
@copyright Russell Standish 2000-2013
@author Russell Standish
This file is part of Classdesc
Open source licensed under the MIT license. See LICENSE for details.
*/
#include "classdesc.h"
#include "classdesc_epilogue.h"
#include <assert.h>
using namespace classdesc;
struct Foo
{
int a;
Foo(int x=0): a(x) {}
void b() {}
Foo operator+(const Foo& x) const {return a+x.a;}
};
int main()
{
Exclude<int> eint;
Exclude<Foo> efoo(2);
Exclude<Foo*> epfoo(&efoo);
Exclude<int*> epint(&(int&)eint);
Exclude<bool> bfoo(false);
eint = 3;
assert(eint+2 == 5);
assert(2+eint == 5);
assert(*epint+2 ==5);
assert(2+*epint ==5);
assert((efoo+Foo(3)).a==5);
assert((Foo(3)+efoo).a==5);
assert((*epfoo+Foo(3)).a==5);
efoo.b();
epfoo->b();
assert( (epfoo+2) - epfoo == 2);
assert( (2+epfoo) - epfoo == 2);
assert(bfoo||true);
assert((!bfoo)&&true);
assert(!(bfoo&&true));
assert((bfoo||bfoo)==false);
assert((bfoo&&bfoo)==false);
assert(bfoo==bfoo);
assert(!(bfoo!=bfoo));
bfoo|=true;
assert(bfoo);
bfoo&=false;
assert(!bfoo);
}