source: src/libcfa/containers/maybe @ b2551ce

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 b2551ce 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.2 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// maybe -- May contain a value.
8//
9// Author           : Andrew Beach
10// Created On       : Wed May 24 14:43:00 2017
11// Last Modified By : Andrew Beach
12// Last Modified On : Fri Jun 16 15:42:00 2017
13// Update Count     : 2
14//
15
16
17#ifndef MAYBE_H
18#define MAYBE_H
19
20#include <stdbool.h>
21
22// DO NOT USE DIRECTLY!
23forall(otype T)
24struct maybe {
25    bool has_value;
26    T value;
27};
28
29
30forall(otype T)
31void ?{}(maybe(T) * this);
32
33forall(otype T)
34void ?{}(maybe(T) * this, T value);
35
36forall(otype T)
37void ?{}(maybe(T) * this, maybe(T) other);
38
39forall(otype T)
40void ^?{}(maybe(T) * this);
41
42forall(otype T)
43maybe(T) ?=?(maybe(T) * this, maybe(T) other);
44
45forall(otype T)
46bool ?!=?(maybe(T) this, zero_t);
47
48/* Waiting for bug#11 to be fixed.
49forall(otype T)
50maybe(T) maybe_value(T value);
51
52forall(otype T)
53maybe(T) maybe_none();
54*/
55
56forall(otype T)
57bool has_value(maybe(T) * this);
58
59forall(otype T)
60T get(maybe(T) * this);
61
62forall(otype T)
63void set(maybe(T) * this, T value);
64
65forall(otype T)
66void set_none(maybe(T) * this);
67
68#endif // MAYBE_H
Note: See TracBrowser for help on using the repository browser.