From 1247d7aea8b9be73e22c100817abcb4edc3de97d Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Sat, 16 May 2015 04:37:26 +0100 Subject: [PATCH] Pretty syntax --- lib/math/Grid_math_trace.h | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/lib/math/Grid_math_trace.h b/lib/math/Grid_math_trace.h index db8202e6..f6778496 100644 --- a/lib/math/Grid_math_trace.h +++ b/lib/math/Grid_math_trace.h @@ -35,39 +35,22 @@ inline auto trace(const iScalar &arg) -> iScalar inline -auto traceIndex(const iScalar &arg) -> iScalar(arg._internal)) > -{ - iScalar(arg._internal))> ret; - ret._internal = traceIndex(arg._internal); - return ret; -} -*/ -template inline auto -traceIndex (const iScalar &arg) -> -typename -std::enable_if,Level>::notvalue, - iScalar(arg._internal))> >::type - +template::TensorLevel != Level >::type * =nullptr> inline auto +traceIndex (const iScalar &arg) -> iScalar(arg._internal))> { iScalar(arg._internal))> ret; ret._internal=traceIndex(arg._internal); return ret; } -template inline auto -traceIndex (const iScalar &arg) -> -typename std::enable_if,Level>::value, - iScalar >::type +template::TensorLevel == Level >::type * =nullptr> inline auto +traceIndex (const iScalar &arg) -> iScalar { return arg; } // If we hit the right index, return scalar and trace it with no further recursion -template inline -auto traceIndex(const iMatrix &arg) -> - typename std::enable_if,Level>::value, // Index matches - iScalar >::type // return scalar +template::TensorLevel == Level >::type * =nullptr> inline +auto traceIndex(const iMatrix &arg) -> iScalar { iScalar ret; zeroit(ret._internal); @@ -78,10 +61,8 @@ auto traceIndex(const iMatrix &arg) -> } // not this level, so recurse -template inline -auto traceIndex(const iMatrix &arg) -> - typename std::enable_if,Level>::notvalue,// No index match - iMatrix(arg._internal[0][0])),N> >::type // return matrix +template::TensorLevel != Level >::type * =nullptr> inline +auto traceIndex(const iMatrix &arg) -> iMatrix(arg._internal[0][0])),N> { iMatrix(arg._internal[0][0])),N> ret; for(int i=0;i