summaryrefslogtreecommitdiff
path: root/gruel/src/lib/pmt/unv_template.cc.t
diff options
context:
space:
mode:
Diffstat (limited to 'gruel/src/lib/pmt/unv_template.cc.t')
-rw-r--r--gruel/src/lib/pmt/unv_template.cc.t19
1 files changed, 19 insertions, 0 deletions
diff --git a/gruel/src/lib/pmt/unv_template.cc.t b/gruel/src/lib/pmt/unv_template.cc.t
index 566168c3d..1ed505e29 100644
--- a/gruel/src/lib/pmt/unv_template.cc.t
+++ b/gruel/src/lib/pmt/unv_template.cc.t
@@ -87,6 +87,13 @@ pmt_init_@TAG@vector(size_t k, const @TYPE@ *data)
return pmt_t(new pmt_@TAG@vector(k, data));
}
+pmt_t
+pmt_init_@TAG@vector(size_t k, const std::vector< @TYPE@ > &data)
+{
+
+ return pmt_t(new pmt_@TAG@vector(k, &data[0]));
+}
+
@TYPE@
pmt_@TAG@vector_ref(pmt_t vector, size_t k)
{
@@ -111,6 +118,18 @@ pmt_@TAG@vector_elements(pmt_t vector, size_t &len)
return _@TAG@vector(vector)->elements(len);
}
+const std::vector< @TYPE@ >
+pmt_@TAG@vector_elements(pmt_t vector)
+{
+ if (!vector->is_@TAG@vector())
+ throw pmt_wrong_type("pmt_@TAG@vector_elements", vector);
+ size_t len;
+ const @TYPE@ *array = _@TAG@vector(vector)->elements(len);
+ const std::vector< @TYPE@ > vec(array, array+len);
+ return vec;
+}
+
+
@TYPE@ *
pmt_@TAG@vector_writable_elements(pmt_t vector, size_t &len)
{