File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -15,30 +15,47 @@ using namespace std;
15
15
template <typename T>
16
16
struct Variable : optional<T>
17
17
{
18
+ /* *
19
+ * @brief bind this variable to the supplied value (making it an unfree variable)
20
+ *
21
+ * @param value
22
+ */
18
23
void bind (const T &value)
19
24
{
20
25
this ->emplace (value);
21
26
}
22
27
28
+ /* *
29
+ * @brief unbinds this variable (making it a free variable)
30
+ *
31
+ */
23
32
void unbind ()
24
33
{
25
34
this ->reset ();
26
35
}
27
36
37
+ /* *
38
+ * @brief checks whether this variable is free or bound
39
+ *
40
+ * @return true if bound to a value
41
+ * @return false if free
42
+ */
28
43
bool isBound () const
29
44
{
30
45
return this ->has_value ();
31
46
}
32
47
33
- const T &
34
- value () const
48
+ /* *
49
+ * @brief returns the bound value (if not bound then throws an exception)
50
+ *
51
+ * @return const T&
52
+ */
53
+ const T &value () const
35
54
{
36
55
return this ->optional <T>::value ();
37
56
}
38
57
};
39
58
40
- // TODO: use auto more for return type of functions
41
-
42
59
template <typename T>
43
60
Variable<T> *var ()
44
61
{
You can’t perform that action at this time.
0 commit comments