source:
libcfa/src/containers/maybe.hfa
@
e4d7c1c
Last change on this file since e4d7c1c was fd54fef, checked in by , 4 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 |
[6b0b624] | 11 | // Last Modified By : Peter A. Buhr |
12 | // Last Modified On : Sat Jul 22 10:00:52 2017 | |
13 | // Update Count : 4 | |
[79308c8e] | 14 | // |
15 | ||
[6b0b624] | 16 | #pragma once |
[79308c8e] | 17 | |
[64fc0ba] | 18 | #include <stdbool.h> |
[79308c8e] | 19 | |
20 | // DO NOT USE DIRECTLY! | |
[fd54fef] | 21 | forall(T) |
[79308c8e] | 22 | struct maybe { |
[64fc0ba] | 23 | bool has_value; |
[79308c8e] | 24 | T value; |
25 | }; | |
26 | ||
27 | ||
[fd54fef] | 28 | forall(T) |
[aca65621] | 29 | void ?{}(maybe(T) & this); |
[79308c8e] | 30 | |
[fd54fef] | 31 | forall(T) |
[aca65621] | 32 | void ?{}(maybe(T) & this, T value); |
[79308c8e] | 33 | |
[fd54fef] | 34 | forall(T) |
[aca65621] | 35 | void ?{}(maybe(T) & this, maybe(T) other); |
[79308c8e] | 36 | |
[fd54fef] | 37 | forall(T) |
[aca65621] | 38 | void ^?{}(maybe(T) & this); |
[79308c8e] | 39 | |
[fd54fef] | 40 | forall(T) |
[aca65621] | 41 | maybe(T) ?=?(maybe(T) & this, maybe(T) other); |
[58daf53] | 42 | |
[fd54fef] | 43 | forall(T) |
[64fc0ba] | 44 | bool ?!=?(maybe(T) this, zero_t); |
[79308c8e] | 45 | |
[20877d2] | 46 | /* Waiting for bug#11 to be fixed. |
[fd54fef] | 47 | forall(T) |
[79308c8e] | 48 | maybe(T) maybe_value(T value); |
49 | ||
[fd54fef] | 50 | forall(T) |
[79308c8e] | 51 | maybe(T) maybe_none(); |
[20877d2] | 52 | */ |
[79308c8e] | 53 | |
[fd54fef] | 54 | forall(T) |
[64fc0ba] | 55 | bool has_value(maybe(T) * this); |
[79308c8e] | 56 | |
[fd54fef] | 57 | forall(T) |
[79308c8e] | 58 | T get(maybe(T) * this); |
59 | ||
[fd54fef] | 60 | forall(T) |
[58daf53] | 61 | void set(maybe(T) * this, T value); |
62 | ||
[fd54fef] | 63 | forall(T) |
[58daf53] | 64 | void set_none(maybe(T) * this); |
65 | ||
[6b0b624] | 66 | // Local Variables: // |
67 | // mode: c // | |
68 | // tab-width: 4 // | |
69 | // End: // |
Note: See TracBrowser
for help on using the repository browser.