//
// 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.
//
// result -- Contains the expected value or an error value.
//
// Author           : Andrew Beach
// Created On       : Wed May 24 14:45:00 2017
// Last Modified By : Peter A. Buhr
// Last Modified On : Sat Jul 22 10:00:44 2017
// Update Count     : 3
//

#pragma once

#include <stdbool.h>

// DO NOT USE DIRECTLY!
forall(otype T, otype E)
union inner_result{
	T value;
	E error;
};

forall(otype T, otype E)
struct result {
	bool has_value;
	inline union inner_result(T, E);
};


forall(otype T, otype E)
void ?{}(result(T, E) & this);

forall(otype T, otype E)
void ?{}(result(T, E) & this, one_t, T value);

forall(otype T, otype E)
void ?{}(result(T, E) & this, zero_t, E error);

forall(otype T, otype E)
void ?{}(result(T, E) & this, result(T, E) other);

forall(otype T, otype E)
void ^?{}(result(T, E) & this);

forall(otype T, otype E)
result(T, E) ?=?(result(T, E) & this, result(T, E) other);

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

/* Wating for bug#11 to be fixed.
forall(otype T, otype E)
result(T, E) result_value(T value);

forall(otype T, otype E)
result(T, E) result_error(E error);
*/

forall(otype T, otype E)
bool has_value(result(T, E) * this);

forall(otype T, otype E)
T get(result(T, E) * this);

forall(otype T, otype E)
E get_error(result(T, E) * this);

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

forall(otype T, otype E)
void set_error(result(T, E) * this, E error);

// Local Variables: //
// mode: c //
// tab-width: 4 //
// End: //
