From a1a6b02bb5d3c50c690fedcd9aa6e6adc747d9a4 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 13 Mar 2019 19:17:22 +0100 Subject: [PATCH] add some utilities --- src/include/helper_tools.cc.h | 22 ++++++++++++++++++++++ src/include/helper_tools.h | 12 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/include/helper_tools.cc.h b/src/include/helper_tools.cc.h index 7a50193..0037d75 100644 --- a/src/include/helper_tools.cc.h +++ b/src/include/helper_tools.cc.h @@ -120,6 +120,14 @@ namespace MultiArrayTools return std::dynamic_pointer_cast( rbptr ); } + template + auto createRangeE(const Args&... args) + -> std::shared_ptr + { + typename Range::Factory f(args...); + return createExplicit(f); + } + template auto rptr(const MArray& ma) -> decltype(ma.template getRangePtr()) @@ -228,5 +236,19 @@ namespace MultiArrayTools return ConstSlice( ro, &r->get(0) ); } + template + auto mkArray(const std::shared_ptr&... rs) + -> MultiArray + { + return MultiArray(rs...); + } + + template + auto mkArray(const std::shared_ptr&... rs, const T& val) + -> MultiArray + { + return MultiArray(rs..., val); + } + } diff --git a/src/include/helper_tools.h b/src/include/helper_tools.h index 895baee..17bee87 100644 --- a/src/include/helper_tools.h +++ b/src/include/helper_tools.h @@ -64,6 +64,10 @@ namespace MultiArrayTools auto createRange(const vector& cvec) -> std::shared_ptr; + template + auto createRangeE(const Args&... args) + -> std::shared_ptr; + template auto rptr(const MArray& ma) -> decltype(ma.template getRangePtr()); @@ -103,6 +107,14 @@ namespace MultiArrayTools auto metaSlice(const std::shared_ptr& r, const std::shared_ptr& ro) -> ConstSlice; + template + auto mkArray(const std::shared_ptr&... rs) + -> MultiArray; + + template + auto mkArray(const std::shared_ptr&... rs, const T& val) + -> MultiArray; + template inline void For(const std::shared_ptr& ind, const std::function& ll) {