From 8f94517aa42779458fbd642954d17a0a4e37566b Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Fri, 18 May 2018 20:23:21 +0200 Subject: [PATCH] fix typos and formal stuff -> tests work again --- src/include/mbase_def.h | 6 ++-- src/include/multi_array_operation.h | 49 ++++++++++------------------- src/include/type_operations.h | 14 ++++++--- 3 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/include/mbase_def.h b/src/include/mbase_def.h index 6d569c5..c0abd6b 100644 --- a/src/include/mbase_def.h +++ b/src/include/mbase_def.h @@ -21,12 +21,12 @@ namespace MultiArrayTools class MultiArray; // multi_array_operation.h - template + template class OperationBase; // multi_array_operation.h - template - class MutableOperationBase; + //template + //class MutableOperationBase; // multi_array_operation.h template diff --git a/src/include/multi_array_operation.h b/src/include/multi_array_operation.h index d8819fa..c6497f5 100644 --- a/src/include/multi_array_operation.h +++ b/src/include/multi_array_operation.h @@ -55,14 +55,20 @@ namespace MultiArrayTools private: friend OperationClass; - OperationTemplate() = default; + friend OperationTemplate; + OperationBase() = default; }; template class OperationTemplate : public OperationBase - { /* empty per default; specialize if needed */ }; + { + /* empty per default; specialize if needed */ + private: + OperationTemplate() = default; + friend OperationClass; + }; + -#include "type_operations.h" template class OperationMaster @@ -96,7 +102,7 @@ namespace MultiArrayTools }; typedef T value_type; - typedef OperationBase OB; + //typedef OperationBase OB; typedef ContainerRange CRange; typedef ContainerIndex IndexType; //typedef typename MultiRange::IndexType IndexType; @@ -301,29 +307,6 @@ namespace MultiArrayTools auto loop(Expr exp) const -> decltype(mInd->iforh(exp)); }; - template - struct operate - { - static inline OperationRoot - apply(const MultiArrayBase& ma, - const std::shared_ptr&... indices) - { - return OperationRoot(ma, indices...); - } - }; - - // interchange inheritance - // try to implement the 'promote' version - template - class TypeSpecificOperationSet,OperationClass> - { - auto operator()() const - -> Operation,operate,OperationClass> - { - return Operation,operate,OperationClass> - (/*THIS*/); - } - }; } /* ========================= * @@ -343,7 +326,7 @@ namespace MultiArrayTools template template - auto OperationTemplate::operator+(const Second& in) const + auto OperationBase::operator+(const Second& in) const -> Operation,OperationClass,Second> { return Operation,OperationClass,Second>(THIS(), in); @@ -351,7 +334,7 @@ namespace MultiArrayTools template template - auto OperationTemplate::operator-(const Second& in) const + auto OperationBase::operator-(const Second& in) const -> Operation,OperationClass,Second> { return Operation,OperationClass,Second>(THIS(), in); @@ -359,7 +342,7 @@ namespace MultiArrayTools template template - auto OperationTemplate::operator*(const Second& in) const + auto OperationBase::operator*(const Second& in) const -> Operation,OperationClass,Second> { return Operation,OperationClass,Second>(THIS(), in); @@ -367,7 +350,7 @@ namespace MultiArrayTools template template - auto OperationTemplate::operator/(const Second& in) const + auto OperationBase::operator/(const Second& in) const -> Operation,OperationClass,Second> { return Operation,OperationClass,Second>(THIS(), in); @@ -375,7 +358,7 @@ namespace MultiArrayTools template template - auto OperationTemplate::c(std::shared_ptr& ind) const + auto OperationBase::c(std::shared_ptr& ind) const -> Contraction { return Contraction(THIS(), ind); @@ -620,4 +603,6 @@ namespace MultiArrayTools } +#include "type_operations.h" + #endif diff --git a/src/include/type_operations.h b/src/include/type_operations.h index 7889368..3491378 100644 --- a/src/include/type_operations.h +++ b/src/include/type_operations.h @@ -34,20 +34,24 @@ namespace MultiArrayTools // this is, why non-static std::tuple...> ituple; - } + }; template - class OperationTemplate : public OperationBase,OperationClass> + class OperationTemplate,OperationClass> : public OperationBase,OperationClass> { typedef OperationBase,OperationClass> OB; auto operator()(const std::shared_ptr&... indices) - -> Operation,operate,OperationClass> + -> Operation,operate,OperationClass> { - std::shared_ptr ff(indices...); - return Operation(ff, OB::THIS()); + std::shared_ptr > ff(indices...); + return Operation,operate,OperationClass>(ff, OB::THIS()); } + private: + OperationTemplate() = default; + friend OperationClass; + };