Modernize STL usage
authorRoland Schulz <roland.schulz@intel.com>
Mon, 6 Jul 2020 14:19:37 +0000 (14:19 +0000)
committerChristian Blau <cblau.mail@gmail.com>
Mon, 6 Jul 2020 14:19:37 +0000 (14:19 +0000)
29 files changed:
src/gromacs/compat/pointers.h
src/gromacs/compat/utility.h [deleted file]
src/gromacs/domdec/hashedmap.h
src/gromacs/domdec/localatomsetdata.h
src/gromacs/domdec/localatomsetmanager.h
src/gromacs/ewald/pme_gather.cpp
src/gromacs/fileio/mrcserializer.cpp
src/gromacs/fileio/tests/fileioxdrserializer.cpp
src/gromacs/gpu_utils/oclutils.h
src/gromacs/math/arrayrefwithpadding.h
src/gromacs/math/paddedvector.h
src/gromacs/math/tests/testarrayrefs.h
src/gromacs/math/vectypes.h
src/gromacs/mdspan/mdspan.h
src/gromacs/random/uniformrealdistribution.h
src/gromacs/simd/simd.h
src/gromacs/simd/simd_memory.h
src/gromacs/simd/tests/simd_memory.cpp
src/gromacs/utility/allocator.h
src/gromacs/utility/any.h
src/gromacs/utility/arrayref.h
src/gromacs/utility/defaultinitializationallocator.h
src/gromacs/utility/exceptions.h
src/gromacs/utility/fixedcapacityvector.h
src/gromacs/utility/listoflists.h
src/gromacs/utility/range.h
src/gromacs/utility/smalloc.h
src/gromacs/utility/tests/arrayref.cpp
src/gromacs/utility/tests/inmemoryserializer.cpp

index ac3099207e486b253fadf44905dd1118a6b10956..f10760581fec26b052fe82d55306c35bfe8083a5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -89,24 +89,24 @@ template<class T>
 class not_null
 {
 public:
-    static_assert(std::is_assignable<T&, std::nullptr_t>::value, "T cannot be assigned nullptr.");
+    static_assert(std::is_assignable_v<T&, std::nullptr_t>, "T cannot be assigned nullptr.");
 
     //! Move constructor. Asserts in debug mode if \c is nullptr.
-    template<typename U, typename = typename std::enable_if<std::is_convertible<U, T>::value>::type>
+    template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
     constexpr explicit not_null(U&& u) : ptr_(std::forward<U>(u))
     {
         Expects(ptr_ != nullptr);
     }
 
     //! Simple constructor. Asserts in debug mode if \c u is nullptr.
-    template<typename = typename std::enable_if<!std::is_same<std::nullptr_t, T>::value>::type>
+    template<typename = std::enable_if_t<!std::is_same_v<std::nullptr_t, T>>>
     constexpr explicit not_null(T u) : ptr_(u)
     {
         Expects(ptr_ != nullptr);
     }
 
     //! Copy constructor.
-    template<typename U, typename = typename std::enable_if<std::is_convertible<U, T>::value>::type>
+    template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, T>>>
     constexpr not_null(const not_null<U>& other) : not_null(other.get())
     {
     }
@@ -155,16 +155,14 @@ private:
 template<class T>
 not_null<T> make_not_null(T&& t)
 {
-    return not_null<typename std::remove_cv<typename std::remove_reference<T>::type>::type>{
-        std::forward<T>(t)
-    };
+    return not_null<std::remove_cv_t<std::remove_reference_t<T>>>{ std::forward<T>(t) };
 }
 
 //! Convenience function for making not_null pointers from smart pointers.
 template<class T>
 not_null<typename T::pointer> make_not_null(T& t)
 {
-    return not_null<typename std::remove_reference<T>::type::pointer>{ t.get() };
+    return not_null<typename std::remove_reference_t<T>::pointer>{ t.get() };
 }
 
 //! Operators to compare not_null pointers.
diff --git a/src/gromacs/compat/utility.h b/src/gromacs/compat/utility.h
deleted file mode 100644 (file)
index c3fcdc6..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
- * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
- * and including many others, as listed in the AUTHORS file in the
- * top-level source directory and at http://www.gromacs.org.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-
-/*! \libinternal \file
- * \brief Provides backported functions/classes from utility
- *
- * \author Roland Schulz <roland.schulz@intel.com>
- * \ingroup module_compat
- * \inlibraryapi
- */
-#ifndef GMX_COMPAT_UTILITY_H
-#define GMX_COMPAT_UTILITY_H
-namespace gmx
-{
-namespace compat
-{
-//! Forms lvalue reference to const type of t
-template<class T>
-constexpr const T& as_const(T& t) noexcept
-{
-    return t;
-}
-} // namespace compat
-} // namespace gmx
-#endif
index 32bc3ceb25d7edd85958510a0eb373d7e52050bf..4ef845b6013053fe3c2db2074df706f0a9243045 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -50,9 +50,9 @@
 #include <climits>
 
 #include <algorithm>
+#include <utility>
 #include <vector>
 
-#include "gromacs/compat/utility.h"
 #include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/exceptions.h"
 
@@ -260,7 +260,7 @@ public:
      * \param[in] key  The key
      * \return a pointer to value for the given key or nullptr when not present
      */
-    T* find(int key) { return const_cast<T*>(gmx::compat::as_const(*this).find(key)); }
+    T* find(int key) { return const_cast<T*>(std::as_const(*this).find(key)); }
 
     /*! \brief Returns a pointer to the value for the given key or nullptr when not present
      *
index 89cb5216fe03baa3f1f57e57af586690c767936b..a41c6dceef75035687afdc9bb6abe9a46964c6ef 100644 (file)
@@ -75,7 +75,7 @@ public:
      *
      * \param[in] globalAtomIndex Indices of the atoms to be managed
      */
-    template<typename T = void, typename U = std::enable_if_t<!std::is_same<int, index>::value, T>>
+    template<typename T = void, typename U = std::enable_if_t<!std::is_same_v<int, index>, T>>
     explicit LocalAtomSetData(ArrayRef<const int> globalAtomIndex) :
         globalIndex_(globalAtomIndex.begin(), globalAtomIndex.end()),
         localIndex_(globalAtomIndex.begin(), globalAtomIndex.end())
index 8a2c227f32bd2ec65b53e03f5a4d4a9ce0a73bd8..bff851974512d261e04e2f0107a088587e47906f 100644 (file)
@@ -84,7 +84,7 @@ public:
      * \param[in] globalAtomIndex Indices of the atoms to be managed
      * \returns Handle to LocalAtomSet.
      */
-    template<typename T = void, typename U = std::enable_if_t<!std::is_same<int, index>::value, T>>
+    template<typename T = void, typename U = std::enable_if_t<!std::is_same_v<int, index>, T>>
     LocalAtomSet add(ArrayRef<const int> globalAtomIndex);
 #endif
     /*! \brief Add a new atom set to be managed and give back a handle.
index 41d8f3a78317e7c670be6e641be365a6f90051c6..2a7925cfe281335cd195176f2497f87aab10265c 100644 (file)
@@ -93,7 +93,7 @@ struct do_fspline
     template<typename Int>
     RVec operator()(Int order) const
     {
-        static_assert(isIntegralConstant<Int, int>::value || std::is_same<Int, int>::value,
+        static_assert(isIntegralConstant<Int, int>::value || std::is_same_v<Int, int>,
                       "'order' needs to be either of type integral_constant<int,N> or int.");
 
         const int norder = nn * order;
index ac4968cdf2b7b23a081caf0dbbd6fa6c8c225428..96899c0389beeb70c148bcecb4aeb7bccb6b0629 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -77,7 +77,7 @@ enum class MachineStamp : int32_t
  * \param[in,out] valueContainer the array to be serialized
  */
 template<typename ContainerType>
-std::enable_if_t<std::is_same<typename ContainerType::value_type, int32_t>::value, void>
+std::enable_if_t<std::is_same_v<typename ContainerType::value_type, int32_t>, void>
 serialize(ISerializer* serializer, ContainerType* valueContainer)
 {
     for (auto& value : *valueContainer)
@@ -95,7 +95,7 @@ serialize(ISerializer* serializer, ContainerType* valueContainer)
  * \param[in,out] valueContainer the array to be serialized
  */
 template<typename ContainerType>
-std::enable_if_t<std::is_same<typename ContainerType::value_type, float>::value, void>
+std::enable_if_t<std::is_same_v<typename ContainerType::value_type, float>, void>
 serialize(ISerializer* serializer, ContainerType* valueContainer)
 {
     for (auto& value : *valueContainer)
@@ -134,7 +134,7 @@ void serializeIndices(ISerializer* serializer, std::array<int32_t, 3>* valueArra
  * \tparam IntegralType type to be serialized as int32_t
  */
 template<class IntegralType>
-std::enable_if_t<(std::is_integral<IntegralType>::value || std::is_enum<IntegralType>::value), void>
+std::enable_if_t<(std::is_integral_v<IntegralType> || std::is_enum_v<IntegralType>), void>
 serializeAsInt32(ISerializer* serializer, IntegralType* value)
 {
     int32_t serializedValue;
index fb4dcf5af078001504387bc8a15d56fc78a7ce72..2c5d9b0c4309632435361ff75897d569801a74d5 100644 (file)
@@ -103,7 +103,7 @@ public:
         std::int64_t   int64Value_         = c_int64Value;
         double         doubleValue_        = c_intAndFloat64.doubleValue_;
         int            intValue_           = integerSizeDependentTestingValue();
-        real           realValue_          = std::is_same<real, double>::value
+        real           realValue_          = std::is_same_v<real, double>
                                   ? static_cast<real>(c_intAndFloat64.doubleValue_)
                                   : static_cast<real>(c_intAndFloat32.floatValue_);
     } defaultValues_;
index 333147d78f3d358f5152a8be2ab04785f679f578..bb776d4781aac59d61987d11fb1f4b985e4d19d0 100644 (file)
@@ -149,11 +149,10 @@ void prepareGpuKernelArgument(cl_kernel                 kernel,
 
     // Assert on types not allowed to be passed to a kernel
     // (as per section 6.9 of the OpenCL spec).
-    static_assert(!std::is_same<CurrentArg, bool>::value && !std::is_same<CurrentArg, size_t>::value
-                          && !std::is_same<CurrentArg, ptrdiff_t>::value
-                          && !std::is_same<CurrentArg, intptr_t>::value
-                          && !std::is_same<CurrentArg, uintptr_t>::value,
-                  "Invalid type passed to OpenCL kernel functions (see OpenCL spec section 6.9).");
+    static_assert(
+            !std::is_same_v<CurrentArg,
+                            bool> && !std::is_same_v<CurrentArg, size_t> && !std::is_same_v<CurrentArg, ptrdiff_t> && !std::is_same_v<CurrentArg, intptr_t> && !std::is_same_v<CurrentArg, uintptr_t>,
+            "Invalid type passed to OpenCL kernel functions (see OpenCL spec section 6.9).");
 
     prepareGpuKernelArgument(kernel, config, argIndex + 1, otherArgsPtrs...);
 }
index 3e5f535c6cb615015da2db6688b07149f09c09b7..7a8a2b632f45b3cf84849ff61b65b95aaaed53bd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -121,7 +121,7 @@ public:
     {
     }
     //! Convenience overload constructor to make an ArrayRefWithPadding<const T> from a non-const one.
-    template<typename U, typename = std::enable_if_t<std::is_same<value_type, const typename std::remove_reference_t<U>::value_type>::value>>
+    template<typename U, typename = std::enable_if_t<std::is_same_v<value_type, const typename std::remove_reference_t<U>::value_type>>>
     ArrayRefWithPadding(U&& o)
     {
         auto constArrayRefWithPadding = o.constArrayRefWithPadding();
index 79e5c1b08b8f53785213b8c12999e6a40e98aa70..6a1d2e12b210a856a3b4e99714399a2cb8222203 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -373,13 +373,13 @@ public:
         return ArrayRefWithPadding<const T>(data(), data() + size(), data() + paddedSize());
     }
     //! Returns an rvec * pointer for containers of RVec, for use with legacy code.
-    template<typename AlsoT = T, typename = typename std::enable_if<std::is_same<AlsoT, RVec>::value>>
+    template<typename AlsoT = T, typename = typename std::enable_if<std::is_same_v<AlsoT, RVec>>>
     rvec* rvec_array()
     {
         return as_rvec_array(data());
     }
     //! Returns a const rvec * pointer for containers of RVec, for use with legacy code.
-    template<typename AlsoT = T, typename = typename std::enable_if<std::is_same<AlsoT, RVec>::value>>
+    template<typename AlsoT = T, typename = typename std::enable_if<std::is_same_v<AlsoT, RVec>>>
     const rvec* rvec_array() const
     {
         return as_rvec_array(data());
index 405aa4108bfde87874b76eecdebb0eb57dcd39b2..bdaae01d68b365c233727664b43a7555552a117a 100644 (file)
@@ -102,7 +102,7 @@ void compareViews(ArrayRef<T> input, ArrayRef<T> output)
 
 //! Comparison for non-BasicVector ignoring const qualifiers
 template<typename T, typename U>
-typename std::enable_if<std::is_same<typename std::remove_const<T>::type, typename std::remove_const<U>::type>::value, void>::type
+typename std::enable_if_t<std::is_same_v<std::remove_const_t<T>, std::remove_const_t<U>>, void>
 compareViewsIgnoreConst(ArrayRef<T> input, ArrayRef<U> output)
 {
     ASSERT_EQ(input.size(), output.size());
index a8c49149b008f615eeb3b063cc3dbfc0c0c1ee4d..a4f3fe25a00f5e17b91524693158358ed64dda9d 100644 (file)
@@ -94,7 +94,7 @@ public:
     // of pointers, the implementation will be different enough that the whole
     // template class should have a separate partial specialization. We try to avoid
     // accidental matching to pointers, but this assertion is a no-cost extra check.
-    static_assert(!std::is_pointer<std::remove_cv_t<ValueType>>::value,
+    static_assert(!std::is_pointer_v<std::remove_cv_t<ValueType>>,
                   "BasicVector value type must not be a pointer.");
 
     //! Constructs default (uninitialized) vector.
index 10499d655dcf55f840a81c92f2111818d17d0eba..5b2f5351975ba30d25cc58f63f1c44eb1c397f03 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -216,7 +216,7 @@ public:
      * \tparam U container type
      * \param[in] other mdspan-implementing container
      */
-    template<typename U, typename = std::enable_if_t<std::is_same<typename std::remove_reference_t<U>::view_type::element_type, ElementType>::value>>
+    template<typename U, typename = std::enable_if_t<std::is_same_v<typename std::remove_reference_t<U>::view_type::element_type, ElementType>>>
     constexpr basic_mdspan(U&& other) : basic_mdspan(other.asView())
     {
     }
@@ -230,7 +230,7 @@ public:
      * \tparam U container type
      * \param[in] other mdspan-implementing container
      */
-    template<typename U, typename = std::enable_if_t<std::is_same<typename std::remove_reference_t<U>::const_view_type::element_type, ElementType>::value>>
+    template<typename U, typename = std::enable_if_t<std::is_same_v<typename std::remove_reference_t<U>::const_view_type::element_type, ElementType>>>
     constexpr basic_mdspan(const U& other) : basic_mdspan(other.asConstView())
     {
     }
@@ -252,7 +252,7 @@ public:
      * \returns reference to element stored at position i
      */
     template<class IndexType>
-    constexpr std::enable_if_t<std::is_integral<IndexType>::value && extents_type::rank() == 1, reference>
+    constexpr std::enable_if_t<std::is_integral_v<IndexType> && extents_type::rank() == 1, reference>
     operator[](const IndexType& i) const noexcept
     {
         return acc_.access(ptr_, map_(i));
@@ -279,8 +279,8 @@ public:
      */
     template<class IndexType,
              typename sliced_mdspan_type = basic_mdspan<element_type, decltype(extents_type().sliced_extents()), LayoutPolicy, AccessorPolicy>>
-    constexpr std::enable_if_t<std::is_integral<IndexType>::value && (extents_type::rank() > 1)
-                                       && std::is_same<LayoutPolicy, layout_right>::value,
+    constexpr std::enable_if_t<std::is_integral_v<IndexType> && (extents_type::rank() > 1)
+                                       && std::is_same_v<LayoutPolicy, layout_right>,
                                sliced_mdspan_type>
     operator[](const IndexType index) const noexcept
     {
index bdaf090018fab9fc571868e5897909f728b2bead..17a1e9240fd383c2990466a91d134fbabd65cfde 100644 (file)
@@ -113,8 +113,7 @@ RealType generateCanonical(Rng& g)
     // Only unsigned integer types can express the range using the
     // same type. Converting to RealType before computing the range
     // would work but we have no need for that.
-    static_assert(std::is_unsigned<decltype(Rng::max())>::value
-                          && std::is_unsigned<decltype(Rng::min())>::value,
+    static_assert(std::is_unsigned_v<decltype(Rng::max())> && std::is_unsigned_v<decltype(Rng::min())>,
                   "Rng::max and Rng::min must be unsigned");
     RealType r    = RealType(Rng::max() - Rng::min()) + RealType(1);
     RealType s    = g() - Rng::min();
index 537046645a9b2080ae4024bfc6dcadb9e7e794c4..d67ce0bbab84b48090b0cae179ce69e54d5aa51c 100644 (file)
@@ -482,11 +482,12 @@ struct SimdTraits<SimdDInt32>
     using tag                  = SimdDInt32Tag;
 };
 #endif
-
+template<typename T>
+using SimdTraitsT = typename SimdTraits<T>::type;
 template<typename T>
 struct SimdTraits<const T>
 {
-    using type                 = const typename SimdTraits<T>::type;
+    using type                 = const SimdTraitsT<T>;
     static constexpr int width = SimdTraits<T>::width;
     using tag                  = typename SimdTraits<T>::tag;
 };
@@ -503,8 +504,7 @@ struct SimdTraits<const T>
  * \return   Loaded value
  */
 template<typename T>
-static inline std::remove_const_t<T>
-load(const typename internal::SimdTraits<T>::type* m) // disabled by SFINAE for non-SIMD types
+static inline std::remove_const_t<T> load(const internal::SimdTraitsT<T>* m) // disabled by SFINAE for non-SIMD types
 {
     return simdLoad(m, typename internal::SimdTraits<T>::tag());
 }
@@ -516,13 +516,13 @@ static inline T
  * 2) load(real*); template parameter is mandatory because otherwise ambiguity is
  *    created. The dependent type disables type deduction.
  */
-load(const std::enable_if_t<std::is_arithmetic<T>::value, T> *m)
+load(const std::enable_if_t<std::is_arithmetic_v<T>, T> *m)
 {
     return *m;
 }
 
 template<typename T, size_t N>
-static inline T gmx_simdcall load(const AlignedArray<typename internal::SimdTraits<T>::type, N>& m)
+static inline T gmx_simdcall load(const AlignedArray<internal::SimdTraitsT<T>, N>& m)
 {
     return simdLoad(m.data(), typename internal::SimdTraits<T>::tag());
 }
@@ -534,19 +534,19 @@ static inline T gmx_simdcall load(const AlignedArray<typename internal::SimdTrai
  * \return Loaded SimdFloat/Double/Int or basic scalar type
  */
 template<typename T>
-static inline T loadU(const typename internal::SimdTraits<T>::type* m)
+static inline T loadU(const internal::SimdTraitsT<T>* m)
 {
     return simdLoadU(m, typename internal::SimdTraits<T>::tag());
 }
 
 template<typename T>
-static inline T loadU(const std::enable_if_t<std::is_arithmetic<T>::value, T>* m)
+static inline T loadU(const std::enable_if_t<std::is_arithmetic_v<T>, T>* m)
 {
     return *m;
 }
 
 template<typename T, size_t N>
-static inline T gmx_simdcall loadU(const AlignedArray<typename internal::SimdTraits<T>::type, N>& m)
+static inline T gmx_simdcall loadU(const AlignedArray<internal::SimdTraitsT<T>, N>& m)
 {
     return simdLoadU(m.data(), typename internal::SimdTraits<T>::tag());
 }
@@ -621,16 +621,18 @@ struct Simd4Traits<Simd4Double>
     using type = double;
 };
 #endif
+template<typename T>
+using Simd4TraitsT = typename Simd4Traits<T>::type;
 } // namespace internal
 
 #if GMX_SIMD4_HAVE_REAL
 template<typename T>
-T load(const typename internal::Simd4Traits<T>::type* m)
+T load(const internal::Simd4TraitsT<T>* m)
 {
     return load4(m);
 }
 template<typename T>
-T loadU(const typename internal::Simd4Traits<T>::type* m)
+T loadU(const internal::Simd4TraitsT<T>* m)
 {
     return load4U(m);
 }
index aa4a3c8da81ef788c224b1602288f4346516adf7..9a770ce906e81538253a56ef56be570136d7c783 100644 (file)
@@ -55,7 +55,7 @@ class SimdReference
 {
 private:
     using non_const_T = std::remove_const_t<T>;
-    using pointer     = typename SimdTraits<T>::type*;
+    using pointer     = SimdTraitsT<T>*;
 
 public:
     //! \brief Constructor
@@ -98,7 +98,7 @@ class SimdIterator :
     using Base =
             boost::stl_interfaces::iterator_interface<SimdIterator<T>, std::random_access_iterator_tag, T, SimdReference<T>>;
     // pointer is T*
-    using DataPointer = typename SimdTraits<T>::type*;
+    using DataPointer = SimdTraitsT<T>*;
 
 public:
     explicit SimdIterator(DataPointer p = 0) : p_(p)
@@ -144,7 +144,7 @@ public:
     //! Type of values stored in the container.
     using value_type = T;
     //! Pointer to a container element.
-    using pointer = typename SimdTraits<T>::type*;
+    using pointer = SimdTraitsT<T>*;
     //! Reference to a container element.
     using reference = internal::SimdReference<T>;
     //! Iterator type for the container.
@@ -162,7 +162,7 @@ public:
                    "Size of ArrayRef needs to be divisible by type size");
     }
     //! \copydoc ArrayRef::ArrayRef(U)
-    template<typename U, typename = std::enable_if_t<std::is_convertible<typename std::remove_reference_t<U>::pointer, pointer>::value>>
+    template<typename U, typename = std::enable_if_t<std::is_convertible_v<typename std::remove_reference_t<U>::pointer, pointer>>>
     SimdArrayRef(U&& o) :
         begin_(reinterpret_cast<pointer>(o.data())),
         end_(reinterpret_cast<pointer>(o.data() + o.size()))
@@ -190,7 +190,7 @@ public:
 
 private:
     static constexpr int simdWidth = SimdTraits<T>::width;
-    using pack_type                = typename SimdTraits<T>::type[simdWidth];
+    using pack_type                = SimdTraitsT<T>[simdWidth];
     // Private because dereferencing return value is undefined behavior (strict aliasing rule)
     // Only use is conversion constructor above which immediately casts it back.
     // Return type is not "pointer" because then data()+size() would be ill defined.
index b9604b49b895168a376a30ddbbde7c38ba7ecde2..22f19fc03de5d5475f406eea3f93c1ec7472b95e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017,2019, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -94,10 +94,10 @@ template<typename TypeParam>
 class ArrayRefTest : public test::SimdTest
 {
 public:
-    using ArrayRefType = TypeParam;
-    using PointerType  = typename ArrayRefType::pointer;
-    using ValueType    = typename ArrayRefType::value_type;
-    using ElementType  = std::remove_const_t<typename gmx::internal::SimdTraits<ValueType>::type>;
+    using ArrayRefType         = TypeParam;
+    using PointerType          = typename ArrayRefType::pointer;
+    using ValueType            = typename ArrayRefType::value_type;
+    using ElementType          = std::remove_const_t<gmx::internal::SimdTraitsT<ValueType>>;
     static constexpr int width = gmx::internal::SimdTraits<ValueType>::width;
 
     /*! \brief Run the same tests all the time
index c4d4a230278791b1c195625a365c0b9c579ca43d..2bda1d6dab7b8aa7f84094711a499c30c782c10a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -153,7 +153,7 @@ public:
      * Always true for stateless polcies. Has to be defined in the policy for stateful policies.
      * FUTURE: Can be removed with C++17 (is_always_equal)
      */
-    template<class T2, class A = AllocationPolicy, typename = std::enable_if_t<std::is_empty<A>::value>>
+    template<class T2, class A = AllocationPolicy, typename = std::enable_if_t<std::is_empty_v<A>>>
     bool operator==(const Allocator<T2, AllocationPolicy>& /*unused*/) const
     {
         return true;
index 7e2c86f4411f0228d408f12e34041100bd283736..77f70a7863e5e6cdf6c0a96b3a5d6cde2ad76816 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -112,7 +112,7 @@ public:
      *
      * \throws std::bad_alloc if out of memory.
      */
-    template<typename T, typename = std::enable_if_t<!std::is_same<T, Any>::value>>
+    template<typename T, typename = std::enable_if_t<!std::is_same_v<T, Any>>>
     explicit Any(T&& value) : content_(new Content<std::decay_t<T>>(std::forward<T>(value)))
     {
     }
index d7efde7145a3558afe06b4933ea31cd869f115e6..d70527b230c8a9ce7368d075d8efd02137450f92 100644 (file)
@@ -73,7 +73,7 @@ struct ArrayRefIter :
     // This default constructor does not initialize it_
     constexpr ArrayRefIter() noexcept {}
     constexpr explicit ArrayRefIter(T* it) noexcept : it_(it) {}
-    template<class T2 = T, class = std::enable_if_t<std::is_const<T2>::value>>
+    template<class T2 = T, class = std::enable_if_t<std::is_const_v<T2>>>
     constexpr ArrayRefIter(ArrayRefIter<std::remove_const_t<T2>> it) noexcept : it_(&*it)
     {
     }
@@ -176,7 +176,7 @@ public:
      * This constructor is not explicit to allow directly passing
      * a container to a method that takes ArrayRef.
      */
-    template<typename U, typename = std::enable_if_t<std::is_convertible<typename std::remove_reference_t<U>::pointer, pointer>::value>>
+    template<typename U, typename = std::enable_if_t<std::is_convertible_v<typename std::remove_reference_t<U>::pointer, pointer>>>
     ArrayRef(U&& o) : begin_(o.data()), end_(o.data() + o.size())
     {
     }
@@ -313,7 +313,7 @@ ArrayRef<const T> constArrayRefFromArray(const T* begin, size_t size)
  * \see ArrayRef
  */
 template<typename T>
-ArrayRef<std::conditional_t<std::is_const<T>::value, const typename T::value_type, typename T::value_type>>
+ArrayRef<std::conditional_t<std::is_const_v<T>, const typename T::value_type, typename T::value_type>>
 makeArrayRef(T& c)
 {
     return c;
index a98dc4491d5488b729f736cb57f044b7877769e0..54321b3bbb04c96782b6eedf5f25b9e4ef21e337 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -70,7 +70,7 @@ public:
 
     /*! \brief Constructs an object and default initializes */
     template<typename U>
-    void construct(U* ptr) noexcept(std::is_nothrow_default_constructible<U>::value)
+    void construct(U* ptr) noexcept(std::is_nothrow_default_constructible_v<U>)
     {
         ::new (static_cast<void*>(ptr)) U;
     }
index 034a60b3d12ec3c37c1d1eeabb895de3290259bd..51abee1c42beff9b22c658353453d50447b620aa 100644 (file)
@@ -379,7 +379,7 @@ private:
  * if the enable_if causes problems with some compilers, it can be removed.
  */
 template<class Exception, class Tag, class T>
-inline std::enable_if_t<std::is_base_of<GromacsException, Exception>::value, Exception>
+inline std::enable_if_t<std::is_base_of_v<GromacsException, Exception>, Exception>
 operator<<(Exception ex, const ExceptionInfo<Tag, T>& item)
 {
     ex.setInfo(item);
index 03c6d79443361fb6867847176ad0117da699bcd8..276744958822cc76454d63d0e61a510b46de9677 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -194,7 +194,7 @@ public:
     reference emplace_back(Args&&... args)
     {
         GMX_ASSERT(size() < capacity, "Cannot add more elements than the capacity");
-        if (std::is_move_assignable<T>::value)
+        if (std::is_move_assignable_v<T>)
         {
             *end_ = std::move(T(args...));
         }
index 96927dc80c882d3be40a355236a450e25f21d5b8..e9baa98b4ddbe1b6804f2ca1d25dd407a4084d14 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -77,7 +77,7 @@ namespace gmx
 template<typename T>
 class ListOfLists
 {
-    static_assert(std::is_arithmetic<T>::value, "This class is limited to arithmetic types");
+    static_assert(std::is_arithmetic_v<T>, "This class is limited to arithmetic types");
 
 public:
     //! Constructs an empty list of lists
@@ -133,7 +133,7 @@ public:
     void pushBackListOfSize(int numElements)
     {
         // With arithmetic types enforced, this assertion is always true
-        static_assert(std::is_default_constructible<T>::value,
+        static_assert(std::is_default_constructible_v<T>,
                       "pushBackListOfSize should only be called with default constructable types");
         elements_.resize(elements_.size() + numElements);
         listRanges_.push_back(int(elements_.size()));
index 8fb2f12362d63b4c825bf4de0c1c7db0208ba6fe..5871eb4e746acd61b9839ecbbabf0728cbc5e8b4 100644 (file)
@@ -63,7 +63,7 @@ namespace gmx
 template<typename T>
 class Range
 {
-    static_assert(std::is_integral<T>::value, "Range can only be used with integral types");
+    static_assert(std::is_integral_v<T>, "Range can only be used with integral types");
 
     // Note: This class has as invariant: begin_ <= end_
 
index bf7fa34c9ce9e37de1233b94b4ee41733500839d..cb9fb4a73931e06f1f8fd47e28424ff6980d6003 100644 (file)
@@ -202,7 +202,7 @@ void save_free_aligned(const char* name, const char* file, int line, void* ptr);
 template<typename T>
 static inline void gmx_snew_impl(const char* name, const char* file, int line, T*& ptr, size_t nelem)
 {
-    static_assert(std::is_pod<T>::value, "snew() called on C++ type");
+    static_assert(std::is_pod_v<T>, "snew() called on C++ type");
     // NOLINTNEXTLINE bugprone-sizeof-expression
     ptr = static_cast<T*>(save_calloc(name, file, line, nelem, sizeof(T)));
 }
@@ -210,7 +210,7 @@ static inline void gmx_snew_impl(const char* name, const char* file, int line, T
 template<typename T>
 static inline void gmx_srenew_impl(const char* name, const char* file, int line, T*& ptr, size_t nelem)
 {
-    static_assert(std::is_pod<T>::value, "srenew() called on C++ type");
+    static_assert(std::is_pod_v<T>, "srenew() called on C++ type");
     // NOLINTNEXTLINE bugprone-sizeof-expression
     ptr = static_cast<T*>(save_realloc(name, file, line, ptr, nelem, sizeof(T)));
 }
@@ -218,7 +218,7 @@ static inline void gmx_srenew_impl(const char* name, const char* file, int line,
 template<typename T>
 static inline void gmx_smalloc_impl(const char* name, const char* file, int line, T*& ptr, size_t size)
 {
-    static_assert(std::is_pod<T>::value, "smalloc() called on C++ type");
+    static_assert(std::is_pod_v<T>, "smalloc() called on C++ type");
     ptr = static_cast<T*>(save_malloc(name, file, line, size));
 }
 /** C++ helper for snew_aligned(). */
@@ -226,22 +226,21 @@ template<typename T>
 static inline void
 gmx_snew_aligned_impl(const char* name, const char* file, int line, T*& ptr, size_t nelem, size_t alignment)
 {
-    static_assert(std::is_pod<T>::value, "snew_aligned() called on C++ type");
+    static_assert(std::is_pod_v<T>, "snew_aligned() called on C++ type");
     ptr = static_cast<T*>(save_calloc_aligned(name, file, line, nelem, sizeof(T), alignment));
 }
 /** C++ helper for sfree(). */
 template<typename T>
 static inline void gmx_sfree_impl(const char* name, const char* file, int line, T* ptr)
 {
-    static_assert(std::is_pod<T>::value || std::is_void<T>::value, "sfree() called on C++ type");
+    static_assert(std::is_pod_v<T> || std::is_void_v<T>, "sfree() called on C++ type");
     save_free(name, file, line, ptr);
 }
 /** C++ helper for sfree_aligned(). */
 template<typename T>
 static inline void gmx_sfree_aligned_impl(const char* name, const char* file, int line, T* ptr)
 {
-    static_assert(std::is_pod<T>::value || std::is_void<T>::value,
-                  "sfree_aligned() called on C++ type");
+    static_assert(std::is_pod_v<T> || std::is_void_v<T>, "sfree_aligned() called on C++ type");
     save_free_aligned(name, file, line, ptr);
 }
 /*! \} */
index 8c9e2759ec67f6880bbacd323597b0d30bb28214..17cd919ce644a528782eb425a350be668b2a378f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -176,7 +176,7 @@ using makeConstIf_t = std::conditional_t<c, const T, T>;
 
 TYPED_TEST(ArrayRefTest, ConstructFromVectorWorks)
 {
-    makeConstIf_t<std::is_const<typename TestFixture::ValueType>::value, std::vector<typename TestFixture::NonConstValueType>> v(
+    makeConstIf_t<std::is_const_v<typename TestFixture::ValueType>, std::vector<typename TestFixture::NonConstValueType>> v(
             this->a, this->a + aSize);
     typename TestFixture::ArrayRefType arrayRef(v);
     this->runTests(v.data(), arrayRef);
index 1a450900033d976408e776d809c68e58547e154e..2db9b643f50a4923553354736f6478f1cb22c29f 100644 (file)
@@ -162,7 +162,7 @@ protected:
                                         c_int64Value,
                                         c_intAndFloat64.doubleValue_,
                                         integerSizeDependentTestingValue(),
-                                        std::is_same<real, double>::value
+                                        std::is_same_v<real, double>
                                                 ? static_cast<real>(c_intAndFloat64.doubleValue_)
                                                 : static_cast<real>(c_intAndFloat32.floatValue_) };
 
@@ -176,8 +176,8 @@ protected:
         c_int64ValueSwapped,
         c_intAndFloat64Swapped.doubleValue_,
         integerSizeDependentTestingValueEndianessSwapped(),
-        std::is_same<real, float>::value ? static_cast<real>(c_intAndFloat32Swapped.floatValue_)
-                                         : static_cast<real>(c_intAndFloat64Swapped.doubleValue_)
+        std::is_same_v<real, float> ? static_cast<real>(c_intAndFloat32Swapped.floatValue_)
+                                    : static_cast<real>(c_intAndFloat64Swapped.doubleValue_)
     };
 };
 
@@ -189,7 +189,7 @@ TEST_F(InMemorySerializerTest, Roundtrip)
 
     auto buffer = serializer.finishAndGetBuffer();
 
-    InMemoryDeserializer deserializer(buffer, std::is_same<real, double>::value);
+    InMemoryDeserializer deserializer(buffer, std::is_same_v<real, double>);
 
     SerializerValues deserialisedValues = deserialize(&deserializer);
 
@@ -204,7 +204,7 @@ TEST_F(InMemorySerializerTest, RoundtripWithEndianessSwap)
 
     auto buffer = serializerWithSwap.finishAndGetBuffer();
 
-    InMemoryDeserializer deserializerWithSwap(buffer, std::is_same<real, double>::value,
+    InMemoryDeserializer deserializerWithSwap(buffer, std::is_same_v<real, double>,
                                               EndianSwapBehavior::Swap);
 
     SerializerValues deserialisedValues = deserialize(&deserializerWithSwap);
@@ -220,7 +220,7 @@ TEST_F(InMemorySerializerTest, SerializerExplicitEndianessSwap)
 
     auto buffer = serializerWithSwap.finishAndGetBuffer();
 
-    InMemoryDeserializer deserializerWithOutSwap(buffer, std::is_same<real, double>::value);
+    InMemoryDeserializer deserializerWithOutSwap(buffer, std::is_same_v<real, double>);
 
     SerializerValues deserialisedValues = deserialize(&deserializerWithOutSwap);
     checkSerializerValuesforEquality(endianessSwappedValues_, deserialisedValues);
@@ -234,7 +234,7 @@ TEST_F(InMemorySerializerTest, DeserializerExplicitEndianessSwap)
 
     auto buffer = serializer.finishAndGetBuffer();
 
-    InMemoryDeserializer deserializerWithSwap(buffer, std::is_same<real, double>::value,
+    InMemoryDeserializer deserializerWithSwap(buffer, std::is_same_v<real, double>,
                                               EndianSwapBehavior::Swap);
 
     SerializerValues deserialisedValues = deserialize(&deserializerWithSwap);