/*
* 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.
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())
{
}
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.
+++ /dev/null
-/*
- * 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
/*
* 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.
#include <climits>
#include <algorithm>
+#include <utility>
#include <vector>
-#include "gromacs/compat/utility.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/exceptions.h"
* \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
*
*
* \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())
* \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.
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;
/*
* 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.
* \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)
* \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)
* \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;
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_;
// 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...);
}
/*
* 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.
{
}
//! 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();
/*
* 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.
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());
//! 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());
// 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.
/*
* 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.
* \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())
{
}
* \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())
{
}
* \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));
*/
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
{
// 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();
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;
};
* \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());
}
* 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());
}
* \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());
}
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);
}
{
private:
using non_const_T = std::remove_const_t<T>;
- using pointer = typename SimdTraits<T>::type*;
+ using pointer = SimdTraitsT<T>*;
public:
//! \brief Constructor
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)
//! 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.
"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()))
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.
/*
* 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.
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
/*
* 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.
* 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;
/*
* 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.
*
* \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)))
{
}
// 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)
{
}
* 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())
{
}
* \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;
/*
* 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.
/*! \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;
}
* 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);
/*
* 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.
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...));
}
/*
* 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.
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
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()));
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_
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)));
}
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)));
}
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(). */
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);
}
/*! \} */
/*
* 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.
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);
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_) };
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_)
};
};
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);
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);
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);
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);