File tree Expand file tree Collapse file tree 4 files changed +67
-17
lines changed
Expand file tree Collapse file tree 4 files changed +67
-17
lines changed Original file line number Diff line number Diff line change 1212#include < tuple>
1313
1414#include " tuple_hash.h"
15- #include " Variable.h"
15+ #include " variable.h"
16+ #include " tuple_binding.h"
1617
1718namespace datalog
1819{
1920
2021using namespace std ;
2122
23+ /* *
24+ * @brief create a new variable
25+ *
26+ * @tparam T
27+ * @return Variable<T>*
28+ */
2229template <typename T>
2330Variable<T> *var ()
2431{
2532 return new Variable<T>();
2633}
2734
35+ /* *
36+ * @brief get the value of a variable
37+ *
38+ * @tparam T
39+ * @param t
40+ * @return T
41+ */
2842template <typename T>
2943T val (Variable<T> *t)
3044{
3145 return t->value ();
3246}
3347
48+ /* *
49+ * @brief delete a variable
50+ *
51+ * @tparam T
52+ * @param v
53+ */
3454template <typename T>
3555void deleteVar (Variable<T> *v)
3656{
3757 delete v;
3858}
3959
40- template <typename T>
41- void unbind (Variable<T> *t)
42- {
43- t->unbind ();
44- }
45-
46- template <typename T>
47- void unbind (const T &t) {}
48-
49- template <typename ... Ts>
50- void unbind (const tuple<Ts...> &tuple)
51- {
52- apply ([](auto &&... args) { ((unbind (args), ...)); }, tuple);
53- }
54-
5560template <typename T>
5661bool bind (const T &a, const T &b)
5762{
Original file line number Diff line number Diff line change 1+ #ifndef TUPLES_H
2+ #define TUPLES_H
3+
4+ #include " variable.h"
5+
6+ namespace datalog {
7+
8+ /* *
9+ * @brief unbind a variable
10+ *
11+ * @tparam T
12+ * @param t
13+ */
14+ template <typename T>
15+ void unbind (Variable<T> *t)
16+ {
17+ t->unbind ();
18+ }
19+
20+ /* *
21+ * @brief unbind no-operation for types that are not variables
22+ *
23+ * @tparam T
24+ * @param t
25+ */
26+ template <typename T>
27+ void unbind (const T &t) {
28+ // If t is not a Variable then perform no-op
29+ }
30+
31+ /* *
32+ * @brief apply unbind to a tuple of variables and values
33+ *
34+ * @tparam Ts
35+ * @param tuple
36+ */
37+ template <typename ... Ts>
38+ void unbind (const tuple<Ts...> &tuple)
39+ {
40+ apply ([](auto &&... args) { ((unbind (args), ...)); }, tuple);
41+ }
42+
43+ }
44+
45+ #endif // TUPLES_H
File renamed without changes.
Original file line number Diff line number Diff line change 11#include " catch.hpp"
2- #include " Variable .h"
2+ #include " variable .h"
33
44using namespace datalog ;
55
You can’t perform that action at this time.
0 commit comments