// // 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 25 14:45:00 2017 // Last Modified By : Andrew Beach // Last Modified On : Wed May 25 16:57:00 2017 // Update Count : 1 // #ifndef RESULT_H #define RESULT_H #include // 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; 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) bool ?!=?(result(T, E) this, zero_t); 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); #endif // RESULT_H