From 2ed60bbc017282abacd8d8db8c01e8d1b7cf8d24 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 21 Apr 2020 12:10:26 +0200 Subject: [PATCH] STYLE: generalize transform/invTransform no-op for base types --- src/OpenFOAM/primitives/transform/transform.H | 61 ++++--------------- 1 file changed, 12 insertions(+), 49 deletions(-) diff --git a/src/OpenFOAM/primitives/transform/transform.H b/src/OpenFOAM/primitives/transform/transform.H index d34a041e44a..3030697ad60 100644 --- a/src/OpenFOAM/primitives/transform/transform.H +++ b/src/OpenFOAM/primitives/transform/transform.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,6 +37,7 @@ Description #include "tensor.H" #include "mathematicalConstants.H" +#include <type_traits> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -144,59 +146,20 @@ inline tensor Ra(const vector& a, const scalar omega) } -//- No-op rotational transform of a bool -inline bool transform(const tensor&, const bool b) +//- No-op rotational transform for base types +template<class T> +constexpr typename std::enable_if<std::is_arithmetic<T>::value, T>::type +transform(const tensor&, const T val) { - return b; + return val; } - -//- No-op inverse rotational transform of a bool -inline bool invTransform(const tensor&, const bool b) -{ - return b; -} - - -//- No-op rotational transform of a label -inline label transform(const tensor&, const label i) -{ - return i; -} - - -//- No-op inverse rotational transform of a label -inline label invTransform(const tensor&, const label i) -{ - return i; -} - - -//- No-op rotational transform of an unsigned integer -inline unsigned int transform(const tensor&, const unsigned int i) -{ - return i; -} - - -//- No-op inverse rotational transform of an unsigned integer -inline unsigned int invTransform(const tensor&, const unsigned int i) -{ - return i; -} - - -//- No-op rotational transform of a scalar -inline scalar transform(const tensor&, const scalar s) -{ - return s; -} - - -//- No-op inverse rotational transform of a scalar -inline scalar invTransform(const tensor&, const scalar s) +//- No-op inverse rotational transform for base types +template<class T> +constexpr typename std::enable_if<std::is_arithmetic<T>::value, T>::type +invTransform(const tensor&, const T val) { - return s; + return val; } -- GitLab