Skip to content

Commit

Permalink
Merge pull request #507 from thelfer/505-remove-usage-of-stdenable_if…
Browse files Browse the repository at this point in the history
…-in-favor-of-the-requires-clause

505 remove usage of stdenable if in favor of the requires clause
  • Loading branch information
thelfer authored Feb 9, 2024
2 parents ec85dea + 6ebbb30 commit 28660fb
Show file tree
Hide file tree
Showing 74 changed files with 3,092 additions and 4,432 deletions.
2 changes: 0 additions & 2 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ install_header(TFEL/Metaprogramming/Forward TypeList.hxx)
install_header(TFEL/Metaprogramming Implements.hxx)
install_header(TFEL/Metaprogramming TypeList.hxx)
install_header(TFEL/Metaprogramming TypeList.ixx)
install_header(TFEL/Metaprogramming IsConstCallable.hxx)
install_header(TFEL/Metaprogramming GenerateTypeList.hxx)
install_header(TFEL/Metaprogramming InvalidType.hxx)
install_header(TFEL/Metaprogramming HasIterator.hxx)
install_header(TFEL/Metaprogramming HasConstIterator.hxx)
install_header(TFEL/Metaprogramming HasRandomAccessConstIterator.hxx)
install_header(TFEL/Metaprogramming EmptyClass.hxx)
install_header(TFEL/Metaprogramming HasRandomAccessIterator.hxx)
install_header(TFEL/Metaprogramming ResultOf.hxx)
install_header(TFEL/Metaprogramming MakeIntegerRange.hxx)

install_header(TFEL/TypeTraits/Promote Promote.ixx)
Expand Down
8 changes: 4 additions & 4 deletions include/TFEL/Config/TFELConfig.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,17 @@
*/
#define TFEL_CONSTEXPR constexpr

#if (defined __CUDACC__) || (defined __HIPPCC__)
#if (defined __CUDACC__) || (defined __HIPCC__)
#ifndef TFEL_DEVICE
#define TFEL_DEVICE __device__
#endif /* TFEL_DEVICE */
#ifndef TFEL_HOST
#define TFEL_HOST __host__
#endif /* TFEL_HOST */
#if (defined __CUDA_ARCH__) || (defined __HIP_ARCH__)
#if (defined __CUDA_ARCH__) || (defined __HIP_DEVICE_COMPILE__)
#define TFEL_NO_REPORT_CONTRACT_VIOLATION 1
#endif /* (defined __CUDA_ARCH__) || (defined __HIP_ARCH__) */
#endif /* (defined __CUDACC__) || (defined __HIPPCC__) */
#endif /* (defined __CUDA_ARCH__) || (defined __HIP_DEVICE_COMPILE__) */
#endif /* (defined __CUDACC__) || (defined __HIPCC__) */

#if defined(__clang__) && defined(__CUDA__) && defined(__CUDA_ARCH__)
#define TFEL_NO_REPORT_CONTRACT_VIOLATION 1
Expand Down
161 changes: 70 additions & 91 deletions include/TFEL/FSAlgorithm/copy.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#ifndef LIB_TFEL_FSALGORITHM_COPY_HXX
#define LIB_TFEL_FSALGORITHM_COPY_HXX

#include "TFEL/Config/TFELConfig.hxx"
#include <type_traits>
#include "TFEL/Config/TFELConfig.hxx"
#include "TFEL/TypeTraits/IsRandomAccessIterator.hxx"

namespace tfel::fsalgo {
Expand Down Expand Up @@ -48,14 +48,14 @@ namespace tfel::fsalgo {
* - InputIterator is a model of Input Iterator.
* - OutputIterator is a model of Output Iterator.
* - InputIterator's value type is convertible to a type in OutputIterator's
* set of value types.
* set of value types.
*
* \author Thomas Helfer
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE OutputIterator exe(InputIterator p,
OutputIterator q) {
TFEL_HOST_DEVICE constexpr static OutputIterator exe(
InputIterator p, OutputIterator q) noexcept {
*q = *p;
return copy<N - 1>::exe(++p, ++q);
}
Expand All @@ -77,8 +77,8 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE OutputIterator exe(InputIterator,
OutputIterator q) {
TFEL_HOST_DEVICE constexpr static OutputIterator exe(
InputIterator, OutputIterator q) noexcept {
return q;
}
};
Expand All @@ -104,8 +104,8 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE OutputIterator exe(InputIterator p,
OutputIterator q) {
TFEL_HOST_DEVICE constexpr static OutputIterator exe(
InputIterator p, OutputIterator q) noexcept {
*q = *p;
return ++q;
}
Expand Down Expand Up @@ -142,11 +142,8 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond,
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
TFEL_HOST_DEVICE constexpr static auto exe(InputIterator p,
OutputIterator q) noexcept {
q[0] = p[0];
q[1] = p[1];
return q + 2;
Expand All @@ -157,11 +154,10 @@ namespace tfel::fsalgo {
* \see copy<N>::exe for details
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
!(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond),
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
*q = *p;
return copy<1u>::exe(++p, ++q);
}
Expand All @@ -180,8 +176,7 @@ namespace tfel::fsalgo {
struct copy<3u> {
/*!
* This version of copy is used if iterators are Random Access. Test is
* based on the tfel::typetraits::IsRandomAccessIterator class. \see
* std::enable_if, tfel::typetraits::IsRandomAccessIterator
* based on the tfel::typetraits::IsRandomAccessIterator class.
*
* \param InputIterator iterator to the element to be copied
* \param OutputIterator iterator to the place where this element will be
Expand All @@ -199,11 +194,10 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond,
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
Expand All @@ -215,11 +209,10 @@ namespace tfel::fsalgo {
* \see copy<N>::exe for details
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
!(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond),
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
*q = *p;
return copy<2u>::exe(++p, ++q);
}
Expand Down Expand Up @@ -256,11 +249,10 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond,
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
Expand All @@ -273,11 +265,10 @@ namespace tfel::fsalgo {
* \see copy<N>::exe for details
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
!(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond),
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
*q = *p;
return copy<3u>::exe(++p, ++q);
}
Expand Down Expand Up @@ -314,11 +305,10 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond,
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
Expand All @@ -332,11 +322,10 @@ namespace tfel::fsalgo {
* \see copy<N>::exe for details
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
!(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond),
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
*q = *p;
return copy<4u>::exe(++p, ++q);
}
Expand Down Expand Up @@ -373,11 +362,10 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond,
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
Expand All @@ -392,11 +380,10 @@ namespace tfel::fsalgo {
* \see copy<N>::exe for details
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
!(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond),
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
*q = *p;
return copy<5u>::exe(++p, ++q);
}
Expand Down Expand Up @@ -433,11 +420,10 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond,
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
Expand All @@ -453,11 +439,10 @@ namespace tfel::fsalgo {
* \see copy<N>::exe for details
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
!(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond),
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
*q = *p;
return copy<6u>::exe(++p, ++q);
}
Expand Down Expand Up @@ -494,11 +479,10 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond,
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
Expand All @@ -515,11 +499,10 @@ namespace tfel::fsalgo {
* \see copy<N>::exe for details
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
!(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond),
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
*q = *p;
return copy<7u>::exe(++p, ++q);
}
Expand Down Expand Up @@ -556,11 +539,10 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond,
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
Expand All @@ -578,11 +560,10 @@ namespace tfel::fsalgo {
* \see copy<N>::exe for details
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
!(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond),
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
*q = *p;
return copy<8u>::exe(++p, ++q);
}
Expand Down Expand Up @@ -619,11 +600,10 @@ namespace tfel::fsalgo {
* \date 30 Jun 2006
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond,
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond&&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond) {
q[0] = p[0];
q[1] = p[1];
q[2] = p[2];
Expand All @@ -642,11 +622,10 @@ namespace tfel::fsalgo {
* \see copy<N>::exe for details
*/
template <typename InputIterator, typename OutputIterator>
static TFEL_FSALGORITHM_INLINE typename std::enable_if<
TFEL_HOST_DEVICE static constexpr auto
exe(InputIterator p, OutputIterator q) noexcept requires(
!(tfel::typetraits::IsRandomAccessIterator<InputIterator>::cond &&
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond),
OutputIterator>::type
exe(InputIterator p, OutputIterator q) {
tfel::typetraits::IsRandomAccessIterator<OutputIterator>::cond)) {
*q = *p;
return copy<9u>::exe(++p, ++q);
}
Expand Down
Loading

0 comments on commit 28660fb

Please sign in to comment.