Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/containers/maybe.c

    raca65621 r58daf53  
    1919
    2020forall(otype T)
    21 void ?{}(maybe(T) & this) {
    22         this.has_value = false;
     21void ?{}(maybe(T) * this) {
     22        this->has_value = false;
    2323}
    2424
    2525forall(otype T)
    26 void ?{}(maybe(T) & this, T value) {
    27         this.has_value = true;
    28         (this.value){value};
     26void ?{}(maybe(T) * this, T value) {
     27        this->has_value = true;
     28        (&this->value){value};
    2929}
    3030
    3131forall(otype T)
    32 void ?{}(maybe(T) & this, maybe(T) other) {
    33         this.has_value = other.has_value;
     32void ?{}(maybe(T) * this, maybe(T) other) {
     33        this->has_value = other.has_value;
    3434        if (other.has_value) {
    35                 (this.value){other.value};
     35                (&this->value){other.value};
    3636        }
    3737}
    3838
    3939forall(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;
     40maybe(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;
    4646        } 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};
    4949        }
    50         return this;
    5150}
    5251
    5352forall(otype T)
    54 void ^?{}(maybe(T) & this) {
    55         if (this.has_value) {
    56                 ^(this.value){};
     53void ^?{}(maybe(T) * this) {
     54        if (this->has_value) {
     55                ^(&this->value){};
    5756        }
    5857}
     
    9089        } else {
    9190                this->has_value = true;
    92                 (this->value){value};
     91                (&this->value){value};
    9392        }
    9493}
     
    9897        if (this->has_value) {
    9998                this->has_value = false;
    100                 ^(this->value){};
     99                ^(&this->value){};
    101100        }
    102101}
Note: See TracChangeset for help on using the changeset viewer.