source:
src/libcfa/containers/maybe
@
fab6ded
Last change on this file since fab6ded was 20877d2, checked in by , 7 years ago | |
---|---|
|
|
File size: 1.2 KB |
Rev | Line | |
---|---|---|
[79308c8e] | 1 | // |
2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo | |
3 | // | |
4 | // The contents of this file are covered under the licence agreement in the | |
5 | // file "LICENCE" distributed with Cforall. | |
6 | // | |
7 | // maybe -- May contain a value. | |
8 | // | |
9 | // Author : Andrew Beach | |
[58daf53] | 10 | // Created On : Wed May 24 14:43:00 2017 |
[79308c8e] | 11 | // Last Modified By : Andrew Beach |
[20877d2] | 12 | // Last Modified On : Fri Jun 16 15:42:00 2017 |
13 | // Update Count : 2 | |
[79308c8e] | 14 | // |
15 | ||
16 | ||
17 | #ifndef MAYBE_H | |
18 | #define MAYBE_H | |
19 | ||
[64fc0ba] | 20 | #include <stdbool.h> |
[79308c8e] | 21 | |
22 | // DO NOT USE DIRECTLY! | |
23 | forall(otype T) | |
24 | struct maybe { | |
[64fc0ba] | 25 | bool has_value; |
[79308c8e] | 26 | T value; |
27 | }; | |
28 | ||
29 | ||
30 | forall(otype T) | |
31 | void ?{}(maybe(T) * this); | |
32 | ||
33 | forall(otype T) | |
34 | void ?{}(maybe(T) * this, T value); | |
35 | ||
36 | forall(otype T) | |
37 | void ?{}(maybe(T) * this, maybe(T) other); | |
38 | ||
39 | forall(otype T) | |
40 | void ^?{}(maybe(T) * this); | |
41 | ||
[58daf53] | 42 | forall(otype T) |
43 | maybe(T) ?=?(maybe(T) * this, maybe(T) other); | |
44 | ||
[79308c8e] | 45 | forall(otype T) |
[64fc0ba] | 46 | bool ?!=?(maybe(T) this, zero_t); |
[79308c8e] | 47 | |
[20877d2] | 48 | /* Waiting for bug#11 to be fixed. |
[79308c8e] | 49 | forall(otype T) |
50 | maybe(T) maybe_value(T value); | |
51 | ||
52 | forall(otype T) | |
53 | maybe(T) maybe_none(); | |
[20877d2] | 54 | */ |
[79308c8e] | 55 | |
56 | forall(otype T) | |
[64fc0ba] | 57 | bool has_value(maybe(T) * this); |
[79308c8e] | 58 | |
59 | forall(otype T) | |
60 | T get(maybe(T) * this); | |
61 | ||
[58daf53] | 62 | forall(otype T) |
63 | void set(maybe(T) * this, T value); | |
64 | ||
65 | forall(otype T) | |
66 | void set_none(maybe(T) * this); | |
67 | ||
[79308c8e] | 68 | #endif // MAYBE_H |
Note: See TracBrowser
for help on using the repository browser.