//
// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
//
// The contents of this file are covered under the licence agreement in the
// file "LICENCE" distributed with Cforall.
//
// maybe -- May contain a value.
//
// Author           : Andrew Beach
// Created On       : Wed May 24 14:43:00 2017
// Last Modified By : Andrew Beach
// Last Modified On : Fri Jun 16 15:42:00 2017
// Update Count     : 2
//


#ifndef MAYBE_H
#define MAYBE_H

#include <stdbool.h>

// DO NOT USE DIRECTLY!
forall(otype T)
struct maybe {
    bool has_value;
    T value;
};


forall(otype T)
void ?{}(maybe(T) * this);

forall(otype T)
void ?{}(maybe(T) * this, T value);

forall(otype T)
void ?{}(maybe(T) * this, maybe(T) other);

forall(otype T)
void ^?{}(maybe(T) * this);

forall(otype T)
maybe(T) ?=?(maybe(T) * this, maybe(T) other);

forall(otype T)
bool ?!=?(maybe(T) this, zero_t);

/* Waiting for bug#11 to be fixed.
forall(otype T)
maybe(T) maybe_value(T value);

forall(otype T)
maybe(T) maybe_none();
*/

forall(otype T)
bool has_value(maybe(T) * this);

forall(otype T)
T get(maybe(T) * this);

forall(otype T)
void set(maybe(T) * this, T value);

forall(otype T)
void set_none(maybe(T) * this);

#endif // MAYBE_H
