source: src/libcfa/containers/result @ 79308c8e

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 79308c8e was 79308c8e, checked in by Andrew Beach <ajbeach@…>, 4 years ago

First draft of maybe and result.

  • Property mode set to 100644
File size: 1.3 KB
Line 
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
10// Created On       : Wed May 25 14:45:00 2017
11// Last Modified By : Andrew Beach
12// Last Modified On : Wed May 25 16:57:00 2017
13// Update Count     : 1
14//
15
16
17#ifndef RESULT_H
18#define RESULT_H
19
20
21// DO NOT USE DIRECTLY!
22forall(otype T, otype E)
23struct result {
24        _Bool has_value;
25        union {
26                T value;
27                E error;
28        };
29};
30
31
32forall(otype T, otype E)
33void ?{}(result(T, E) * this);
34
35forall(otype T, otype E)
36void ?{}(result(T, E) * this, one_t, T value);
37
38forall(otype T, otype E)
39void ?{}(result(T, E) * this, zero_t, E error);
40
41forall(otype T, otype E)
42void ?{}(result(T, E) * this, result(T, E) other);
43
44forall(otype T, otype E)
45void ^?{}(result(T, E) * this);
46
47forall(otype T, otype E)
48_Bool ?!=?(result(T, E) this, zero_t);
49
50forall(otype T, otype E)
51result(T, E) result_value(T value);
52
53forall(otype T, otype E)
54result(T, E) result_error(E error);
55
56forall(otype T, otype E)
57_Bool has_value(result(T, E) * this);
58
59forall(otype T, otype E)
60T get(result(T, E) * this);
61
62forall(otype T, otype E)
63E get_error(result(T, E) * this);
64
65#endif // RESULT_H
Note: See TracBrowser for help on using the repository browser.