diff --git a/Eigen/Core b/Eigen/Core index 2fec8f35c..060c92bcd 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -96,6 +96,9 @@ // for std::is_nothrow_move_assignable #include +// for std::move, std::forward, std::declval +#include + // for std::this_thread::yield(). #if !defined(EIGEN_USE_BLAS) && (defined(EIGEN_HAS_OPENMP) || defined(EIGEN_GEMM_THREADPOOL)) #include @@ -139,7 +142,6 @@ #include #include #include -#include #ifndef EIGEN_SYCL_LOCAL_THREAD_DIM0 #define EIGEN_SYCL_LOCAL_THREAD_DIM0 16 #endif diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index 0d701198b..ef1642c54 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -119,9 +119,8 @@ struct evaluator_base { using ExpressionTraits = traits; enum { Alignment = 0 }; - // noncopyable: - // Don't make this class inherit noncopyable as this kills EBO (Empty Base Optimization) - // and make complex evaluator much larger than then should do. + // Spell out deleted copy operations instead of inheriting from an empty helper: + // an extra base can kill EBO and make complex evaluators larger than they should be. EIGEN_DEVICE_FUNC constexpr evaluator_base() = default; evaluator_base(const evaluator_base&) = delete; diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 4b0ca975b..83e22147d 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -1376,7 +1376,7 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double trunc(const double& x) { // T is assumed to be an integer type with a>=0, and b>0 template EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE constexpr T div_ceil(T a, T b) { - using UnsignedT = typename internal::make_unsigned::type; + using UnsignedT = std::make_unsigned_t; EIGEN_STATIC_ASSERT((NumTraits::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES) // Note: explicitly declaring a and b as non-negative values allows the compiler to use better optimizations const UnsignedT ua = UnsignedT(a); @@ -1389,8 +1389,8 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE constexpr T div_ceil(T a, T b) { // T is assumed to be an integer type with a>=0, and b>0 template EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE constexpr T round_down(T a, U b) { - using UnsignedT = typename internal::make_unsigned::type; - using UnsignedU = typename internal::make_unsigned::type; + using UnsignedT = std::make_unsigned_t; + using UnsignedU = std::make_unsigned_t; EIGEN_STATIC_ASSERT((NumTraits::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES) EIGEN_STATIC_ASSERT((NumTraits::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES) // Note: explicitly declaring a and b as non-negative values allows the compiler to use better optimizations diff --git a/Eigen/src/Core/arch/AVX512/TrsmKernel.h b/Eigen/src/Core/arch/AVX512/TrsmKernel.h index 11c0bd73d..fffedb67e 100644 --- a/Eigen/src/Core/arch/AVX512/TrsmKernel.h +++ b/Eigen/src/Core/arch/AVX512/TrsmKernel.h @@ -227,7 +227,7 @@ void gemmKernel(Scalar* A_arr, Scalar* B_arr, Scalar* C_arr, int64_t M, int64_t constexpr int64_t U3 = urolls::PacketSize * 3; constexpr int64_t U2 = urolls::PacketSize * 2; constexpr int64_t U1 = urolls::PacketSize * 1; - using vec = typename std::conditional::value, vecFullFloat, vecFullDouble>::type; + using vec = std::conditional_t::value, vecFullFloat, vecFullDouble>; int64_t N_ = (N / U3) * U3; int64_t M_ = (M / EIGEN_AVX_MAX_NUM_ROW) * EIGEN_AVX_MAX_NUM_ROW; int64_t K_ = (K / EIGEN_AVX_MAX_K_UNROL) * EIGEN_AVX_MAX_K_UNROL; @@ -785,7 +785,7 @@ template void triSolveKernelLxK(Scalar* A_arr, Scalar* B_arr, int64_t M, int64_t K, int64_t LDA, int64_t LDB) { // Note: this assumes EIGEN_AVX_MAX_NUM_ROW = 8. Unrolls should be adjusted // accordingly if EIGEN_AVX_MAX_NUM_ROW is smaller. - using vec = typename std::conditional::value, vecFullFloat, vecFullDouble>::type; + using vec = std::conditional_t::value, vecFullFloat, vecFullDouble>; if (M == 8) triSolveKernel(A_arr, B_arr, K, LDA, LDB); else if (M == 7) @@ -817,7 +817,7 @@ EIGEN_ALWAYS_INLINE void copyBToRowMajor(Scalar* B_arr, int64_t LDB, int64_t K, int64_t remM_ = 0) { EIGEN_UNUSED_VARIABLE(remM_); using urolls = unrolls::transB; - using vecHalf = typename std::conditional::value, vecHalfFloat, vecFullDouble>::type; + using vecHalf = std::conditional_t::value, vecHalfFloat, vecFullDouble>; PacketBlock ymm; constexpr int64_t U3 = urolls::PacketSize * 3; constexpr int64_t U2 = urolls::PacketSize * 2; diff --git a/Eigen/src/Core/arch/AVX512/TrsmUnrolls.inc b/Eigen/src/Core/arch/AVX512/TrsmUnrolls.inc index 3a5f68eba..3ca8b2d24 100644 --- a/Eigen/src/Core/arch/AVX512/TrsmUnrolls.inc +++ b/Eigen/src/Core/arch/AVX512/TrsmUnrolls.inc @@ -129,8 +129,8 @@ EIGEN_ALWAYS_INLINE void trans8x8blocks(PacketBlock &kernel) { template class trans { public: - using vec = typename std::conditional::value, vecFullFloat, vecFullDouble>::type; - using vecHalf = typename std::conditional::value, vecHalfFloat, vecFullDouble>::type; + using vec = std::conditional_t::value, vecFullFloat, vecFullDouble>; + using vecHalf = std::conditional_t::value, vecHalfFloat, vecFullDouble>; static constexpr int64_t PacketSize = packet_traits::size; /*********************************** @@ -281,8 +281,8 @@ class trans { template class transB { public: - using vec = typename std::conditional::value, vecFullFloat, vecFullDouble>::type; - using vecHalf = typename std::conditional::value, vecHalfFloat, vecFullDouble>::type; + using vec = std::conditional_t::value, vecFullFloat, vecFullDouble>; + using vecHalf = std::conditional_t::value, vecHalfFloat, vecFullDouble>; static constexpr int64_t PacketSize = packet_traits::size; /*********************************** @@ -585,7 +585,7 @@ class transB { template class trsm { public: - using vec = typename std::conditional::value, vecFullFloat, vecFullDouble>::type; + using vec = std::conditional_t::value, vecFullFloat, vecFullDouble>; static constexpr int64_t PacketSize = packet_traits::size; /*********************************** @@ -864,7 +864,7 @@ class trsm { template class gemm { public: - using vec = typename std::conditional::value, vecFullFloat, vecFullDouble>::type; + using vec = std::conditional_t::value, vecFullFloat, vecFullDouble>; static constexpr int64_t PacketSize = packet_traits::size; /*********************************** diff --git a/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h b/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h index ab02d320a..4815974b0 100644 --- a/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +++ b/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h @@ -490,7 +490,7 @@ void gemmMMA(const DataMapper& res, const Scalar* blockA, const Scalar* blockB, const Packet pAlpha = pset1(alpha); const Packet pMask = bmask(remaining_rows); - typedef typename std::conditional_t<(sizeof(Scalar) == sizeof(float)), RhsPacket, __vector_pair> RhsPacket2; + typedef std::conditional_t<(sizeof(Scalar) == sizeof(float)), RhsPacket, __vector_pair> RhsPacket2; Index col = 0; #ifdef GEMM_MULTIPLE_COLS @@ -869,7 +869,7 @@ void gemm_complexMMA(const DataMapper& res, const LhsScalar* blockAc, const RhsS const Scalar* blockA = (Scalar*)blockAc; const Scalar* blockB = (Scalar*)blockBc; - typedef typename std::conditional_t<(sizeof(Scalar) == sizeof(float)), RhsPacket, __vector_pair> RhsPacket2; + typedef std::conditional_t<(sizeof(Scalar) == sizeof(float)), RhsPacket, __vector_pair> RhsPacket2; Index col = 0; #ifdef GEMM_MULTIPLE_COLS diff --git a/Eigen/src/Core/arch/GPU/Tuple.h b/Eigen/src/Core/arch/GPU/Tuple.h index 0e7448792..e9b608c1f 100644 --- a/Eigen/src/Core/arch/GPU/Tuple.h +++ b/Eigen/src/Core/arch/GPU/Tuple.h @@ -187,7 +187,7 @@ struct unwrap_reference_wrapper> { // For use in make_tuple, decays a type and unwraps a reference_wrapper. template struct unwrap_decay { - using type = typename unwrap_reference_wrapper::type>::type; + using type = typename unwrap_reference_wrapper>::type; }; /** @@ -223,12 +223,12 @@ constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename tuple_get_impl::type>::value...>::value>> +template >::value...>::value>> constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE - typename tuple_cat_impl::type...>::ReturnType + typename tuple_cat_impl...>::ReturnType tuple_cat(Tuples&&... tuples) { - return tuple_cat_impl::type...>::run(std::forward(tuples)...); + return tuple_cat_impl...>::run(std::forward(tuples)...); } /** diff --git a/Eigen/src/Core/arch/RVV10/PacketMath2.h b/Eigen/src/Core/arch/RVV10/PacketMath2.h index d99a154cc..ccf496b9a 100644 --- a/Eigen/src/Core/arch/RVV10/PacketMath2.h +++ b/Eigen/src/Core/arch/RVV10/PacketMath2.h @@ -262,8 +262,7 @@ EIGEN_DEVICE_FUNC inline void ptranspose(PacketBlock& kernel) { template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet2Xi>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet2Xi> predux_half(const Packet4Xi& a) { return __riscv_vadd_vv_i32m2(__riscv_vget_v_i32m4_i32m2(a, 0), __riscv_vget_v_i32m4_i32m2(a, 1), unpacket_traits::size); @@ -271,8 +270,7 @@ EIGEN_STRONG_INLINE template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet1Xi>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet1Xi> predux_half(const Packet2Xi& a) { return __riscv_vadd_vv_i32m1(__riscv_vget_v_i32m2_i32m1(a, 0), __riscv_vget_v_i32m2_i32m1(a, 1), unpacket_traits::size); @@ -629,8 +627,7 @@ EIGEN_STRONG_INLINE Packet2Xf pldexp(const Packet2Xf& a, const Packet template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet2Xf>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet2Xf> predux_half(const Packet4Xf& a) { return __riscv_vfadd_vv_f32m2(__riscv_vget_v_f32m4_f32m2(a, 0), __riscv_vget_v_f32m4_f32m2(a, 1), unpacket_traits::size); @@ -638,8 +635,7 @@ EIGEN_STRONG_INLINE template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet1Xf>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet1Xf> predux_half(const Packet2Xf& a) { return __riscv_vfadd_vv_f32m1(__riscv_vget_v_f32m2_f32m1(a, 0), __riscv_vget_v_f32m2_f32m1(a, 1), unpacket_traits::size); @@ -889,8 +885,7 @@ EIGEN_DEVICE_FUNC inline void ptranspose(PacketBlock& kernel) { template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet2Xl>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet2Xl> predux_half(const Packet4Xl& a) { return __riscv_vadd_vv_i64m2(__riscv_vget_v_i64m4_i64m2(a, 0), __riscv_vget_v_i64m4_i64m2(a, 1), unpacket_traits::size); @@ -898,8 +893,7 @@ EIGEN_STRONG_INLINE template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet1Xl>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet1Xl> predux_half(const Packet2Xl& a) { return __riscv_vadd_vv_i64m1(__riscv_vget_v_i64m2_i64m1(a, 0), __riscv_vget_v_i64m2_i64m1(a, 1), unpacket_traits::size); @@ -1254,8 +1248,7 @@ EIGEN_STRONG_INLINE Packet2Xd pldexp(const Packet2Xd& a, const Packet template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet2Xd>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet2Xd> predux_half(const Packet4Xd& a) { return __riscv_vfadd_vv_f64m2(__riscv_vget_v_f64m4_f64m2(a, 0), __riscv_vget_v_f64m4_f64m2(a, 1), unpacket_traits::size); @@ -1263,8 +1256,7 @@ EIGEN_STRONG_INLINE template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet1Xd>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet1Xd> predux_half(const Packet2Xd& a) { return __riscv_vfadd_vv_f64m1(__riscv_vget_v_f64m2_f64m1(a, 0), __riscv_vget_v_f64m2_f64m1(a, 1), unpacket_traits::size); @@ -1515,8 +1507,7 @@ EIGEN_DEVICE_FUNC inline void ptranspose(PacketBlock& kernel) { template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet2Xs>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet2Xs> predux_half(const Packet4Xs& a) { return __riscv_vadd_vv_i16m2(__riscv_vget_v_i16m4_i16m2(a, 0), __riscv_vget_v_i16m4_i16m2(a, 1), unpacket_traits::size); @@ -1524,8 +1515,7 @@ EIGEN_STRONG_INLINE template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet1Xs>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet1Xs> predux_half(const Packet2Xs& a) { return __riscv_vadd_vv_i16m1(__riscv_vget_v_i16m2_i16m1(a, 0), __riscv_vget_v_i16m2_i16m1(a, 1), unpacket_traits::size); diff --git a/Eigen/src/Core/arch/RVV10/PacketMathBF16.h b/Eigen/src/Core/arch/RVV10/PacketMathBF16.h index 2522efd99..8e15b21a4 100644 --- a/Eigen/src/Core/arch/RVV10/PacketMathBF16.h +++ b/Eigen/src/Core/arch/RVV10/PacketMathBF16.h @@ -806,10 +806,9 @@ EIGEN_DEVICE_FUNC inline void ptranspose(PacketBlock& kernel) { } template -EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet1Xbf>::type - predux_half(const Packet2Xbf& a) { +EIGEN_STRONG_INLINE std::enable_if_t< + std::is_same::value && (unpacket_traits::size % 8) == 0, Packet1Xbf> +predux_half(const Packet2Xbf& a) { return padd(__riscv_vget_v_bf16m2_bf16m1(a, 0), __riscv_vget_v_bf16m2_bf16m1(a, 1)); } diff --git a/Eigen/src/Core/arch/RVV10/PacketMathFP16.h b/Eigen/src/Core/arch/RVV10/PacketMathFP16.h index 73118a31c..b1113c9d1 100644 --- a/Eigen/src/Core/arch/RVV10/PacketMathFP16.h +++ b/Eigen/src/Core/arch/RVV10/PacketMathFP16.h @@ -886,8 +886,7 @@ EIGEN_STRONG_INLINE Packet2Xh float2half(const Packet4Xf& a) { template EIGEN_STRONG_INLINE - typename std::enable_if::value && (unpacket_traits::size % 8) == 0, - Packet1Xh>::type + std::enable_if_t::value && (unpacket_traits::size % 8) == 0, Packet1Xh> predux_half(const Packet2Xh& a) { return __riscv_vfadd_vv_f16m1(__riscv_vget_v_f16m2_f16m1(a, 0), __riscv_vget_v_f16m2_f16m1(a, 1), unpacket_traits::size); diff --git a/Eigen/src/Core/products/SelfadjointRank2Update.h b/Eigen/src/Core/products/SelfadjointRank2Update.h index d052dfba5..165875ff4 100644 --- a/Eigen/src/Core/products/SelfadjointRank2Update.h +++ b/Eigen/src/Core/products/SelfadjointRank2Update.h @@ -188,7 +188,7 @@ struct selfadjoint_rank2_update_selector { template using conj_expr_if = - std::conditional::Scalar>, T>>; + std::conditional_t::Scalar>, T>>; } // end namespace internal diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index 233e58f88..705913986 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -160,7 +160,7 @@ template class RefBase; template , OuterStride<>>> + std::conditional_t, OuterStride<>>> class Ref; template > class CwiseUnaryView; diff --git a/Eigen/src/Core/util/IndexedViewHelper.h b/Eigen/src/Core/util/IndexedViewHelper.h index 82dd8a5e2..1c9e35d67 100644 --- a/Eigen/src/Core/util/IndexedViewHelper.h +++ b/Eigen/src/Core/util/IndexedViewHelper.h @@ -434,9 +434,8 @@ struct VectorIndexedViewSelector< using ColMajorReturnType = IndexedView, ZeroIndex>; using ConstColMajorReturnType = IndexedView, ZeroIndex>; - using ReturnType = typename internal::conditional::type; - using ConstReturnType = - typename internal::conditional::type; + using ReturnType = std::conditional_t; + using ConstReturnType = std::conditional_t; template = true> static inline RowMajorReturnType run(Derived& derived, const Indices& indices) { diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index e51fe38b3..c08489a7d 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -729,12 +729,12 @@ // // With MSVC, without defining /Zc:__cplusplus, the __cplusplus macro will // report 199711L regardless of the language standard specified via /std. -// We need to rely on _MSVC_LANG instead, which is only available after -// VS2015.3. +// We need to rely on _MSVC_LANG instead where available. Older MSVC versions +// supported by Eigen do not define _MSVC_LANG, so use Eigen's minimum standard. #if EIGEN_COMP_MSVC_LANG > 0 #define EIGEN_CPLUSPLUS EIGEN_COMP_MSVC_LANG #elif EIGEN_COMP_MSVC >= 1900 -#define EIGEN_CPLUSPLUS 201103L +#define EIGEN_CPLUSPLUS 201402L #elif defined(__cplusplus) #define EIGEN_CPLUSPLUS __cplusplus #else @@ -750,10 +750,8 @@ #define EIGEN_COMP_CXXVER 17 #elif EIGEN_CPLUSPLUS >= 201402L #define EIGEN_COMP_CXXVER 14 -#elif EIGEN_CPLUSPLUS >= 201103L -#define EIGEN_COMP_CXXVER 11 #else -#define EIGEN_COMP_CXXVER 03 +#define EIGEN_COMP_CXXVER 0 #endif // The macros EIGEN_HAS_CXX?? defines a rough estimate of available c++ features diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 87b52429a..c52137d5f 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -634,11 +634,6 @@ struct smart_memmove_helper { } }; -template -EIGEN_DEVICE_FUNC T* smart_move(T* start, T* end, T* target) { - return std::move(start, end, target); -} - /***************************************************************************** *** Implementation of runtime stack allocation (falling back to malloc) *** *****************************************************************************/ @@ -665,8 +660,11 @@ EIGEN_DEVICE_FUNC T* smart_move(T* start, T* end, T* target) { // This helper class construct the allocated memory, and takes care of destructing and freeing the handled data // at destruction time. In practice this helper class is mainly useful to avoid memory leak in case of exceptions. template -class aligned_stack_memory_handler : noncopyable { +class aligned_stack_memory_handler { public: + aligned_stack_memory_handler(const aligned_stack_memory_handler&) = delete; + aligned_stack_memory_handler& operator=(const aligned_stack_memory_handler&) = delete; + /* Creates a stack_memory_handler responsible for the buffer \a ptr of size \a size. * Note that \a ptr can be 0 regardless of the other parameters. * This constructor takes care of constructing/initializing the elements of the buffer if required by the scalar type @@ -733,25 +731,6 @@ struct local_nested_eval_wrapper { #endif // EIGEN_ALLOCA -template -class scoped_array : noncopyable { - T* m_ptr; - - public: - explicit scoped_array(std::ptrdiff_t size) { m_ptr = new T[size]; } - ~scoped_array() { delete[] m_ptr; } - T& operator[](std::ptrdiff_t i) { return m_ptr[i]; } - const T& operator[](std::ptrdiff_t i) const { return m_ptr[i]; } - T*& ptr() { return m_ptr; } - const T* ptr() const { return m_ptr; } - operator const T*() const { return m_ptr; } -}; - -template -void swap(scoped_array& a, scoped_array& b) { - std::swap(a.ptr(), b.ptr()); -} - } // end namespace internal /** \internal diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 848d90ddc..d78df80c1 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -196,18 +196,6 @@ using add_const_on_value_type_t = typename add_const_on_value_type::type; using std::is_convertible; -/** \internal - * A base class do disable default copy ctor and copy assignment operator. - */ -class noncopyable { - EIGEN_DEVICE_FUNC noncopyable(const noncopyable&); - EIGEN_DEVICE_FUNC const noncopyable& operator=(const noncopyable&); - - protected: - EIGEN_DEVICE_FUNC noncopyable() {} - EIGEN_DEVICE_FUNC ~noncopyable() {} -}; - /** \internal * Provides access to the number of elements in the object of as a compile-time constant expression. * It "returns" Eigen::Dynamic if the size cannot be resolved at compile-time (default). @@ -301,24 +289,12 @@ struct result_of { typedef typename std::invoke_result::type type1; typedef remove_all_t type; }; - -template -struct invoke_result { - typedef typename std::invoke_result::type type1; - typedef remove_all_t type; -}; #else template struct result_of { typedef typename std::result_of::type type1; typedef remove_all_t type; }; - -template -struct invoke_result { - typedef typename result_of::type type1; - typedef remove_all_t type; -}; #endif // Reduces a sequence of bools to true if all are true, false otherwise. @@ -326,82 +302,35 @@ template using reduce_all = std::is_same, std::integer_sequence>; -// Reduces a sequence of bools to true if any are true, false if all false. -template -using reduce_any = std::integral_constant, - std::integer_sequence>::value>; - -struct meta_yes { - char a[1]; -}; -struct meta_no { - char a[2]; -}; - // Check whether T::ReturnType does exist -template -struct has_ReturnType { - template - static meta_yes testFunctor(C const*, typename C::ReturnType const* = 0); - template - static meta_no testFunctor(...); - - enum { value = sizeof(testFunctor(static_cast(0))) == sizeof(meta_yes) }; -}; +template +struct has_ReturnType : false_type {}; template -const T* return_ptr(); +struct has_ReturnType> : true_type {}; -template -struct has_nullary_operator { - template - static meta_yes testFunctor(C const*, std::enable_if_t<(sizeof(return_ptr()->operator()()) > 0)>* = 0); - static meta_no testFunctor(...); +template +struct has_nullary_operator : false_type {}; - enum { value = sizeof(testFunctor(static_cast(0))) == sizeof(meta_yes) }; -}; +template +struct has_nullary_operator()())) > 0)>> + : true_type {}; -template -struct has_unary_operator { - template - static meta_yes testFunctor(C const*, std::enable_if_t<(sizeof(return_ptr()->operator()(IndexType(0))) > 0)>* = 0); - static meta_no testFunctor(...); +template +struct has_unary_operator : false_type {}; - enum { value = sizeof(testFunctor(static_cast(0))) == sizeof(meta_yes) }; -}; +template +struct has_unary_operator()(IndexType(0)))) > 0)>> + : true_type {}; -template -struct has_binary_operator { - template - static meta_yes testFunctor( - C const*, std::enable_if_t<(sizeof(return_ptr()->operator()(IndexType(0), IndexType(0))) > 0)>* = 0); - static meta_no testFunctor(...); +template +struct has_binary_operator : false_type {}; - enum { value = sizeof(testFunctor(static_cast(0))) == sizeof(meta_yes) }; -}; - -/** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer. - * Usage example: \code meta_sqrt<1023>::ret \endcode - */ -template Y)))> -class meta_sqrt { - enum { - MidX = (InfX + SupX) / 2, - TakeInf = MidX * MidX > Y ? 1 : 0, - NewInf = int(TakeInf) ? InfX : int(MidX), - NewSup = int(TakeInf) ? int(MidX) : SupX - }; - - public: - enum { ret = meta_sqrt::ret }; -}; - -template -class meta_sqrt { - public: - enum { ret = (SupX * SupX <= Y) ? SupX : InfX }; -}; +template +struct has_binary_operator< + T, IndexType, std::enable_if_t<(sizeof(decltype(std::declval()(IndexType(0), IndexType(0)))) > 0)>> + : true_type {}; /** \internal Computes the least common multiple of two positive integer A and B * at compile-time. @@ -469,7 +398,7 @@ struct equal_strict_impl { // X is an unsigned integer // Y is a signed integer // if Y is non-negative, it may be represented exactly as its unsigned counterpart. - using UnsignedY = typename internal::make_unsigned::type; + using UnsignedY = std::make_unsigned_t; static constexpr EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool run(const X& x, const Y& y) { return y < Y(0) ? false : (x == static_cast(y)); } @@ -636,20 +565,6 @@ constexpr bool enum_lt_not_dynamic(A a, B b) { return (int)a < (int)b; } -template -constexpr bool enum_le_not_dynamic(A a, B b) { - plain_enum_asserts(a, b); - if ((int)a == Dynamic || (int)b == Dynamic) return false; - return (int)a <= (int)b; -} - -template -constexpr bool enum_gt_not_dynamic(A a, B b) { - plain_enum_asserts(a, b); - if ((int)a == Dynamic || (int)b == Dynamic) return false; - return (int)a > (int)b; -} - template constexpr bool enum_ge_not_dynamic(A a, B b) { plain_enum_asserts(a, b); diff --git a/Eigen/src/Core/util/MoreMeta.h b/Eigen/src/Core/util/MoreMeta.h index a20506e34..4f831670b 100644 --- a/Eigen/src/Core/util/MoreMeta.h +++ b/Eigen/src/Core/util/MoreMeta.h @@ -368,64 +368,15 @@ struct logical_and_op { return a && b; } }; -struct logical_or_op { - template - constexpr static auto run(A a, B b) -> decltype(a || b) { - return a || b; - } -}; - -struct equal_op { - template - constexpr static auto run(A a, B b) -> decltype(a == b) { - return a == b; - } -}; -struct not_equal_op { - template - constexpr static auto run(A a, B b) -> decltype(a != b) { - return a != b; - } -}; struct lesser_op { template constexpr static auto run(A a, B b) -> decltype(a < b) { return a < b; } }; -struct lesser_equal_op { - template - constexpr static auto run(A a, B b) -> decltype(a <= b) { - return a <= b; - } -}; -struct greater_op { - template - constexpr static auto run(A a, B b) -> decltype(a > b) { - return a > b; - } -}; -struct greater_equal_op { - template - constexpr static auto run(A a, B b) -> decltype(a >= b) { - return a >= b; - } -}; /* generic unary operations */ -struct not_op { - template - constexpr static auto run(A a) -> decltype(!a) { - return !a; - } -}; -struct negation_op { - template - constexpr static auto run(A a) -> decltype(-a) { - return -a; - } -}; struct greater_equal_zero_op { template constexpr static auto run(A a) -> decltype(a >= 0) { diff --git a/Eigen/src/SparseCore/CompressedStorage.h b/Eigen/src/SparseCore/CompressedStorage.h index 8f8a6963a..30bd8ad2f 100644 --- a/Eigen/src/SparseCore/CompressedStorage.h +++ b/Eigen/src/SparseCore/CompressedStorage.h @@ -72,10 +72,9 @@ class CompressedStorage { void resize(Index size, double reserveSizeFactor = 0) { if (m_allocatedSize < size) { // Avoid underflow on the std::min call by choosing the smaller index type. - using SmallerIndexType = - typename std::conditional((std::numeric_limits::max)()) < - static_cast((std::numeric_limits::max)()), - Index, StorageIndex>::type; + using SmallerIndexType = std::conditional_t((std::numeric_limits::max)()) < + static_cast((std::numeric_limits::max)()), + Index, StorageIndex>; Index realloc_size = (std::min)(NumTraits::highest(), size + Index(reserveSizeFactor * double(size))); if (realloc_size < size) internal::throw_std_bad_alloc(); diff --git a/Eigen/src/SparseCore/SparseMatrixBase.h b/Eigen/src/SparseCore/SparseMatrixBase.h index acdaf9366..514107ee2 100644 --- a/Eigen/src/SparseCore/SparseMatrixBase.h +++ b/Eigen/src/SparseCore/SparseMatrixBase.h @@ -225,7 +225,7 @@ class SparseMatrixBase : public EigenBase { #ifndef EIGEN_NO_IO friend std::ostream& operator<<(std::ostream& s, const SparseMatrixBase& m) { using Nested = typename Derived::Nested; - using NestedCleaned = typename internal::remove_all::type; + using NestedCleaned = internal::remove_all_t; if (Flags & RowMajorBit) { Nested nm(m.derived()); diff --git a/Eigen/src/SparseCore/SparseSolverBase.h b/Eigen/src/SparseCore/SparseSolverBase.h index acf1564a9..a1ed4ba11 100644 --- a/Eigen/src/SparseCore/SparseSolverBase.h +++ b/Eigen/src/SparseCore/SparseSolverBase.h @@ -64,14 +64,17 @@ std::enable_if_t so * */ template -class SparseSolverBase : internal::noncopyable { +class SparseSolverBase { public: /** Default constructor */ SparseSolverBase() : m_isInitialized(false) {} - SparseSolverBase(SparseSolverBase&& other) : internal::noncopyable{}, m_isInitialized{other.m_isInitialized} {} + SparseSolverBase(const SparseSolverBase&) = delete; + SparseSolverBase& operator=(const SparseSolverBase&) = delete; - ~SparseSolverBase() {} + SparseSolverBase(SparseSolverBase&& other) : m_isInitialized{other.m_isInitialized} {} + + ~SparseSolverBase() = default; Derived& derived() { return *static_cast(this); } const Derived& derived() const { return *static_cast(this); } diff --git a/blas/GeneralRank1Update.h b/blas/GeneralRank1Update.h index e6c3cab10..48cba9785 100644 --- a/blas/GeneralRank1Update.h +++ b/blas/GeneralRank1Update.h @@ -21,7 +21,7 @@ template struct general_rank1_update { static void run(Index rows, Index cols, Scalar* mat, Index stride, const Scalar* u, const Scalar* v, Scalar alpha) { typedef Map > OtherMap; - typedef typename conj_expr_if::type ConjRhsType; + typedef conj_expr_if ConjRhsType; conj_if cj; for (Index i = 0; i < cols; ++i) diff --git a/blas/PackedSelfadjointProduct.h b/blas/PackedSelfadjointProduct.h index 5109960fb..6e8c70d01 100644 --- a/blas/PackedSelfadjointProduct.h +++ b/blas/PackedSelfadjointProduct.h @@ -24,7 +24,7 @@ struct selfadjoint_packed_rank1_update::Real RealScalar; static void run(Index size, Scalar* mat, const Scalar* vec, RealScalar alpha) { typedef Map > OtherMap; - typedef typename conj_expr_if::type ConjRhsType; + typedef conj_expr_if ConjRhsType; conj_if cj; for (Index i = 0; i < size; ++i) { diff --git a/blas/PackedTriangularMatrixVector.h b/blas/PackedTriangularMatrixVector.h index 4e8e085c0..5b9267043 100644 --- a/blas/PackedTriangularMatrixVector.h +++ b/blas/PackedTriangularMatrixVector.h @@ -28,7 +28,7 @@ struct packed_triangular_matrix_vector_product cj; typedef Map > LhsMap; - typedef typename conj_expr_if::type ConjLhsType; + typedef conj_expr_if ConjLhsType; typedef Map > ResMap; for (Index i = 0; i < size; ++i) { @@ -56,9 +56,9 @@ struct packed_triangular_matrix_vector_product cj; typedef Map > LhsMap; - typedef typename conj_expr_if::type ConjLhsType; + typedef conj_expr_if ConjLhsType; typedef Map > RhsMap; - typedef typename conj_expr_if::type ConjRhsType; + typedef conj_expr_if ConjRhsType; for (Index i = 0; i < size; ++i) { Index s = !IsLower && (HasUnitDiag || HasZeroDiag) ? 1 : 0; diff --git a/blas/PackedTriangularSolverVector.h b/blas/PackedTriangularSolverVector.h index 92964fb08..76a828ad8 100644 --- a/blas/PackedTriangularSolverVector.h +++ b/blas/PackedTriangularSolverVector.h @@ -23,7 +23,7 @@ struct packed_triangular_solve_vector cj; typedef Map > LhsMap; - typedef typename conj_expr_if::type ConjLhsType; + typedef conj_expr_if ConjLhsType; lhs += IsLower ? 0 : (size * (size + 1) >> 1) - 1; for (Index pi = 0; pi < size; ++pi) { @@ -46,7 +46,7 @@ struct packed_triangular_solve_vector cj; typedef Map > LhsMap; - typedef typename conj_expr_if::type ConjLhsType; + typedef conj_expr_if ConjLhsType; lhs += IsLower ? 0 : size * (size - 1) >> 1; for (Index pi = 0; pi < size; ++pi) { diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp index dd39cf165..2e74e2eb0 100644 --- a/test/array_cwise.cpp +++ b/test/array_cwise.cpp @@ -1329,8 +1329,8 @@ struct cast_tests_impl { template = ScalarTupleSize - 1) || (j >= ScalarTupleSize)> static std::enable_if_t run() { - using Type1 = typename std::tuple_element::type; - using Type2 = typename std::tuple_element::type; + using Type1 = std::tuple_element_t; + using Type2 = std::tuple_element_t; cast_test_impl::run(); cast_test_impl::run(); static constexpr size_t next_i = (j == ScalarTupleSize - 1) ? (i + 1) : (i + 0); diff --git a/test/gpu_common.h b/test/gpu_common.h index 0e7c6058c..4e2085076 100644 --- a/test/gpu_common.h +++ b/test/gpu_common.h @@ -51,9 +51,9 @@ void run_on_gpu(const Kernel& ker, int n, const Input& in, Output& out) { gpuDeviceSynchronize(); #ifdef EIGEN_USE_HIP - hipLaunchKernelGGL(HIP_KERNEL_NAME(run_on_gpu_meta_kernel::type, - typename std::decay::type>), - dim3(Grids), dim3(Blocks), 0, 0, ker, n, d_in, d_out); + hipLaunchKernelGGL( + HIP_KERNEL_NAME(run_on_gpu_meta_kernel, std::decay_t>), + dim3(Grids), dim3(Blocks), 0, 0, ker, n, d_in, d_out); #else // Various versions of clang-format incorrectly add spaces to the kernel launch brackets. // clang-format off diff --git a/test/gpu_test_helper.h b/test/gpu_test_helper.h index 80960eb31..15a05e603 100644 --- a/test/gpu_test_helper.h +++ b/test/gpu_test_helper.h @@ -40,9 +40,6 @@ using tuple_impl::tuple; #undef EIGEN_USE_CUSTOM_TUPLE } // namespace test_detail -template -using decay_t = typename std::decay::type; - template using kernel_result_t = decltype(std::declval()(std::declval()...)); @@ -64,10 +61,10 @@ template , T1, Ts...> { using type = typename extract_output_indices_helper< N - 1, Idx + 1, - typename std::conditional< + std::conditional_t< // If is a non-const l-value reference, append index. std::is_lvalue_reference::value && !std::is_const>::value, - std::index_sequence, std::index_sequence>::type, + std::index_sequence, std::index_sequence>, Ts...>::type; }; @@ -89,7 +86,7 @@ struct void_helper { // Converts void -> Void, T otherwise. template - using ReturnType = typename std::conditional::value, Void, T>::type; + using ReturnType = std::conditional_t::value, Void, T>; // Non-void return value. template @@ -109,9 +106,8 @@ struct void_helper { // Restores the original return type, Void -> void, T otherwise. template - static EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC - std::enable_if_t::type, Void>::value, T> - restore(T&& val) { + static EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC std::enable_if_t, Void>::value, T> restore( + T&& val) { return val; } @@ -140,18 +136,18 @@ EIGEN_DEVICE_FUNC void run_serialized(std::index_sequence, std::inde const uint8_t* read_end = buffer + capacity; read_ptr = Eigen::deserialize(read_ptr, read_end, input_size); // Create value-type instances to populate. - auto args = make_tuple(decay_t{}...); + auto args = make_tuple(std::decay_t{}...); EIGEN_UNUSED_VARIABLE(args); // Avoid NVCC compile warning. // NVCC 9.1 requires us to spell out the template parameters explicitly. - read_ptr = Eigen::deserialize(read_ptr, read_end, get...>(args)...); + read_ptr = Eigen::deserialize(read_ptr, read_end, get...>(args)...); // Call function, with void->Void conversion so we are guaranteed a complete // output type. - auto result = void_helper::call(kernel, get...>(args)...); + auto result = void_helper::call(kernel, get...>(args)...); // Determine required output size. size_t output_size = Eigen::serialize_size(capacity); - output_size += Eigen::serialize_size(get...>(args)...); + output_size += Eigen::serialize_size(get...>(args)...); output_size += Eigen::serialize_size(result); // Always serialize required buffer size. @@ -162,7 +158,7 @@ EIGEN_DEVICE_FUNC void run_serialized(std::index_sequence, std::inde // Serialize outputs if they fit in the buffer. if (output_size <= capacity) { // Collect outputs and result. - write_ptr = Eigen::serialize(write_ptr, write_end, get...>(args)...); + write_ptr = Eigen::serialize(write_ptr, write_end, get...>(args)...); write_ptr = Eigen::serialize(write_ptr, write_end, result); } } diff --git a/test/main.h b/test/main.h index b429572b7..1f6857217 100644 --- a/test/main.h +++ b/test/main.h @@ -52,10 +52,8 @@ #include #include #include -#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) #include #include -#endif #if __cplusplus > 201703L // libstdc++ 9's indirectly uses max() via . // libstdc++ 10's indirectly uses max() via ranges headers. diff --git a/test/meta.cpp b/test/meta.cpp index 7c0934801..d79a01c58 100644 --- a/test/meta.cpp +++ b/test/meta.cpp @@ -111,25 +111,6 @@ EIGEN_DECLARE_TEST(meta) { VERIFY((internal::has_ReturnType>::value)); VERIFY((!internal::has_ReturnType::value)); VERIFY((!internal::has_ReturnType::value)); - - VERIFY(internal::meta_sqrt<1>::ret == 1); -#define VERIFY_META_SQRT(X) VERIFY(internal::meta_sqrt::ret == int(std::sqrt(double(X)))) - VERIFY_META_SQRT(2); - VERIFY_META_SQRT(3); - VERIFY_META_SQRT(4); - VERIFY_META_SQRT(5); - VERIFY_META_SQRT(6); - VERIFY_META_SQRT(8); - VERIFY_META_SQRT(9); - VERIFY_META_SQRT(15); - VERIFY_META_SQRT(16); - VERIFY_META_SQRT(17); - VERIFY_META_SQRT(255); - VERIFY_META_SQRT(256); - VERIFY_META_SQRT(257); - VERIFY_META_SQRT(1023); - VERIFY_META_SQRT(1024); - VERIFY_META_SQRT(1025); } using Eigen::internal::apply_op_from_left; diff --git a/test/packetmath.cpp b/test/packetmath.cpp index 009152580..f36e6d559 100644 --- a/test/packetmath.cpp +++ b/test/packetmath.cpp @@ -872,7 +872,7 @@ void packetmath_real() { test::packet_helper h; data1[0] = Scalar{-0}; h.store(data2, internal::pnegate(h.load(data1))); - typedef typename internal::make_unsigned::type>::type Bits; + typedef std::make_unsigned_t::type> Bits; Bits bits = numext::bit_cast(data2[0]); VERIFY_IS_EQUAL(bits, static_cast(Bits(1) << (sizeof(Scalar) * CHAR_BIT - 1))); } diff --git a/unsupported/Eigen/src/AutoDiff/CoherentPadOp.h b/unsupported/Eigen/src/AutoDiff/CoherentPadOp.h index 696ef5b3a..68f8b0a38 100644 --- a/unsupported/Eigen/src/AutoDiff/CoherentPadOp.h +++ b/unsupported/Eigen/src/AutoDiff/CoherentPadOp.h @@ -22,7 +22,7 @@ struct CoherentPadOp; template struct traits> : public traits { - typedef typename internal::remove_all::type PlainXprType; + typedef internal::remove_all_t PlainXprType; typedef typename internal::ref_selector::type XprNested; typedef typename std::remove_reference_t XprNested_; enum : int { diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h b/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h index 4266495fd..ee77e8871 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h @@ -86,7 +86,7 @@ class MatrixPowerParenthesesReturnValue : public ReturnByValue -class MatrixPowerAtomic : internal::noncopyable { +class MatrixPowerAtomic { private: enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime }; typedef typename MatrixType::Scalar Scalar; @@ -107,6 +107,9 @@ class MatrixPowerAtomic : internal::noncopyable { static RealScalar computeSuperDiag(RealScalar, RealScalar, RealScalar p); public: + MatrixPowerAtomic(const MatrixPowerAtomic&) = delete; + MatrixPowerAtomic& operator=(const MatrixPowerAtomic&) = delete; + /** * \brief Constructor. * @@ -340,12 +343,15 @@ inline typename MatrixPowerAtomic::RealScalar MatrixPowerAtomic -class MatrixPower : internal::noncopyable { +class MatrixPower { private: typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; public: + MatrixPower(const MatrixPower&) = delete; + MatrixPower& operator=(const MatrixPower&) = delete; + /** * \brief Constructor. *