source: src/libcfa/containers/result @ f32e53e

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since f32e53e was 20877d2, checked in by Andrew Beach <ajbeach@…>, 7 years ago

I've been sitting on these tests for a while. New tests for maybe/result. Passing on my machine.

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[79308c8e]1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// result -- Contains the expected value or an error value.
8//
9// Author           : Andrew Beach
[58daf53]10// Created On       : Wed May 24 14:45:00 2017
[79308c8e]11// Last Modified By : Andrew Beach
[20877d2]12// Last Modified On : Fri Jun 16 15:41:00 2017
13// Update Count     : 2
[79308c8e]14//
15
16
17#ifndef RESULT_H
18#define RESULT_H
19
[64fc0ba]20#include <stdbool.h>
[79308c8e]21
22// DO NOT USE DIRECTLY!
[64fc0ba]23forall(otype T, otype E)
24union inner_result{
25        T value;
26        E error;
27};
28
[79308c8e]29forall(otype T, otype E)
30struct result {
[64fc0ba]31        bool has_value;
32        inner_result(T, E);
[79308c8e]33};
34
35
36forall(otype T, otype E)
37void ?{}(result(T, E) * this);
38
39forall(otype T, otype E)
40void ?{}(result(T, E) * this, one_t, T value);
41
42forall(otype T, otype E)
43void ?{}(result(T, E) * this, zero_t, E error);
44
45forall(otype T, otype E)
46void ?{}(result(T, E) * this, result(T, E) other);
47
48forall(otype T, otype E)
49void ^?{}(result(T, E) * this);
50
[58daf53]51forall(otype T, otype E)
52result(T, E) ?=?(result(T, E) * this, result(T, E) other);
53
[79308c8e]54forall(otype T, otype E)
[64fc0ba]55bool ?!=?(result(T, E) this, zero_t);
[79308c8e]56
[20877d2]57/* Wating for bug#11 to be fixed.
[79308c8e]58forall(otype T, otype E)
59result(T, E) result_value(T value);
60
61forall(otype T, otype E)
62result(T, E) result_error(E error);
[20877d2]63*/
[79308c8e]64
65forall(otype T, otype E)
[64fc0ba]66bool has_value(result(T, E) * this);
[79308c8e]67
68forall(otype T, otype E)
69T get(result(T, E) * this);
70
71forall(otype T, otype E)
72E get_error(result(T, E) * this);
73
[58daf53]74forall(otype T, otype E)
75void set(result(T, E) * this, T value);
76
77forall(otype T, otype E)
78void set_error(result(T, E) * this, E error);
79
[79308c8e]80#endif // RESULT_H
Note: See TracBrowser for help on using the repository browser.