aboutsummaryrefslogtreecommitdiff
path: root/c/pl.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/pl.h')
-rw-r--r--c/pl.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/c/pl.h b/c/pl.h
index 1448361..8325c86 100644
--- a/c/pl.h
+++ b/c/pl.h
@@ -67,20 +67,17 @@ inline int PlGet(term_t t, atom_t* x) { return PL_get_atom(t, x); }
inline int PlGet(term_t t, char** x) { return PL_get_atom_chars(t, x); }
inline int PlGet(term_t t, wchar_t** x) { size_t len; return PL_get_wchars(t, &len, x, CVT_ATOM); }
-/* Helper templates for Plx, Pl. */
+/* Put in or get from a term reference an arbitrary number of values,
+ * returning false if any value could not be put/got. */
template <typename = void>
-inline int PlPutN(term_t) { return -1; }
-template <typename T>
-inline int PlPutN(term_t t, T arg) { return PlPut(t, arg); }
+inline bool PlPutN(term_t) { return true; }
template <typename T, typename... U>
-inline int PlPutN(term_t t, T arg, U... xs) { return PlPut(t, arg) && PlPutN(t+1, xs...); }
+inline bool PlPutN(term_t t, T x, U... xs) { return PlPut(t, x) && PlPutN(t+1, xs...); }
template <typename = void>
-inline int PlGetN(term_t) { return -1; }
-template <typename T>
-inline int PlGetN(term_t t, T arg) { return PlGet(t, arg); }
+inline bool PlGetN(term_t) { return true; }
template <typename T, typename... U>
-inline int PlGetN(term_t t, T arg, U... xs) { return PlGet(t, arg) && PlGetN(t+1, xs...); }
+inline bool PlGetN(term_t t, T x, U... xs) { return PlGet(t, x) && PlGetN(t+1, xs...); }
/* Call Prolog predicate, propagating Prolog exceptions. */
template <typename... T>