Fix code so clang-tidy no longer complains
authorMark Abraham <mark.j.abraham@gmail.com>
Mon, 22 Feb 2021 12:29:43 +0000 (13:29 +0100)
committerArtem Zhmurov <zhmurov@gmail.com>
Mon, 22 Feb 2021 16:47:47 +0000 (16:47 +0000)
src/gromacs/mdlib/tests/freeenergyparameters.cpp
src/gromacs/utility/enumerationhelpers.h

index d6d085bcfb12a718115f85f65ecd28f4269a0e8e..b2b3fe0fc39da6c03d9c3fddcd72b07456acfd62 100644 (file)
@@ -137,28 +137,14 @@ public:
         fepvals.init_fep_state = GetParam().initFepState;
         fepvals.init_lambda    = GetParam().initLambda;
         fepvals.delta_lambda   = GetParam().deltaLambda;
-        fepvals.all_lambda     = getLambdaMatrix(GetParam().nLambda);
-        fepvals.n_lambda       = GetParam().nLambda;
+        std::fill(fepvals.all_lambda.begin(),
+                  fepvals.all_lambda.end(),
+                  defaultLambdaArrayForTest_[GetParam().nLambda]);
+        fepvals.n_lambda = GetParam().nLambda;
         return fepvals;
     }
 
-    /*! \brief construct a lambda matrix
-     *
-     * \param[in] nLambda
-     * \returns nLambda * eftpNR matrix with pre-defined values
-     */
-    gmx::EnumerationArray<FreeEnergyPerturbationCouplingType, std::vector<double>> getLambdaMatrix(int nLambda)
-    {
-        for (auto i : keysOf(allLambda_))
-        {
-            allLambda_[i] = defaultLambdaArrayForTest_[nLambda];
-        }
-        return allLambda_;
-    }
-
 private:
-    //! Construction aide for double ** matrix without snew
-    gmx::EnumerationArray<FreeEnergyPerturbationCouplingType, std::vector<double>> allLambda_;
     //! a set of default lambda arrays for different lengths
     std::vector<std::vector<double>> defaultLambdaArrayForTest_ = { {}, { 0.8 }, { 0.2, 0.8 }, { 0.2, 0.8, 0.8 } };
 };
index 59ef2689d3cda84a5ec5e237d7c1df636e9af82b..17bba5c10a4b9c8a84113b1ef39c249a7f5373b3 100644 (file)
@@ -190,12 +190,17 @@ public:
  *
  * See file documentation for usage example.
  *
+ * Note that if clang-tidy gives strange errors referring to the line
+ * number of the struct declaration, these likely refer to the
+ * compiler-generated constructors. Simplification of the calling code
+ * might eliminate that call and thus the clang-tidy error.
+ *
  * \tparam  EnumType   The enum (class) type.
  * \tparam  DataType   Type of the data stored in the array.
  * \tparam  ArraySize  Size in entries of the array.
  */
 template<typename EnumType, typename DataType, EnumType ArraySize = EnumType::Count>
-struct EnumerationArray final // NOLINT(readability-braces-around-statements)
+struct EnumerationArray final
 {
     //! Convenience alias
     using EnumerationWrapperType = EnumerationWrapper<EnumType, ArraySize>;