Changeset aca65621 for src/libcfa/containers/maybe.c
- Timestamp:
- Jul 12, 2017, 4:40:02 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 0698aa1
- Parents:
- 469f709
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/containers/maybe.c
r469f709 raca65621 19 19 20 20 forall(otype T) 21 void ?{}(maybe(T) *this) {22 this ->has_value = false;21 void ?{}(maybe(T) & this) { 22 this.has_value = false; 23 23 } 24 24 25 25 forall(otype T) 26 void ?{}(maybe(T) *this, T value) {27 this ->has_value = true;28 ( &this->value){value};26 void ?{}(maybe(T) & this, T value) { 27 this.has_value = true; 28 (this.value){value}; 29 29 } 30 30 31 31 forall(otype T) 32 void ?{}(maybe(T) *this, maybe(T) other) {33 this ->has_value = other.has_value;32 void ?{}(maybe(T) & this, maybe(T) other) { 33 this.has_value = other.has_value; 34 34 if (other.has_value) { 35 ( &this->value){other.value};35 (this.value){other.value}; 36 36 } 37 37 } 38 38 39 39 forall(otype T) 40 maybe(T) ?=?(maybe(T) *this, maybe(T) that) {41 if (this ->has_value & that.has_value) {42 this ->value = that.value;43 } else if (this ->has_value) {44 ^( &this->value){};45 this ->has_value = false;40 maybe(T) ?=?(maybe(T) & this, maybe(T) that) { 41 if (this.has_value & that.has_value) { 42 this.value = that.value; 43 } else if (this.has_value) { 44 ^(this.value){}; 45 this.has_value = false; 46 46 } else if (that.has_value) { 47 this ->has_value = true;48 ( &this->value){that.value};47 this.has_value = true; 48 (this.value){that.value}; 49 49 } 50 return this; 50 51 } 51 52 52 53 forall(otype T) 53 void ^?{}(maybe(T) *this) {54 if (this ->has_value) {55 ^( &this->value){};54 void ^?{}(maybe(T) & this) { 55 if (this.has_value) { 56 ^(this.value){}; 56 57 } 57 58 } … … 89 90 } else { 90 91 this->has_value = true; 91 ( &this->value){value};92 (this->value){value}; 92 93 } 93 94 } … … 97 98 if (this->has_value) { 98 99 this->has_value = false; 99 ^( &this->value){};100 ^(this->value){}; 100 101 } 101 102 }
Note: See TracChangeset
for help on using the changeset viewer.