From f424f583fefe4d14f2364c98cd9927d70491e4f6 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Thu, 7 Jan 2021 10:33:24 +0100
Subject: [PATCH] Use helper classes as is_same_v and the like.

is_same_v<> for is_same<>::value
decay_t<> for decay<>::type
is_integral_v<> for is_integral<>::value
invoke_result_t<> for invoke_result<>::type
---
 Applications/FileIO/CsvInterface.h            |  4 ++--
 MathLib/LinAlg/GlobalMatrixVectorTypes.h      |  7 +++---
 MathLib/Nonlinear/Root1D.h                    |  7 +++---
 MathLib/ODE/CVodeSolver.cpp                   |  2 +-
 .../ExtrapolatableElementCollection.h         |  4 ++--
 .../GenericNaturalBoundaryCondition-impl.h    |  4 ++--
 ProcessLib/Output/SecondaryVariable.h         | 18 +++++++--------
 ProcessLib/TES/TESLocalAssembler.h            | 11 ++++------
 Tests/MathLib/TestNonlinear1D.cpp             |  7 ++++--
 Tests/NumLib/TestODEInt.cpp                   |  2 +-
 Tests/NumLib/TestShapeFunctions.cpp           | 22 +++++++++----------
 11 files changed, 43 insertions(+), 45 deletions(-)

diff --git a/Applications/FileIO/CsvInterface.h b/Applications/FileIO/CsvInterface.h
index 265a83d2224..3a27c978f89 100644
--- a/Applications/FileIO/CsvInterface.h
+++ b/Applications/FileIO/CsvInterface.h
@@ -67,8 +67,8 @@ public:
                              std::vector<T> const& vec)
     {
         static_assert(
-            std::is_same<T, std::string>::value ||
-                std::is_same<T, double>::value || std::is_same<T, int>::value,
+            std::is_same_v<T, std::string> || std::is_same_v<T, double> ||
+                std::is_same_v<T, int>,
             "CsvInterface can only write vectors of strings, doubles or ints.");
 
         if (!_data.empty())
diff --git a/MathLib/LinAlg/GlobalMatrixVectorTypes.h b/MathLib/LinAlg/GlobalMatrixVectorTypes.h
index afd1b5c1381..dada4abe463 100644
--- a/MathLib/LinAlg/GlobalMatrixVectorTypes.h
+++ b/MathLib/LinAlg/GlobalMatrixVectorTypes.h
@@ -51,12 +51,11 @@
 
 /// A type used for indexing of global vectors and matrices. It is equal to the
 /// GlobalMatrix::IndexType and the GlobalVector::IndexType.
-static_assert(std::is_integral<GlobalMatrix::IndexType>::value,
+static_assert(std::is_integral_v<GlobalMatrix::IndexType>,
               "The index type for global matrices is not an integral type.");
-static_assert(std::is_integral<GlobalVector::IndexType>::value,
+static_assert(std::is_integral_v<GlobalVector::IndexType>,
               "The index type for global vectors is not an integral type.");
-static_assert(std::is_same<GlobalMatrix::IndexType,
-                           GlobalVector::IndexType>::value,
+static_assert(std::is_same_v<GlobalMatrix::IndexType, GlobalVector::IndexType>,
               "The global matrix and vector index types do not match.");
 // Both types are integral types and equal, define a single GlobalIndexType.
 using GlobalIndexType = GlobalMatrix::IndexType;
diff --git a/MathLib/Nonlinear/Root1D.h b/MathLib/Nonlinear/Root1D.h
index 9deb624af9c..10e81e5fcbe 100644
--- a/MathLib/Nonlinear/Root1D.h
+++ b/MathLib/Nonlinear/Root1D.h
@@ -51,10 +51,9 @@ public:
     RegulaFalsi(Function const& f, double a, double b)
         : _f(f), _a(a), _b(b), _fa(f(a)), _fb(f(b))
     {
-        static_assert(
-                std::is_same<double, decltype(f(0.0))>::value,
-                "Using this class for functions that do not return double"
-                " involves a lot of casts. Hence it is disabled.");
+        static_assert(std::is_same_v<double, decltype(f(0.0))>,
+                      "Using this class for functions that do not return double"
+                      " involves a lot of casts. Hence it is disabled.");
 
         if (detail::almost_zero(_fa)) {
             _b = _a;
diff --git a/MathLib/ODE/CVodeSolver.cpp b/MathLib/ODE/CVodeSolver.cpp
index e44636730d5..0b9d3c66ec7 100644
--- a/MathLib/ODE/CVodeSolver.cpp
+++ b/MathLib/ODE/CVodeSolver.cpp
@@ -83,7 +83,7 @@ namespace ODE
  */
 class CVodeSolverImpl final
 {
-    static_assert(std::is_same<realtype, double>::value,
+    static_assert(std::is_same_v<realtype, double>,
                   "CVode's realtype is not the same as double");
 
 public:
diff --git a/NumLib/Extrapolation/ExtrapolatableElementCollection.h b/NumLib/Extrapolation/ExtrapolatableElementCollection.h
index fce0d10a8d5..ec14a203c22 100644
--- a/NumLib/Extrapolation/ExtrapolatableElementCollection.h
+++ b/NumLib/Extrapolation/ExtrapolatableElementCollection.h
@@ -80,8 +80,8 @@ class ExtrapolatableLocalAssemblerCollection
 public:
     //! LocalAssemblerCollection contains many LocalAssembler's.
     using LocalAssembler =
-        typename std::decay<decltype(*std::declval<LocalAssemblerCollection>()
-                                         [static_cast<std::size_t>(0)])>::type;
+        typename std::decay_t<decltype(*std::declval<LocalAssemblerCollection>()
+                                           [static_cast<std::size_t>(0)])>;
 
     static_assert(std::is_base_of<ExtrapolatableElement, LocalAssembler>::value,
                   "Local assemblers used for extrapolation must be derived "
diff --git a/ProcessLib/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h b/ProcessLib/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h
index b20825ecbfc..08f084e39a5 100644
--- a/ProcessLib/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h
+++ b/ProcessLib/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h
@@ -26,8 +26,8 @@ GenericNaturalBoundaryCondition<BoundaryConditionData,
         unsigned const global_dim, MeshLib::Mesh const& bc_mesh, Data&& data)
     : _data(std::forward<Data>(data)), _bc_mesh(bc_mesh)
 {
-    static_assert(std::is_same<typename std::decay<BoundaryConditionData>::type,
-                               typename std::decay<Data>::type>::value,
+    static_assert(std::is_same_v<typename std::decay_t<BoundaryConditionData>,
+                                 typename std::decay_t<Data>>,
                   "Type mismatch between declared and passed BC data.");
 
     // check basic data consistency
diff --git a/ProcessLib/Output/SecondaryVariable.h b/ProcessLib/Output/SecondaryVariable.h
index 4599f02025e..9a1c0974051 100644
--- a/ProcessLib/Output/SecondaryVariable.h
+++ b/ProcessLib/Output/SecondaryVariable.h
@@ -50,22 +50,22 @@ struct SecondaryVariableFunctions final
     {
         // Used to detect nasty implicit conversions.
         static_assert(
-            std::is_same<
+            std::is_same_v<
                 GlobalVector const&,
-                typename std::invoke_result<
+                typename std::invoke_result_t<
                     F1, double const, std::vector<GlobalVector*> const&,
                     std::vector<NumLib::LocalToGlobalIndexMap const*> const&,
-                    std::unique_ptr<GlobalVector>&>::type>::value,
+                    std::unique_ptr<GlobalVector>&>>,
             "The function eval_field_ does not return a const reference"
             " to a GlobalVector");
 
         static_assert(
-            std::is_same<
+            std::is_same_v<
                 GlobalVector const&,
-                typename std::invoke_result<
+                typename std::invoke_result_t<
                     F2, double const, std::vector<GlobalVector*> const&,
                     std::vector<NumLib::LocalToGlobalIndexMap const*> const&,
-                    std::unique_ptr<GlobalVector>&>::type>::value,
+                    std::unique_ptr<GlobalVector>&>>,
             "The function eval_residuals_ does not return a const reference"
             " to a GlobalVector");
     }
@@ -78,12 +78,12 @@ struct SecondaryVariableFunctions final
     {
         // Used to detect nasty implicit conversions.
         static_assert(
-            std::is_same<
+            std::is_same_v<
                 GlobalVector const&,
-                typename std::invoke_result<
+                typename std::invoke_result_t<
                     F1, double const, std::vector<GlobalVector*> const&,
                     std::vector<NumLib::LocalToGlobalIndexMap const*> const&,
-                    std::unique_ptr<GlobalVector>&>::type>::value,
+                    std::unique_ptr<GlobalVector>&>>,
             "The function eval_field_ does not return a const reference"
             " to a GlobalVector");
     }
diff --git a/ProcessLib/TES/TESLocalAssembler.h b/ProcessLib/TES/TESLocalAssembler.h
index df5407737b0..f41cbcf06ee 100644
--- a/ProcessLib/TES/TESLocalAssembler.h
+++ b/ProcessLib/TES/TESLocalAssembler.h
@@ -145,13 +145,10 @@ private:
     using NodalMatrixType = typename LAT::LocalMatrix;
     using NodalVectorType = typename LAT::LocalVector;
 
-    static_assert(
-        std::is_same<NodalMatrixType, typename LAT::LocalMatrix>::value,
-        "local matrix and data traits matrix do not coincide");
-    static_assert(
-        std::is_same<NodalVectorType, typename LAT::LocalVector>::value,
-        "local vector and data traits vector do not coincide");
-
+    static_assert(std::is_same_v<NodalMatrixType, typename LAT::LocalMatrix>,
+                  "local matrix and data traits matrix do not coincide");
+    static_assert(std::is_same_v<NodalVectorType, typename LAT::LocalVector>,
+                  "local vector and data traits vector do not coincide");
 };
 
 }  // namespace TES
diff --git a/Tests/MathLib/TestNonlinear1D.cpp b/Tests/MathLib/TestNonlinear1D.cpp
index c076a12e959..2173c444da5 100644
--- a/Tests/MathLib/TestNonlinear1D.cpp
+++ b/Tests/MathLib/TestNonlinear1D.cpp
@@ -53,10 +53,13 @@ TYPED_TEST(MathLibRegulaFalsi, QuadraticFunction)
 
     auto const error = std::abs(f(rf.getResult()));
 
-    if (!std::is_same<NL::Unmodified, TypeParam>::value) {
+    if (!std::is_same_v<NL::Unmodified, TypeParam>)
+    {
         EXPECT_GT(std::numeric_limits<double>::epsilon(), old_range);
         EXPECT_GT(std::numeric_limits<double>::epsilon(), error);
-    } else {
+    }
+    else
+    {
         // The unmodified regula falsi method converges very slowly.
         EXPECT_GT(100.0*std::numeric_limits<double>::epsilon(), error);
     }
diff --git a/Tests/NumLib/TestODEInt.cpp b/Tests/NumLib/TestODEInt.cpp
index d7fa999d1d0..47358596b3b 100644
--- a/Tests/NumLib/TestODEInt.cpp
+++ b/Tests/NumLib/TestODEInt.cpp
@@ -123,7 +123,7 @@ private:
 };
 
 template <typename TimeDisc, typename ODE, NumLib::NonlinearSolverTag NLTag>
-typename std::enable_if<std::is_same<TimeDisc, NumLib::BackwardEuler>::value,
+typename std::enable_if<std::is_same_v<TimeDisc, NumLib::BackwardEuler>,
                         Solution>::type
 run_test_case(const unsigned num_timesteps)
 {
diff --git a/Tests/NumLib/TestShapeFunctions.cpp b/Tests/NumLib/TestShapeFunctions.cpp
index aca35e3a766..c6385761733 100644
--- a/Tests/NumLib/TestShapeFunctions.cpp
+++ b/Tests/NumLib/TestShapeFunctions.cpp
@@ -46,20 +46,20 @@ struct NaturalPointGenerator
 
     result_type intervalMap(result_type const& tuple) const
     {
-        if (std::is_same<ShapeFunction, NumLib::ShapeLine2>::value ||
-            std::is_same<ShapeFunction, NumLib::ShapeLine3>::value ||
-            std::is_same<ShapeFunction, NumLib::ShapeQuad4>::value ||
-            std::is_same<ShapeFunction, NumLib::ShapeQuad8>::value ||
-            std::is_same<ShapeFunction, NumLib::ShapeQuad9>::value ||
-            std::is_same<ShapeFunction, NumLib::ShapeHex8>::value ||
-            std::is_same<ShapeFunction, NumLib::ShapeHex20>::value)
+        if (std::is_same_v<ShapeFunction, NumLib::ShapeLine2> ||
+            std::is_same_v<ShapeFunction, NumLib::ShapeLine3> ||
+            std::is_same_v<ShapeFunction, NumLib::ShapeQuad4> ||
+            std::is_same_v<ShapeFunction, NumLib::ShapeQuad8> ||
+            std::is_same_v<ShapeFunction, NumLib::ShapeQuad9> ||
+            std::is_same_v<ShapeFunction, NumLib::ShapeHex8> ||
+            std::is_same_v<ShapeFunction, NumLib::ShapeHex20>)
         {
             return tuple;
         }
-        if (std::is_same<ShapeFunction, NumLib::ShapeTri3>::value ||
-            std::is_same<ShapeFunction, NumLib::ShapeTri6>::value ||
-            std::is_same<ShapeFunction, NumLib::ShapeTet4>::value ||
-            std::is_same<ShapeFunction, NumLib::ShapeTet10>::value)
+        if (std::is_same_v<ShapeFunction, NumLib::ShapeTri3> ||
+            std::is_same_v<ShapeFunction, NumLib::ShapeTri6> ||
+            std::is_same_v<ShapeFunction, NumLib::ShapeTet4> ||
+            std::is_same_v<ShapeFunction, NumLib::ShapeTet10>)
         {
             // Map square (x, y) \in [-1, 1]^2 to a triangle such that x,y
             // \in [0, 1], and x+y \in [0, 2/2].
-- 
GitLab