diff --git a/hydra/Convolution.h b/hydra/Convolution.h index 9bfda561b..29bc07c3f 100644 --- a/hydra/Convolution.h +++ b/hydra/Convolution.h @@ -49,6 +49,8 @@ #endif #include #include +#include +#include #if HYDRA_DEVICE_SYSTEM == CUDA #define TYPE typename std::conditional< std::is_convertible,hydra::thrust::system::cuda::tag >::value, std::integral_constant,std::integral_constant>::type @@ -65,10 +67,8 @@ template,std::integral_constant>::type, typename GPU_DATA = TAG> -inline typename std::enable_if::value && hydra::detail::is_iterable::value - // && (USING_CUDA_BACKEND::value == USING_CUFFT::value) - // && (USING_CUDA_BACKEND::value == GPU_DATA::value), -,void>::type +requires (std::floating_point && hydra::detail::Iterable) +inline void convolute(detail::BackendPolicy policy, detail::FFTPolicy fft_policy, Functor const& functor, Kernel const& kernel, T min, T max, Iterable&& output, bool power_up=true ){ diff --git a/hydra/Decays.h b/hydra/Decays.h index 1a08af453..8f4b3fe32 100644 --- a/hydra/Decays.h +++ b/hydra/Decays.h @@ -39,6 +39,8 @@ #include #include #include +#include +#include namespace hydra { @@ -239,11 +241,11 @@ public : } template - typename std::enable_if< - detail::is_hydra_functor::value || - detail::is_hydra_lambda::value || - detail::is_hydra_composite_functor::value, - PhaseSpaceReweight >::type + requires ( + detail::HydraCallable || + detail::HydraCompositeFunctor + ) + PhaseSpaceReweight GetEventWeightFunctor(Functor const& functor) const { return PhaseSpaceReweight(functor ,fMotherMass, fMasses ); @@ -253,11 +255,11 @@ public : Unweight(size_t seed=0x180ec6d33cfd0aba); template - typename std::enable_if< - detail::is_hydra_functor::value || - detail::is_hydra_lambda::value || - detail::is_hydra_composite_functor::value , - hydra::Range>::type + requires ( + detail::HydraCallable || + detail::HydraCompositeFunctor + ) + hydra::Range Unweight( Functor const& functor, double weight=-1.0, size_t seed=0x39abdc4529b1661c); /** @@ -284,9 +286,9 @@ public : } template + requires (hydra::detail::Iterable && ...) auto Meld( Iterables&&... iterable) - -> typename std::enable_if< detail::all_true::value...>::value, - decltype(std::declval().meld( std::forward(iterable) ...)) >::type + -> decltype(std::declval().meld( std::forward(iterable) ...)) { return fDecays.meld(std::forward(iterable)... ); @@ -367,7 +369,8 @@ public : } template - typename std::enable_if::value, void>::type + requires (hydra::detail::Iterable) + void insert(iterator position, Iterable range) { fDecays.insert( position, range); diff --git a/hydra/DenseHistogram.h b/hydra/DenseHistogram.h index 7e9784af9..4a1a1ad4e 100644 --- a/hydra/DenseHistogram.h +++ b/hydra/DenseHistogram.h @@ -44,6 +44,8 @@ #include #include #include +#include +#include namespace hydra { @@ -51,8 +53,8 @@ namespace hydra { /** * \ingroup histogram */ -template< typename T, std::size_t N, typename BACKEND, typename = typename detail::dimensionality::type, - typename = typename std::enable_if::value, void>::type> +template< typename T, size_t N, typename BACKEND, typename = typename detail::dimensionality::type> +requires (std::is_arithmetic::value) class DenseHistogram; /** @@ -107,7 +109,8 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens fContents.resize(fNBins +2); } - template::value, void>::type> + template + requires (std::integral) DenseHistogram( std::array grid, std::array const& lowerlimits, std::array const& upperlimits): fNBins(1) { @@ -121,7 +124,8 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens fContents.resize(fNBins +2 ); } - template::value, void>::type> + template + requires (std::integral) DenseHistogram( Int (&grid)[N], double (&lowerlimits)[N], double (&upperlimits)[N] ): fNBins(1) { @@ -268,8 +272,8 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens return bin; } - template::value, void>::type> + template + requires (std::integral) inline size_t GetBin( Int (&bins)[N]){ size_t bin=0; @@ -279,8 +283,8 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens return bin; } - template::value, void>::type> + template + requires (std::integral) inline size_t GetBin( std::array const& bins){ size_t bin=0; @@ -300,15 +304,15 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens get_indexes(globalbin, bins); } - template::value, void>::type> + template + requires (std::integral) inline void GetIndexes(size_t globalbin, Int (&bins)[N]){ get_indexes(globalbin, bins); } - template::value, void>::type> + template + requires (std::integral) inline void GetIndexes(size_t globalbin, std::array& bins){ get_indexes(globalbin, bins); @@ -338,8 +342,8 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens std::numeric_limits::max(); } - template::value, void>::type> + template + requires (std::integral) inline double GetBinContent( Int (&bins)[N]){ size_t bin=0; @@ -351,8 +355,8 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens std::numeric_limits::max(); } - template::value, void>::type> + template + requires (std::integral) inline double GetBinContent( std::array const& bins){ size_t bin=0; @@ -412,15 +416,18 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens template - inline typename std::enable_if< M==2, T >::type + requires (M==2) + inline T Interpolate( std::array const& point); template - inline typename std::enable_if< M==3, T >::type + requires (M==3) + inline T Interpolate( std::array const& point); template - inline typename std::enable_if< M==4, T >::type + requires (M==4) + inline T Interpolate( std::array const& point); //stl range interface @@ -467,16 +474,15 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens Fill(Iterator1 begin, Iterator1 end, Iterator2 wbegin); template - inline typename std::enable_if< hydra::detail::is_iterable::value, - DenseHistogram, detail::multidimensional>&>::type + requires (hydra::detail::Iterable) + inline DenseHistogram, detail::multidimensional>& Fill(Iterable& container){ return this->Fill( container.begin(), container.end()); } template - inline typename std::enable_if< hydra::detail::is_iterable::value - && hydra::detail::is_iterable::value, - DenseHistogram, detail::multidimensional>& >::type + requires (hydra::detail::Iterable && hydra::detail::Iterable) + inline DenseHistogram, detail::multidimensional>& Fill(Iterable1& container, Iterable2& wbegin){ return this->Fill( container.begin(), container.end(), wbegin.begin()); } @@ -496,11 +502,13 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens //k = i_1*(dim_2*...*dim_n) + i_2*(dim_3*...*dim_n) + ... + i_{n-1}*dim_n + i_n template - typename hydra::thrust::detail::enable_if< (I== N) && std::is_integral::value, void>::type + requires ((I== N) && std::integral) + void get_global_bin(const Int (&)[N], size_t&){ } template - typename hydra::thrust::detail::enable_if< (I< N) && std::is_integral::value, void>::type + requires ((I< N) && std::integral) + void get_global_bin(const Int (&indexes)[N], size_t& index) { size_t prod =1; @@ -512,11 +520,13 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens } template - typename hydra::thrust::detail::enable_if< (I== N) && std::is_integral::value, void>::type + requires ((I== N) && std::integral) + void get_global_bin( std::array const& , size_t&){ } template - typename hydra::thrust::detail::enable_if< (I< N) && std::is_integral::value, void>::type + requires ((I< N) && std::integral) + void get_global_bin( std::array const& indexes, size_t& index) { size_t prod =1; @@ -538,12 +548,14 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens // multiply std::array elements //---------------------------------------- template - typename std::enable_if< (I==N), void >::type + requires ((I==N)) + void multiply( std::array const&, size_t& ) { } template - typename std::enable_if< (I::type + requires ((I const& obj, size_t& result ) { result = I==0? 1.0: result; @@ -555,12 +567,14 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens // multiply static array elements //---------------------------------------- template< size_t I> - typename std::enable_if< (I==N), void >::type + requires ((I==N)) + void multiply( size_t (&)[N] , size_t& ) { } template - typename std::enable_if< (I::type + requires ((I, detail::multidimens // std::array version //------------------------- //end of recursion - template::value, void>::type> - typename std::enable_if< (I==N), void >::type + template + requires (std::integral && (I==N)) + void get_indexes(size_t , std::array& ) {} //begin of the recursion - template::value, void>::type> - typename std::enable_if< (I::type + template + requires (std::integral && (I& indexes) { size_t factor = 1; @@ -596,16 +610,16 @@ class DenseHistogram< T, N, detail::BackendPolicy, detail::multidimens // static array version //------------------------- //end of recursion - template::value, void>::type> - typename std::enable_if< (I==N), void >::type + template + requires (std::integral && (I==N)) + void get_indexes(size_t, Int (&)[N]) {} //begin of the recursion - template::value, void>::type> - typename std::enable_if< (I::type + template + requires (std::integral && (I, detail::uni Fill(Iterator1 begin, Iterator1 end, Iterator2 wbegin); template - inline typename std::enable_if< hydra::detail::is_iterable::value, - DenseHistogram, detail::unidimensional>& >::type + requires (hydra::detail::Iterable) + inline DenseHistogram, detail::unidimensional>& Fill(Iterable&& container){ return this->Fill( std::forward(container).begin(), std::forward(container).end()); } template - inline typename std::enable_if< hydra::detail::is_iterable::value - && hydra::detail::is_iterable::value, - DenseHistogram, detail::unidimensional>& >::type + requires (hydra::detail::Iterable && hydra::detail::Iterable) + inline DenseHistogram, detail::unidimensional>& Fill(Iterable1&& container, Iterable2&& wbegin){ return this->Fill( container.begin(), container.end(), wbegin.begin()); } @@ -893,8 +906,8 @@ make_dense_histogram( detail::BackendPolicy backend, std::array -inline typename std::enable_if< hydra::detail::is_iterable::value, -DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>>::type +requires (hydra::detail::Iterable) +inline DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional> make_dense_histogram( detail::BackendPolicy backend, std::array const& grid, std::array const& lowerlimits, std::array const& upperlimits, Iterable&& data); @@ -911,9 +924,8 @@ make_dense_histogram( detail::BackendPolicy backend, std::array -inline typename std::enable_if< hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value, -DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>>::type +requires (hydra::detail::Iterable && hydra::detail::Iterable) +inline DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional> make_dense_histogram( detail::BackendPolicy backend, std::array const& grid, std::array const& lowerlimits, std::array const& upperlimits, Iterable1&& data, Iterable2&& weight); @@ -967,8 +979,8 @@ make_dense_histogram( detail::BackendPolicy backend, size_t nbins, * @return */ template -inline typename std::enable_if< hydra::detail::is_iterable::value, -DenseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional>>::type +requires (hydra::detail::Iterable) +inline DenseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional> make_dense_histogram( detail::BackendPolicy backend, size_t nbins, double lowerlimits, double upperlimits, Iterable&& data); @@ -985,9 +997,8 @@ make_dense_histogram( detail::BackendPolicy backend, size_t nbins, * @return */ template -inline typename std::enable_if< hydra::detail::is_iterable::value&& - hydra::detail::is_iterable::value, -DenseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional>>::type +requires (hydra::detail::Iterable&& hydra::detail::Iterable) +inline DenseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional> make_dense_histogram( detail::BackendPolicy backend, size_t nbins, double lowerlimits, double upperlimits, Iterable1&& data, Iterable2&& weight); diff --git a/hydra/Filter.h b/hydra/Filter.h index 0c0491a4e..09688f8cc 100644 --- a/hydra/Filter.h +++ b/hydra/Filter.h @@ -39,6 +39,7 @@ //thrust #include +#include //std @@ -55,14 +56,14 @@ namespace hydra { * @return */ template -inline typename std::enable_if< hydra::detail::is_iterable::value, - hydra::Range().begin())>>::type +requires (hydra::detail::Iterable) +inline hydra::Range().begin())> filter(Iterable&& container, Functor const& filter); template -inline typename std::enable_if< hydra::detail::is_iterable::value, - std::pair().begin())>, - hydra::Range().begin())>>>::type +requires (hydra::detail::Iterable) +inline std::pair().begin())>, + hydra::Range().begin())>> segregate(Iterable&& container, Functor const& filter); diff --git a/hydra/Function.h b/hydra/Function.h index ffc4285d7..aa1a5a9d4 100644 --- a/hydra/Function.h +++ b/hydra/Function.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -165,14 +166,12 @@ class BaseFunctor : public detail::Parameters template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_valid_type_pack< argument_type, T...>::value), - return_type>::type + requires ((!detail::ValidTypePack)) + __hydra_host__ __hydra_device__ inline return_type operator()(T...x) const { //typename hydra::tuple::dummy a; - HYDRA_STATIC_ASSERT( (!detail::is_valid_type_pack< argument_type, T...>::value), //int(sizeof...(T))==-1, + HYDRA_STATIC_ASSERT( (!detail::ValidTypePack), //int(sizeof...(T))==-1, "This Hydra functor can not be called with these arguments.\n" "Possible functions arguments are:\n\n" "1) List of arguments matching or convertible to the functor signature.\n" @@ -193,10 +192,8 @@ class BaseFunctor : public detail::Parameters * the lambda signature */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - detail::is_valid_type_pack< argument_type, T...>::value, - return_type>::type + requires (detail::ValidTypePack) + __hydra_host__ __hydra_device__ inline return_type operator()(T...x) const { return static_cast(this)->Evaluate(x...); @@ -208,12 +205,12 @@ class BaseFunctor : public detail::Parameters * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type< typename std::decay::type >::value ) && - (!detail::is_tuple_of_function_arguments< typename std::decay::type >::value) && - ( hydra::thrust::detail::is_convertible< typename std::decay::type, argument_type >::value ), - return_type >::type + requires ( + ( detail::TupleType ) && + (!detail::TupleOfFunctionArguments) && + ( hydra::thrust::detail::is_convertible< typename std::decay::type, argument_type >::value ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T x ) const { return raw_call(x); @@ -225,11 +222,11 @@ class BaseFunctor : public detail::Parameters * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value), - return_type>::type + requires ( + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T x ) const { return call(x); @@ -242,13 +239,13 @@ class BaseFunctor : public detail::Parameters * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ) && - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ) , - return_type>::type + requires ( + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T1 x, T2 y ) const { auto z = hydra::thrust::tuple_cat(x, y); @@ -263,13 +260,13 @@ class BaseFunctor : public detail::Parameters * the lambda arguments in any order. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_function_argument< typename std::decay::type >::value ) && - ( detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ), - return_type>::type + requires ( + (!detail::TupleType ) && + ( detail::FunctionArgumentArg ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T1 x, T2 y ) const { auto z = hydra::thrust::tuple_cat(hydra::thrust::make_tuple(x), y); @@ -283,13 +280,13 @@ class BaseFunctor : public detail::Parameters * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_function_argument< typename std::decay::type >::value ) && - ( detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ), - return_type>::type + requires ( + (!detail::TupleType ) && + ( detail::FunctionArgumentArg ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T2 y, T1 x ) const { auto z = hydra::thrust::tuple_cat(hydra::thrust::make_tuple(x), y); diff --git a/hydra/GenzMalikQuadrature.h b/hydra/GenzMalikQuadrature.h index be03131a4..44db3aa07 100644 --- a/hydra/GenzMalikQuadrature.h +++ b/hydra/GenzMalikQuadrature.h @@ -63,8 +63,9 @@ class GenzMalikQuadrature; * J. Berntsen, T. O. Espelid, and A. Genz, "An adaptive algorithm for the approximate calculation of multiple integrals," ACM Trans. Math. Soft. 17 (4), 437–451 (1991) */ template< size_t N, hydra::detail::Backend BACKEND> +requires (N>1) class GenzMalikQuadrature >: -public Integral1),GenzMalikQuadrature>>::type > +public Integral> > { typedef hydra::detail::BackendPolicy system_type; diff --git a/hydra/GenzMalikRule.h b/hydra/GenzMalikRule.h index de0cb16b8..76f3df9e8 100644 --- a/hydra/GenzMalikRule.h +++ b/hydra/GenzMalikRule.h @@ -69,8 +69,9 @@ class GenzMalikRule; * */ template +requires (DIM>1) class GenzMalikRule>: - GenzMalikRuleBase1), void >::type > + GenzMalikRuleBase { @@ -361,13 +362,15 @@ class GenzMalikRule>: private: template - inline typename std::enable_if< (N==0), GULong64_t>::type twoN() + requires ((N==0)) + inline GULong64_t twoN() { return 1; } template - inline typename std::enable_if< (N>0), GULong64_t>::type twoN() + requires ((N>0)) + inline GULong64_t twoN() { return 2*twoN(); } diff --git a/hydra/Lambda.h b/hydra/Lambda.h index 97d686b60..5bfc34029 100644 --- a/hydra/Lambda.h +++ b/hydra/Lambda.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -87,9 +88,8 @@ class Lambda:public detail::Parameters<0> template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< std::is_copy_assignable::value, - Lambda &>::type + requires (std::is_copy_assignable::value) + __hydra_host__ __hydra_device__ inline Lambda & operator=(Lambda const & other ) { if(this == &other) return *this; @@ -130,10 +130,8 @@ class Lambda:public detail::Parameters<0> template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_valid_type_pack::value), - return_type>::type + requires ((!detail::ValidTypePack)) + __hydra_host__ __hydra_device__ inline return_type operator()(T...x) const { HYDRA_STATIC_ASSERT(int(sizeof...(T))==-1, @@ -157,10 +155,8 @@ class Lambda:public detail::Parameters<0> * the lambda signature */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - detail::is_valid_type_pack::value, - return_type>::type + requires (detail::ValidTypePack) + __hydra_host__ __hydra_device__ inline return_type operator()(T...x) const { return fLambda(x...); @@ -172,12 +168,12 @@ class Lambda:public detail::Parameters<0> * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type< typename std::decay::type >::value ) && - (!detail::is_tuple_of_function_arguments< typename std::decay::type >::value) && - ( std::is_convertible< typename std::decay::type, argument_rvalue_type >::value ), - return_type >::type + requires ( + ( detail::TupleType ) && + (!detail::TupleOfFunctionArguments) && + ( std::is_convertible< typename std::decay::type, argument_rvalue_type >::value ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T x ) const { return raw_call(x); @@ -189,11 +185,11 @@ class Lambda:public detail::Parameters<0> * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value), - return_type>::type + requires ( + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T x ) const { return call(x); @@ -206,13 +202,12 @@ class Lambda:public detail::Parameters<0> * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ) && - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ) , - return_type>::type + requires (( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) +) + __hydra_host__ __hydra_device__ inline return_type operator()( T1 x, T2 y ) const { auto z = hydra::thrust::tuple_cat(x, y); @@ -227,13 +222,13 @@ class Lambda:public detail::Parameters<0> * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_function_argument< typename std::decay::type >::value ) && - ( detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ), - return_type>::type + requires ( + (!detail::TupleType ) && + ( detail::FunctionArgumentArg ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T1 x, T2 y ) const { auto z = hydra::thrust::tuple_cat(hydra::thrust::make_tuple(x), y); @@ -247,13 +242,13 @@ class Lambda:public detail::Parameters<0> * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_function_argument< typename std::decay::type >::value ) && - ( detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ), - return_type>::type + requires ( + (!detail::TupleType ) && + ( detail::FunctionArgumentArg ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T2 y, T1 x ) const { auto z = hydra::thrust::tuple_cat(hydra::thrust::make_tuple(x), y); @@ -340,8 +335,8 @@ class Lambda : public detail::Parameters * when, if ever, c++20 get cuda support... */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if::value, Lambda&>::type + requires (std::is_copy_assignable::value) + __hydra_host__ __hydra_device__ inline Lambda& operator=(Lambda const & other ) { if(this != &other) @@ -389,10 +384,8 @@ class Lambda : public detail::Parameters } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_valid_type_pack::value), - return_type>::type + requires ((!detail::ValidTypePack)) + __hydra_host__ __hydra_device__ inline return_type operator()(T...x) const { HYDRA_STATIC_ASSERT(int(sizeof...(T))==-1, @@ -410,45 +403,43 @@ class Lambda : public detail::Parameters } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (detail::is_valid_type_pack::value), - return_type>::type + requires ((detail::ValidTypePack)) + __hydra_host__ __hydra_device__ inline return_type operator()(T...x) const { return fLambda(this->GetNumberOfParameters(), this->GetParameters(), x...); } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type< typename std::decay::type >::value ) && - (!detail::is_tuple_of_function_arguments< typename std::decay::type >::value) && - ( std::is_convertible::type, argument_rvalue_type>::value ), - return_type >::type + requires ( + ( detail::TupleType ) && + (!detail::TupleOfFunctionArguments) && + ( std::is_convertible::type, argument_rvalue_type>::value ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T x ) const { return raw_call(x); } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value), - return_type>::type + requires ( + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T x ) const { return call(x); } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ) && - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ) , - return_type>::type + requires ( + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T1 x, T2 y ) const { auto z = hydra::thrust::tuple_cat(x, y); @@ -456,13 +447,13 @@ class Lambda : public detail::Parameters } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_function_argument< typename std::decay::type >::value ) && - ( detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ), - return_type>::type + requires ( + (!detail::TupleType ) && + ( detail::FunctionArgumentArg ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T1 x, T2 y ) const { auto z = hydra::thrust::tuple_cat(hydra::thrust::make_tuple(x), y); @@ -470,13 +461,13 @@ class Lambda : public detail::Parameters } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_function_argument< typename std::decay::type >::value ) && - ( detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ), - return_type>::type + requires ( + (!detail::TupleType ) && + ( detail::FunctionArgumentArg ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T2 y, T1 x ) const { auto z = hydra::thrust::tuple_cat(hydra::thrust::make_tuple(x), y); @@ -531,9 +522,8 @@ hydra::Lambda wrap_lambda(LambdaType const& lambda) } template -typename std::enable_if< -detail::all_true::value...>::value, -hydra::Lambda>::type +requires (detail::all_true::value...>::value) +hydra::Lambda wrap_lambda(LambdaType const& lambda, T const&...parameters) { return hydra::Lambda(lambda, {parameters...}); diff --git a/hydra/LogLikelihoodFCN.h b/hydra/LogLikelihoodFCN.h index 5b86dd6bb..06e69e2b3 100644 --- a/hydra/LogLikelihoodFCN.h +++ b/hydra/LogLikelihoodFCN.h @@ -20,7 +20,7 @@ *---------------------------------------------------------------------------*/ /* - * LogLikelihoodFCN2.h + * LogLikelihoodFCN.h * * Created on: 13/08/2017 * Author: Antonio Augusto Alves Junior @@ -36,22 +36,10 @@ #include #include #include +#include namespace hydra { -namespace detail { - -template -struct are_iterators: std::conditional::value...> >::type{}; - -template -struct are_iterables: std::conditional::value...> >::type{}; - - -} // namespace detail - template class LogLikelihoodFCN; @@ -89,8 +77,8 @@ class LogLikelihoodFCN< PDFSumNonExtendable, IteratorD, IteratorW...>; * @return */ template< typename Functor, typename Integrator, typename Iterator, typename ...Iterators> -inline typename std::enable_if< detail::is_iterator::value && detail::are_iterators::value, -LogLikelihoodFCN< Pdf, Iterator , Iterators... > >::type +requires (detail::Iterator && detail::Iterators) +inline LogLikelihoodFCN< Pdf, Iterator , Iterators... > make_loglikehood_fcn(Pdf const& pdf, Iterator first, Iterator last, Iterators... weights ); @@ -104,8 +92,8 @@ make_loglikehood_fcn(Pdf const& pdf, Iterator first, Iterato * @return */ template -inline typename std::enable_if< detail::is_iterator::value && detail::are_iterators::value, -LogLikelihoodFCN< PDFSumExtendable, Iterator, Iterators...> >::type +requires (detail::Iterator && detail::Iterators) +inline LogLikelihoodFCN< PDFSumExtendable, Iterator, Iterators...> make_loglikehood_fcn(PDFSumExtendable const& functor, Iterator first, Iterator last, Iterators... weights ); @@ -120,8 +108,8 @@ make_loglikehood_fcn(PDFSumExtendable const& functor, Iterator first, I */ template -inline typename std::enable_if< hydra::detail::is_iterator::value && detail::are_iterators::value, -LogLikelihoodFCN< PDFSumNonExtendable, Iterator,Iterators... >>::type +requires (hydra::detail::Iterator && detail::Iterators) +inline LogLikelihoodFCN< PDFSumNonExtendable, Iterator,Iterators... > make_loglikehood_fcn(PDFSumNonExtendableconst& pdf, Iterator first, Iterator last, Iterators... weights); @@ -137,14 +125,9 @@ make_loglikehood_fcn(PDFSumNonExtendableconst& pdf, Iterator first, Ite * @return */ template< typename Functor, typename Integrator, typename Iterable, typename ...Iterables > -inline typename std::enable_if< (!detail::is_iterator::value) && - ((sizeof...(Iterables)==0) || !detail::are_iterators::value) && - (!hydra::detail::is_hydra_dense_histogram< typename std::remove_reference::type>::value) && - (!hydra::detail::is_hydra_sparse_histogram::type>::value) && - detail::is_iterable::value && - detail::are_iterables::value, -LogLikelihoodFCN< Pdf, decltype(std::declval().begin()), - decltype(std::declval().begin())... >>::type +requires ((!detail::Iterator) && ((sizeof...(Iterables)==0) || !detail::Iterators) && (!hydra::detail::is_hydra_dense_histogram< typename std::remove_reference::type>::value) && (!hydra::detail::is_hydra_sparse_histogram::type>::value) && hydra::detail::Iterable && detail::Iterables) +inline LogLikelihoodFCN< Pdf, decltype(std::declval().begin()), + decltype(std::declval().begin())... > make_loglikehood_fcn(Pdf const& pdf, Iterable&& points, Iterables&&... weights ); @@ -158,13 +141,9 @@ make_loglikehood_fcn(Pdf const& pdf, Iterable&& points, Iter * @return */ template -inline typename std::enable_if< (!detail::is_iterator::value) && - ((sizeof...(Iterables)==0) || !detail::are_iterators::value) && - (!hydra::detail::is_hydra_dense_histogram< typename std::remove_reference::type>::value) && - (!hydra::detail::is_hydra_sparse_histogram::type>::value) && - detail::is_iterable::value && detail::are_iterables::value, -LogLikelihoodFCN< PDFSumExtendable, decltype(std::declval().begin()), - decltype(std::declval().begin())...> >::type +requires ((!detail::Iterator) && ((sizeof...(Iterables)==0) || !detail::Iterators) && (!hydra::detail::is_hydra_dense_histogram< typename std::remove_reference::type>::value) && (!hydra::detail::is_hydra_sparse_histogram::type>::value) && hydra::detail::Iterable && detail::Iterables) +inline LogLikelihoodFCN< PDFSumExtendable, decltype(std::declval().begin()), + decltype(std::declval().begin())...> make_loglikehood_fcn(PDFSumExtendable const& functor, Iterable&& points, Iterables&& ...weights ); @@ -178,14 +157,9 @@ make_loglikehood_fcn(PDFSumExtendable const& functor, Iterable&& points * @return */ template -inline typename std::enable_if< (!detail::is_iterator::value) && - ((sizeof...(Iterables)==0) || !detail::are_iterators::value) && - (!hydra::detail::is_hydra_dense_histogram< typename std::remove_reference::type>::value) && - (!hydra::detail::is_hydra_sparse_histogram::type>::value) && - hydra::detail::is_iterable::value && - detail::are_iterables::value, -LogLikelihoodFCN< PDFSumNonExtendable, decltype(std::declval< Iterable>().begin()), - decltype(std::declval< Iterables>().begin())... > >::type +requires ((!detail::Iterator) && ((sizeof...(Iterables)==0) || !detail::Iterators) && (!hydra::detail::is_hydra_dense_histogram< typename std::remove_reference::type>::value) && (!hydra::detail::is_hydra_sparse_histogram::type>::value) && hydra::detail::Iterable && detail::Iterables) +inline LogLikelihoodFCN< PDFSumNonExtendable, decltype(std::declval< Iterable>().begin()), + decltype(std::declval< Iterables>().begin())... > make_loglikehood_fcn(PDFSumNonExtendable const& functor, Iterable&& points, Iterables&&... weights ); @@ -202,11 +176,10 @@ make_loglikehood_fcn(PDFSumNonExtendable const& functor, Iterable&& poi * @return hydra::LogLikelihoodFCN instance hydra::Pdf for . */ template< typename Functor, typename Integrator, typename Histogram> -inline typename std::enable_if::value || - detail::is_hydra_sparse_histogram::value, -LogLikelihoodFCN< Pdf, +requires (detail::is_hydra_dense_histogram::value || detail::is_hydra_sparse_histogram::value) +inline LogLikelihoodFCN< Pdf, decltype(std::declval().GetBinsCenters().begin()), - decltype( std::declval().GetBinsContents().begin())>>::type + decltype( std::declval().GetBinsContents().begin())> make_loglikehood_fcn(Pdf const& pdf, Histogram const& points ); @@ -218,11 +191,10 @@ make_loglikehood_fcn(Pdf const& pdf, Histogram const& points * @return hydra::LogLikelihoodFCN instance for hydra::PDFSumExtendable. */ template -inline typename std::enable_if::value || - detail::is_hydra_sparse_histogram::value, - LogLikelihoodFCN< PDFSumExtendable, +requires (detail::is_hydra_dense_histogram::value || detail::is_hydra_sparse_histogram::value) +inline LogLikelihoodFCN< PDFSumExtendable, decltype(std::declval().GetBinsCenters().begin()), - decltype(std::declval().GetBinsContents().begin()) >>::type + decltype(std::declval().GetBinsContents().begin()) > make_loglikehood_fcn(PDFSumExtendable const& pdf, Histogram const& data); @@ -234,11 +206,10 @@ make_loglikehood_fcn(PDFSumExtendable const& pdf, Histogram const& dat * @return hydra::LogLikelihoodFCN instance for hydra::PDFSumNonExtendable */ template -inline typename std::enable_if::value || - detail::is_hydra_sparse_histogram::value, - LogLikelihoodFCN< PDFSumNonExtendable, +requires (detail::is_hydra_dense_histogram::value || detail::is_hydra_sparse_histogram::value) +inline LogLikelihoodFCN< PDFSumNonExtendable, decltype(std::declval().GetBinsCenters().begin()), - decltype(std::declval().GetBinsContents().begin()) >>::type + decltype(std::declval().GetBinsContents().begin()) > make_loglikehood_fcn(PDFSumNonExtendable const& pdf, Histogram const& data); diff --git a/hydra/PhaseSpace.h b/hydra/PhaseSpace.h index 7536fd5ee..ba423c59e 100644 --- a/hydra/PhaseSpace.h +++ b/hydra/PhaseSpace.h @@ -67,6 +67,7 @@ #include #include #include +#include namespace hydra { @@ -196,8 +197,8 @@ class PhaseSpace { * @return A Range object pointing to the @param result container */ template - inline typename std::enable_if< hydra::detail::is_iterable::value, - hydra::Range().begin())>>::type + requires (hydra::detail::Iterable) + inline hydra::Range().begin())> Evaluate(Vector4R const& mother, Iterable&& iterable, FUNCTOR const& ...functors); /** @@ -208,9 +209,8 @@ class PhaseSpace { * @return A Range object pointing to the @param result container */ template - inline typename std::enable_if< hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value, - hydra::Range().begin())>>::type + requires (hydra::detail::Iterable && hydra::detail::Iterable) + inline hydra::Range().begin())> Evaluate(IterableMother&& mothers, Iterable&& result, FUNCTOR const& ...functors); //-------------------------------------------------------------------- @@ -259,8 +259,8 @@ class PhaseSpace { * @param end Iterator pointing to the end output range. */ template - inline typename std::enable_if< hydra::detail::is_iterable::value, - hydra::Range().begin())>>::type + requires (hydra::detail::Iterable) + inline hydra::Range().begin())> Generate(Vector4R const& mother, Iterable&& events); /** @@ -270,9 +270,8 @@ class PhaseSpace { * @param daughters_begin Iterator pointing to the begin of range of daughter particles. */ template - inline typename std::enable_if< hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value, - hydra::Range().begin())>>::type + requires (hydra::detail::Iterable && hydra::detail::Iterable) + inline hydra::Range().begin())> Generate( IterableMothers&& mothers, Iterable&& daughters); //-------------------------------------------------------------------------- diff --git a/hydra/Random.h b/hydra/Random.h index 4d6dc018d..2844984d8 100644 --- a/hydra/Random.h +++ b/hydra/Random.h @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -62,57 +63,6 @@ namespace hydra{ -namespace detail { - -namespace random { - -template -struct is_iterator: std::conditional< - !hydra::detail::is_hydra_composite_functor::value && - !hydra::detail::is_hydra_functor::value && - !hydra::detail::is_hydra_lambda::value && - !hydra::detail::is_iterable::value && - hydra::detail::is_iterator::value, - std::true_type, - std::false_type >::type {}; - -template -struct is_iterable: std::conditional< - !hydra::detail::is_hydra_composite_functor::value && - !hydra::detail::is_hydra_functor::value && - !hydra::detail::is_hydra_lambda::value && - hydra::detail::is_iterable::value && - !hydra::detail::is_iterator::value, - std::true_type, - std::false_type >::type {}; - -template -struct is_callable: std::conditional< - (hydra::detail::is_hydra_composite_functor::value || - hydra::detail::is_hydra_functor::value || - hydra::detail::is_hydra_lambda::value ) && - !hydra::detail::is_iterable::value && - !hydra::detail::is_iterator::value, - std::true_type, - std::false_type >::type {}; - -template< typename Engine, typename Functor, typename Iterable> -struct is_matching_iterable: std::conditional< - hydra::detail::is_iterable::value && - !hydra::detail::is_iterator::value && - (hydra::detail::is_hydra_composite_functor::value || - hydra::detail::is_hydra_functor::value || - hydra::detail::is_hydra_lambda::value ) && - hydra::detail::has_rng_formula::value && - std::is_convertible< - decltype(std::declval>().Generate( std::declval(), std::declval())), - typename hydra::thrust::iterator_traits().begin())>::value_type>::value, - std::true_type, std::false_type ->::type{}; -} // namespace random - -} // namespace detail - /** * \ingroup random @@ -131,9 +81,8 @@ struct is_matching_iterable: std::conditional< * @return hydra::Range object pointing unweighted sample. */ template -typename std::enable_if< -detail::random::is_iterator::value && detail::random::is_iterator::value, -Range >::type +requires (detail::random::Iterator && detail::random::Iterator) +Range unweight( hydra::thrust::detail::execution_policy_base const& policy, IteratorData data_begin, IteratorData data_end, IteratorWeight weights_begin, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0); @@ -155,9 +104,8 @@ unweight( hydra::thrust::detail::execution_policy_base const& po * @return hydra::Range object pointing unweighted sample. */ template -typename std::enable_if< -detail::random::is_iterator::value && detail::random::is_iterator::value, -Range >::type +requires (detail::random::Iterator && detail::random::Iterator) +Range unweight( detail::BackendPolicy const& policy, IteratorData data_begin, IteratorData data_end, IteratorWeight weights_begin, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0); @@ -177,10 +125,8 @@ unweight( detail::BackendPolicy const& policy, IteratorData data_begin, * @return hydra::Range object pointing unweighted sample. */ template -typename std::enable_if< - detail::random::is_iterator::value && detail::random::is_iterator::value, - Range ->::type +requires (detail::random::Iterator && detail::random::Iterator) +Range unweight(IteratorData data_begin, IteratorData data_end , IteratorData weights_begin, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0); @@ -200,9 +146,8 @@ unweight(IteratorData data_begin, IteratorData data_end , IteratorData weights_b * @return hydra::Range object pointing unweighted sample. */ template -typename std::enable_if< -detail::random::is_iterable::value && detail::random::is_iterable::value, -Range< decltype(std::declval().begin())> >::type +requires (detail::random::Iterable && detail::random::Iterable) +Range< decltype(std::declval().begin())> unweight( hydra::detail::BackendPolicy const& policy, IterableData&& data, IterableWeight&& weights, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0); @@ -221,10 +166,8 @@ unweight( hydra::detail::BackendPolicy const& policy, IterableData&& d * @return hydra::Range object pointing unweighted sample. */ template -typename std::enable_if< - detail::random::is_iterable::value && detail::random::is_iterable::value, - Range< decltype(std::declval().begin())> ->::type +requires (detail::random::Iterable && detail::random::Iterable) +Range< decltype(std::declval().begin())> unweight( IterableData data, IterableWeight weights, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0 ); @@ -244,10 +187,8 @@ unweight( IterableData data, IterableWeight weights, * @return hydra::Range object pointing unweighted sample. */ template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterator::value, - Range ->::type +requires (detail::random::Callable && detail::random::Iterator) +Range unweight( hydra::thrust::detail::execution_policy_base const& policy, Iterator begin, Iterator end, Functor const& functor, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0 ); @@ -268,10 +209,8 @@ unweight( hydra::thrust::detail::execution_policy_base const& pol * @return hydra::Range object pointing unweighted sample. */ template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterator::value, - Range ->::type +requires (detail::random::Callable && detail::random::Iterator) +Range unweight( hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, Functor const& functor, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0 ); @@ -289,10 +228,8 @@ unweight( hydra::detail::BackendPolicy const& policy, Iterator begin, I * @return hydra::Range object pointing unweighted sample. */ template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterator::value, - Range ->::type +requires (detail::random::Callable && detail::random::Iterator) +Range unweight( Iterator begin, Iterator end, Functor const& functor, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0 ); @@ -309,10 +246,8 @@ unweight( Iterator begin, Iterator end, Functor const& functor, * @return hydra::Range object pointing unweighted sample. */ template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterable::value , - Range< decltype(std::declval().begin())> ->::type +requires (detail::random::Callable && detail::random::Iterable) +Range< decltype(std::declval().begin())> unweight( hydra::detail::BackendPolicy const& policy, Iterable&& iterable, Functor const& functor, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0 ); @@ -330,9 +265,8 @@ unweight( hydra::detail::BackendPolicy const& policy, * @return hydra::Range object pointing unweighted sample. */ template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterable::value , -Range< decltype(std::declval().begin())>>::type +requires (detail::random::Callable && detail::random::Iterable) +Range< decltype(std::declval().begin())> unweight( Iterable&& iterable, Functor const& functor, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0 ); @@ -351,9 +285,8 @@ unweight( Iterable&& iterable, Functor const& functor, * @return range with the generated values */ template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterator::value, -Range >::type +requires (detail::random::Callable && detail::random::Iterator) +Range sample(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, double min, double max, Functor const& functor, size_t seed=0xb56c4feeef1b, size_t rng_jump=0 ); @@ -372,9 +305,8 @@ sample(hydra::detail::BackendPolicy const& policy, * @return range with the generated values */ template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterator::value, -Range >::type +requires (detail::random::Callable && detail::random::Iterator) +Range sample(hydra::thrust::detail::execution_policy_base const& policy, Iterator begin, Iterator end, double min, double max, Functor const& functor, size_t seed=0xb56c4feeef1b, size_t rng_jump=0 ); @@ -392,9 +324,8 @@ sample(hydra::thrust::detail::execution_policy_base const& policy * @return range with the generated values */ template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterator::value, -Range >::type +requires (detail::random::Callable && detail::random::Iterator) +Range sample(Iterator begin, Iterator end , double min, double max, Functor const& functor, size_t seed=0xb56c4feeef1b, size_t rng_jump=0 ); @@ -410,9 +341,8 @@ sample(Iterator begin, Iterator end , double min, double max, * @return range with the generated values */ template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterable::value , -Range< decltype(std::declval().begin())>>::type +requires (detail::random::Callable && detail::random::Iterable) +Range< decltype(std::declval().begin())> sample(Iterable&& output, double min, double max, Functor const& functor, size_t seed=0xb56c4feeef1b, size_t rng_jump=0 ); @@ -429,9 +359,8 @@ sample(Iterable&& output, double min, double max, * @return range with the generated values */ template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterator::value, -Range >::type +requires (detail::random::Callable && detail::random::Iterator) +Range sample(Iterator begin, Iterator end , std::arrayconst& min, std::arrayconst& max, Functor const& functor, size_t seed=0xb56c4feeef1b, size_t rng_jump=0 ); @@ -448,11 +377,12 @@ sample(Iterator begin, Iterator end , std::arrayconst& min, std::array * @return range with the generated values */ template -typename std::enable_if< -detail::random::is_callable::value && -detail::random::is_iterator::value && -detail::is_tuple_type< decltype(*std::declval())>::value, -Range >::type +requires ( + detail::random::Callable && + detail::random::Iterator && + detail::is_tuple_type< decltype(*std::declval())>::value +) +Range sample(Iterator begin, Iterator end , typename Functor::argument_type const& min, typename Functor::argument_type const& max, Functor const& functor, size_t seed=0xb56c4feeef1b, size_t rng_jump=0 ); @@ -470,9 +400,8 @@ sample(Iterator begin, Iterator end , * @param functor distribution to be sampled */ template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterator::value, -Range >::type +requires (detail::random::Callable && detail::random::Iterator) +Range sample(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end , std::arrayconst& min, std::arrayconst& max, @@ -490,9 +419,8 @@ sample(hydra::detail::BackendPolicy const& policy, * @param functor distribution to be sampled */ template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterator::value, -Range >::type +requires (detail::random::Callable && detail::random::Iterator) +Range sample(hydra::thrust::detail::execution_policy_base const& policy, Iterator begin, Iterator end , std::arrayconst& min, std::arrayconst& max, @@ -510,9 +438,8 @@ sample(hydra::thrust::detail::execution_policy_base const& polic * @return output range with the generated values */ template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterable::value , -Range< decltype(std::declval().begin())>>::type +requires (detail::random::Callable && detail::random::Iterable) +Range< decltype(std::declval().begin())> sample( Iterable&& output , std::arrayconst& min, std::arrayconst& max, Functor const& functor, size_t seed=0xb56c4feeef1b, size_t rng_jump=0 ); @@ -529,11 +456,12 @@ sample( Iterable&& output , * @return output range with the generated values */ template -typename std::enable_if< -detail::random::is_callable::value && -detail::random::is_iterable::value && -detail::is_tuple_type< decltype(*std::declval().begin())>::value , -Range< decltype(std::declval().begin())>>::type +requires ( + detail::random::Callable && + detail::random::Iterable && + detail::is_tuple_type< decltype(*std::declval().begin())>::value +) +Range< decltype(std::declval().begin())> sample( Iterable&& output , typename Functor::argument_type const& min,typename Functor::argument_type const& max, Functor const& functor, size_t seed=0xb56c4feeef1b, size_t rng_jump=0 ); @@ -551,11 +479,9 @@ sample( Iterable&& output , * @param rng_jump sequence offset for the underlying pseudo-random number generator */ template< typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterator, typename FUNCTOR > -typename std::enable_if< hydra::detail::has_rng_formula::value && std::is_convertible< -decltype(std::declval>().Generate( std::declval(), std::declval())), -typename hydra::thrust::iterator_traits::value_type ->::value, void>::type -fill_random(hydra::detail::BackendPolicy const& policy, +requires hydra::detail::HasRngFormula && + hydra::detail::IsRngFormulaConvertible +void fill_random(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); /** @@ -570,11 +496,9 @@ fill_random(hydra::detail::BackendPolicy const& policy, * @param rng_jump sequence offset for the underlying pseudo-random number generator */ template< typename Engine =hydra::default_random_engine, typename Iterator, typename FUNCTOR > -typename std::enable_if< hydra::detail::has_rng_formula::value && std::is_convertible< -decltype(std::declval>().Generate( std::declval(), std::declval())), -typename hydra::thrust::iterator_traits::value_type ->::value, void>::type -fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); +requires hydra::detail::HasRngFormula && + hydra::detail::IsRngFormulaConvertible +void fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); /** * \ingroup random @@ -588,7 +512,8 @@ fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x * @param rng_jump sequence offset for the underlying pseudo-random number generator */ template< typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterable, typename FUNCTOR > -typename std::enable_if< detail::random::is_matching_iterable::value, void>::type +requires (detail::random::MatchingIterable) +void fill_random(hydra::detail::BackendPolicy const& policy, Iterable&& iterable, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); @@ -603,8 +528,8 @@ fill_random(hydra::detail::BackendPolicy const& policy, * @param rng_jump sequence offset for the underlying pseudo-random number generator */ template< typename Engine = hydra::default_random_engine, typename Iterable, typename FUNCTOR > -typename std::enable_if< detail::random::is_matching_iterable::value, -void>::type +requires (detail::random::MatchingIterable) +void fill_random(Iterable&& iterable, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); /** @@ -620,8 +545,8 @@ fill_random(Iterable&& iterable, FUNCTOR const& functor, size_t seed=0x254a0afcf * @param rng_jump sequence offset for the underlying pseudo-random number generator */ template< typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterator, typename FUNCTOR > -typename std::enable_if< !hydra::detail::has_rng_formula::value , void>::type -fill_random(hydra::detail::BackendPolicy const& policy, +requires (!hydra::detail::HasRngFormula) +void fill_random(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); /** @@ -636,8 +561,8 @@ fill_random(hydra::detail::BackendPolicy const& policy, * @param rng_jump sequence offset for the underlying pseudo-random number generator */ template< typename Engine = hydra::default_random_engine, typename Iterator, typename FUNCTOR > -typename std::enable_if< !hydra::detail::has_rng_formula::value , void>::type -fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); +requires (!hydra::detail::HasRngFormula) +void fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); /** * \ingroup random @@ -652,11 +577,9 @@ fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x * @param rng_jump sequence offset for the underlying pseudo-random number generator */ template< typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterator, typename FUNCTOR > -typename std::enable_if< !std::is_convertible< -decltype(std::declval>().Generate( std::declval(), std::declval())), -typename std::iterator_traits::value_type ->::value && hydra::detail::has_rng_formula::value, void>::type -fill_random(hydra::detail::BackendPolicy const& policy, +requires hydra::detail::HasRngFormula && + hydra::detail::NotConvertibleToIteratorValue +void fill_random(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, FUNCTOR const& funct, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); /** @@ -671,11 +594,9 @@ fill_random(hydra::detail::BackendPolicy const& policy, * @param rng_jump sequence offset for the underlying pseudo-random number generator */ template< typename Engine = hydra::default_random_engine, typename Iterator, typename FUNCTOR > -typename std::enable_if< !std::is_convertible< -decltype(std::declval>().Generate( std::declval(), std::declval())), -typename std::iterator_traits::value_type ->::value && hydra::detail::has_rng_formula::value, void>::type -fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); +requires hydra::detail::HasRngFormula && + hydra::detail::NotConvertibleToIteratorValue +void fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); /** * \ingroup random @@ -689,7 +610,8 @@ fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x * @param rng_jump sequence offset for the underlying pseudo-random number generator */ template< typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterable, typename FUNCTOR > -typename std::enable_if< !(detail::random::is_matching_iterable::value), void>::type +requires (!(detail::random::MatchingIterable)) +void fill_random(hydra::detail::BackendPolicy const& policy, Iterable&& iterable, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); @@ -704,11 +626,11 @@ fill_random(hydra::detail::BackendPolicy const& policy, * @param rng_jump sequence offset for the underlying pseudo-random number generator */ template< typename Engine = hydra::default_random_engine, typename Iterable, typename FUNCTOR > -typename std::enable_if::value),void>::type +requires (!(detail::random::MatchingIterable)) +void fill_random(Iterable&& iterable, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0 ); - } #include diff --git a/hydra/RandomFill.h b/hydra/RandomFill.h index 5b9ef430a..444041011 100644 --- a/hydra/RandomFill.h +++ b/hydra/RandomFill.h @@ -50,6 +50,8 @@ #include #include #include +#include +#include @@ -66,10 +68,9 @@ namespace hydra{ * @param functor distribution to be sampled */ template< typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterator, typename FUNCTOR > -typename std::enable_if< hydra::detail::has_rng_formula::value && std::is_convertible< -decltype(std::declval>().Generate( std::declval(), std::declval())), -typename hydra::thrust::iterator_traits::value_type ->::value, void>::type +requires hydra::detail::HasRngFormula && + hydra::detail::IsRngFormulaConvertible +void fill_random(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2); @@ -86,10 +87,9 @@ fill_random(hydra::detail::BackendPolicy const& policy, * @param functor distribution to be sampled */ template< typename Engine =hydra::default_random_engine, typename Iterator, typename FUNCTOR > -typename std::enable_if< hydra::detail::has_rng_formula::value && std::is_convertible< -decltype(std::declval>().Generate( std::declval(), std::declval())), -typename hydra::thrust::iterator_traits::value_type ->::value, void>::type +requires hydra::detail::HasRngFormula && + hydra::detail::IsRngFormulaConvertible +void fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2); @@ -105,9 +105,8 @@ fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x * @param functor distribution to be sampled */ template< typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterable, typename FUNCTOR > -typename std::enable_if< hydra::detail::is_iterable::value && std::is_convertible< -decltype(*std::declval().begin()), typename FUNCTOR::return_type ->::value, void>::type +requires (detail::random::MatchingIterable) +void fill_random(hydra::detail::BackendPolicy const& policy, Iterable&& iterable, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2); @@ -123,9 +122,8 @@ fill_random(hydra::detail::BackendPolicy const& policy, * @param functor distribution to be sampled */ template< typename Engine = hydra::default_random_engine, typename Iterable, typename FUNCTOR > -typename std::enable_if< hydra::detail::is_iterable::value && std::is_convertible< -decltype(*std::declval().begin()), typename FUNCTOR::return_type ->::value, void>::type +requires (detail::random::MatchingIterable) +void fill_random(Iterable&& iterable, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2); @@ -142,7 +140,8 @@ fill_random(Iterable&& iterable, FUNCTOR const& functor, size_t seed=0x254a0afcf * @param functor distribution to be sampled */ template< typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterator, typename FUNCTOR > -typename std::enable_if< !hydra::detail::has_rng_formula::value , void>::type +requires (!hydra::detail::HasRngFormula) +void fill_random(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2); @@ -158,7 +157,8 @@ fill_random(hydra::detail::BackendPolicy const& policy, * @param functor distribution to be sampled */ template< typename Engine = hydra::default_random_engine, typename Iterator, typename FUNCTOR > -typename std::enable_if< !hydra::detail::has_rng_formula::value , void>::type +requires (!hydra::detail::HasRngFormula) +void fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2); @@ -174,10 +174,9 @@ fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x * @param functor distribution to be sampled */ template< typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterator, typename FUNCTOR > -typename std::enable_if< !std::is_convertible< -decltype(std::declval>().Generate( std::declval(), std::declval())), -typename std::iterator_traits::value_type ->::value && hydra::detail::has_rng_formula::value, void>::type +requires hydra::detail::HasRngFormula && + hydra::detail::NotConvertibleToIteratorValue +void fill_random(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, FUNCTOR const& funct, size_t seed=0x254a0afcf7da74a2); @@ -193,10 +192,9 @@ fill_random(hydra::detail::BackendPolicy const& policy, * @param functor distribution to be sampled */ template< typename Engine = hydra::default_random_engine, typename Iterator, typename FUNCTOR > -typename std::enable_if< !std::is_convertible< -decltype(std::declval>().Generate( std::declval(), std::declval())), -typename std::iterator_traits::value_type ->::value && hydra::detail::has_rng_formula::value, void>::type +requires hydra::detail::HasRngFormula && + hydra::detail::NotConvertibleToIteratorValue +void fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2); @@ -212,9 +210,8 @@ fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed=0x * @param functor distribution to be sampled */ template< typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterable, typename FUNCTOR > -typename std::enable_if< !hydra::detail::is_iterable::value || !std::is_convertible< -decltype(*std::declval().begin()), typename FUNCTOR::return_type ->::value, void>::type +requires (!detail::random::MatchingIterable) +void fill_random(hydra::detail::BackendPolicy const& policy, Iterable&& iterable, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2); @@ -229,9 +226,8 @@ fill_random(hydra::detail::BackendPolicy const& policy, * @param functor distribution to be sampled */ template< typename Engine = hydra::default_random_engine, typename Iterable, typename FUNCTOR > -typename std::enable_if< !hydra::detail::is_iterable::value || !std::is_convertible< -decltype(*std::declval().begin()), typename FUNCTOR::return_type ->::value, void>::type +requires (!detail::random::MatchingIterable) +void fill_random(Iterable&& iterable, FUNCTOR const& functor, size_t seed=0x254a0afcf7da74a2); diff --git a/hydra/SPlot.h b/hydra/SPlot.h index 37c482023..148c37d71 100644 --- a/hydra/SPlot.h +++ b/hydra/SPlot.h @@ -54,6 +54,7 @@ #include #include +#include namespace hydra { @@ -364,9 +365,9 @@ class SPlot: public detail::AddPdfBase * @param last iterator pointing to end of the data range. * @return */ -template -typename std::enable_if< detail::is_iterator::value, - SPlot >::type +template +requires (detail::Iterator) +SPlot make_splot(PDFSumExtendable const& pdf, Iterator first, Iterator last) { return SPlot(pdf, first,last); @@ -379,9 +380,9 @@ make_splot(PDFSumExtendable const& pdf, Iterator first, Ite * @param data iterable representing the data-range * @return */ -template -typename std::enable_if< detail::is_iterable::value, - SPlot< decltype(std::declval().begin()), PDF1, PDF2, PDFs...> >::type +template +requires (detail::Iterable) +SPlot< decltype(std::declval().begin()), PDF1, PDF2, PDFs...> make_splot(PDFSumExtendable const& pdf, Iterable&& data){ return SPlot< decltype(std::declval().begin()) , diff --git a/hydra/SparseHistogram.h b/hydra/SparseHistogram.h index 6d54676c6..5f2d80c74 100644 --- a/hydra/SparseHistogram.h +++ b/hydra/SparseHistogram.h @@ -45,14 +45,16 @@ #include #include #include +#include +#include namespace hydra { /** * \ingroup histogram */ -template::type, - typename = typename std::enable_if::value, void>::type> +template::type> +requires (std::is_arithmetic::value) class SparseHistogram; /** @@ -118,7 +120,8 @@ class SparseHistogram, detail::multidimens } - template::value, void>::type> + template + requires (std::integral) SparseHistogram( std::array const& grid, std::array const& lowerlimits, std::array const& upperlimits): fNBins(1) @@ -132,7 +135,8 @@ class SparseHistogram, detail::multidimens } - template::value, void>::type> + template + requires (std::integral) SparseHistogram( Int (&grid)[N], T (&lowerlimits)[N], T (&upperlimits)[N] ): fNBins(1) @@ -245,8 +249,8 @@ class SparseHistogram, detail::multidimens return fNBins; } - template::value, void>::type> + template + requires (std::integral) inline size_t GetBin( Int (&bins)[N]){ size_t bin=0; @@ -266,8 +270,8 @@ class SparseHistogram, detail::multidimens } - template::value, void>::type> + template + requires (std::integral) inline size_t GetBin( std::array const& bins){ size_t bin=0; @@ -277,22 +281,22 @@ class SparseHistogram, detail::multidimens return bin; } - template::value, void>::type> + template + requires (std::integral) inline void GetIndexes(size_t globalbin, Int (&bins)[N]){ get_indexes(globalbin, bins); } - template::value, void>::type> + template + requires (std::integral) inline void GetIndexes(size_t globalbin, std::array& bins){ get_indexes(globalbin, bins); } - template::value, void>::type> + template + requires (std::integral) inline double GetBinContent( Int (&bins)[N]){ size_t bin=0; @@ -319,8 +323,8 @@ class SparseHistogram, detail::multidimens } - template::value, void>::type> + template + requires (std::integral) inline double GetBinContent(std::array const& bins){ size_t bin=0; @@ -369,15 +373,18 @@ class SparseHistogram, detail::multidimens } template - inline typename std::enable_if< M==2, T >::type + requires (M==2) + inline T Interpolate( std::array const& point); template - inline typename std::enable_if< M==3, T >::type + requires (M==3) + inline T Interpolate( std::array const& point); template - inline typename std::enable_if< M==4, T >::type + requires (M==4) + inline T Interpolate( std::array const& point); @@ -430,17 +437,16 @@ class SparseHistogram, detail::multidimens template - inline typename std::enable_if< hydra::detail::is_iterable::value, - SparseHistogram, detail::multidimensional>& >::type + requires (hydra::detail::Iterable) + inline SparseHistogram, detail::multidimensional>& Fill(Iterable&& container){ return this->Fill( std::forward(container).begin(), std::forward(container).end()); } template - inline typename std::enable_if< hydra::detail::is_iterable::value - && hydra::detail::is_iterable::value, - SparseHistogram, detail::multidimensional>& >::type + requires (hydra::detail::Iterable && hydra::detail::Iterable) + inline SparseHistogram, detail::multidimensional>& Fill(Iterable1&& container, Iterable2&& wbegin){ return this->Fill( std::forward(container).begin(), std::forward(container).end(), std::forward(wbegin).begin()); @@ -462,11 +468,13 @@ class SparseHistogram, detail::multidimens //k = i_1*(dim_2*...*dim_n) + i_2*(dim_3*...*dim_n) + ... + i_{n-1}*dim_n + i_n template - typename hydra::thrust::detail::enable_if< (I== N) && std::is_integral::value, void>::type + requires ((I== N) && std::integral) + void get_global_bin(const Int (&)[N], size_t& ){ } template - typename hydra::thrust::detail::enable_if< (I< N) && std::is_integral::value, void>::type + requires ((I< N) && std::integral) + void get_global_bin(const Int (&indexes)[N], size_t& index) { size_t prod =1; @@ -478,11 +486,13 @@ class SparseHistogram, detail::multidimens } template - typename hydra::thrust::detail::enable_if< (I== N) && std::is_integral::value, void>::type + requires ((I== N) && std::integral) + void get_global_bin( std::array const& , size_t& ){ } template - typename hydra::thrust::detail::enable_if< (I< N) && std::is_integral::value, void>::type + requires ((I< N) && std::integral) + void get_global_bin( std::array const& indexes, size_t& index) { size_t prod =1; @@ -503,12 +513,14 @@ class SparseHistogram, detail::multidimens // multiply std::array elements //---------------------------------------- template - typename std::enable_if< (I==N), void >::type + requires ((I==N)) + void multiply( std::array const& , size_t& ) { } template - typename std::enable_if< (I::type + requires ((I const& obj, size_t& result ) { result = I==0? 1.0: result; @@ -520,12 +532,14 @@ class SparseHistogram, detail::multidimens // multiply static array elements //---------------------------------------- template< size_t I> - typename std::enable_if< (I==N), void >::type + requires ((I==N)) + void multiply( size_t (&)[N] , size_t& ) { } template - typename std::enable_if< (I::type + requires ((I, detail::multidimens // std::array version //------------------------- //end of recursion - template::value, void>::type> - typename std::enable_if< (I==N), void >::type + template + requires (std::integral && (I==N)) + void get_indexes(size_t, std::array& ) {} //begin of the recursion - template::value, void>::type> - typename std::enable_if< (I::type + template + requires (std::integral && (I& indexes) { size_t factor = 1; @@ -561,16 +575,16 @@ class SparseHistogram, detail::multidimens // static array version //------------------------- //end of recursion - template::value, void>::type> - typename std::enable_if< (I==N), void >::type + template + requires (std::integral && (I==N)) + void get_indexes(size_t , Int (&)[N]) {} //begin of the recursion - template::value, void>::type> - typename std::enable_if< (I::type + template + requires (std::integral && (I, detail::unidimension template - inline typename std::enable_if< hydra::detail::is_iterable::value, - SparseHistogram,detail::unidimensional >& >::type + requires (hydra::detail::Iterable) + inline SparseHistogram,detail::unidimensional >& Fill(Iterable&& container){ return this->Fill( std::forward(container).begin(), std::forward(container).end()); } template - inline typename std::enable_if< hydra::detail::is_iterable::value - && hydra::detail::is_iterable::value, - SparseHistogram,detail::unidimensional >& >::type + requires (hydra::detail::Iterable && hydra::detail::Iterable) + inline SparseHistogram,detail::unidimensional >& Fill(Iterable1&& container, Iterable2&& wbegin){ return this->Fill( std::forward(container).begin(), std::forward(container).end(), std::forward(wbegin).begin()); @@ -874,8 +887,8 @@ make_sparse_histogram( detail::BackendPolicy, std::array gri * @return */ template< typename T, size_t N , hydra::detail::Backend BACKEND, typename Iterable> -inline typename std::enable_if< hydra::detail::is_iterable::value, -SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>>::type +requires (hydra::detail::Iterable) +inline SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional> make_sparse_histogram( detail::BackendPolicy backend, std::arrayconst& grid, std::arrayconst&lowerlimits, std::arrayconst& upperlimits, Iterable&& data); @@ -893,9 +906,8 @@ make_sparse_histogram( detail::BackendPolicy backend, std::array -inline typename std::enable_if< hydra::detail::is_iterable::value&& -hydra::detail::is_iterable::value, -SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>>::type +requires (hydra::detail::Iterable&& hydra::detail::Iterable) +inline SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional> make_sparse_histogram( detail::BackendPolicy backend, std::arrayconst& grid, std::arrayconst&lowerlimits, std::arrayconst& upperlimits, Iterable1&& data, Iterable2&& weights); @@ -949,8 +961,8 @@ make_sparse_histogram( detail::BackendPolicy, size_t nbins, double lowe * @return */ template< typename T, hydra::detail::Backend BACKEND, typename Iterable> -inline typename std::enable_if< hydra::detail::is_iterable::value, -SparseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional>>::type +requires (hydra::detail::Iterable) +inline SparseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional> make_sparse_histogram( detail::BackendPolicy backend, size_t nbins, double lowerlimit, double upperlimit, Iterable&& data); @@ -967,9 +979,8 @@ make_sparse_histogram( detail::BackendPolicy backend, size_t nbins, * @return */ template< typename T, hydra::detail::Backend BACKEND, typename Iterable1,typename Iterable2 > -inline typename std::enable_if< hydra::detail::is_iterable::value&& -hydra::detail::is_iterable::value, -SparseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional>>::type +requires (hydra::detail::Iterable&& hydra::detail::Iterable) +inline SparseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional> make_sparse_histogram( detail::BackendPolicy backend, size_t nbins, double lowerlimit, double upperlimit, Iterable1&& data, Iterable2&& weights); diff --git a/hydra/Spline.h b/hydra/Spline.h index e417aed66..fcbf7d18d 100644 --- a/hydra/Spline.h +++ b/hydra/Spline.h @@ -46,6 +46,7 @@ #include #include #include +#include namespace hydra { @@ -63,12 +64,12 @@ namespace hydra { * @return Interpolated value */ template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value , - Type >::type +requires ( + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline Type spline(Iterator1 first, Iterator1 last, Iterator2 measurements, Type value); /** @@ -86,14 +87,14 @@ spline(Iterator1 first, Iterator1 last, Iterator2 measurements, Type value); * @return Interpolated value */ template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value, - Type >::type +requires ( + hydra::detail::Iterable && + hydra::detail::Iterable && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline Type spline(Iterable1&& abiscissae, Iterable2&& measurements, Type value); /** @@ -114,76 +115,77 @@ spline(Iterable1&& abiscissae, Iterable2&& measurements, Type value); * @return */ template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value && - std::is_convertible::value -, double>::type +requires ( + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline2D(IteratorX firstx, IteratorX lastx, IteratorY firsty, IteratorY lasty, IteratorM measurements, TypeX x, TypeY y); template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value , - double >::type +requires ( + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline(IterableX&& abcissa_x, IterableY&& abcissa_y, IterableM measurements, TypeX x, TypeX y); template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value, double>::type +requires ( + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v) +__hydra_host__ __hydra_device__ inline double spline3D(IteratorX firstx, IteratorX lastx, IteratorY firsty, IteratorY lasty, IteratorY firstz, IteratorY lastz, IteratorM measurements, TypeX x, TypeY y, TypeZ z); template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value , - double >::type +requires ( + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline3D(IterableX&& abscissa_x, IterableY&& abscissa_y, IterableZ&& abscissa_z, IterableM measurements, TypeX x, TypeX y, TypeZ z ); template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value, double>::type +requires ( + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline4D(IteratorX firstx, IteratorX lastx, IteratorY firsty, IteratorY lasty, IteratorW firstw, IteratorW lastw, @@ -191,23 +193,23 @@ spline4D(IteratorX firstx, IteratorX lastx, IteratorM measurements, TypeX x, TypeY y, TypeW w, TypeZ z); template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value , - double >::type +requires ( + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline3D(IterableX&& abscissa_x, IterableY&& abscissa_y, IterableW&& abscissa_w, IterableZ&& abscissa_z, IterableM measurements, TypeX x, TypeX y, TypeW w, TypeZ z ); } // namespace hydra diff --git a/hydra/Zip.h b/hydra/Zip.h index 4e76052d5..e62b9550e 100644 --- a/hydra/Zip.h +++ b/hydra/Zip.h @@ -39,14 +39,15 @@ #include +#include namespace hydra { template -typename std::enable_if< detail::all_true< detail::is_iterable::value...>::value, +requires (detail::all_true< detail::Iterable...>::value) Range< hydra::thrust::zip_iterator< - decltype(hydra::thrust::make_tuple(std::declval().begin()...))>>>::type + decltype(hydra::thrust::make_tuple(std::declval().begin()...))>> zip(Iterables&&... iterables){ return make_range( hydra::thrust::make_zip_iterator(hydra::thrust::make_tuple(std::forward(iterables).begin()...)), diff --git a/hydra/detail/BaseCompositeFunctor.h b/hydra/detail/BaseCompositeFunctor.h index 67619ff98..f02edb016 100644 --- a/hydra/detail/BaseCompositeFunctor.h +++ b/hydra/detail/BaseCompositeFunctor.h @@ -37,6 +37,7 @@ #include #include #include +#include #include //#include @@ -118,10 +119,8 @@ class BaseCompositeFunctor, Sign template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_valid_type_pack< argument_type, T...>::value), - return_type>::type + requires ((!detail::ValidTypePack)) + __hydra_host__ __hydra_device__ inline return_type operator()(T...x) const { //typename hydra::tuple::dummy a; @@ -146,10 +145,8 @@ class BaseCompositeFunctor, Sign * the lambda signature */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - detail::is_valid_type_pack< argument_type, T...>::value, - return_type>::type + requires (detail::ValidTypePack) + __hydra_host__ __hydra_device__ inline return_type operator()(T...x) const { return static_cast(this)->Evaluate(x...); @@ -161,12 +158,12 @@ class BaseCompositeFunctor, Sign * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type< typename std::decay::type >::value ) && - (!detail::is_tuple_of_function_arguments< typename std::decay::type >::value) && - ( hydra::thrust::detail::is_convertible< typename std::decay::type, argument_type >::value ), - return_type >::type + requires ( + ( detail::TupleType ) && + (!detail::TupleOfFunctionArguments) && + ( hydra::thrust::detail::is_convertible< typename std::decay::type, argument_type >::value ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T x ) const { return raw_call(x); @@ -178,11 +175,8 @@ class BaseCompositeFunctor, Sign * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value), - return_type>::type + requires (( detail::TupleType ) && ( detail::TupleOfFunctionArguments)) + __hydra_host__ __hydra_device__ inline return_type operator()( T x ) const { return call(x); @@ -195,13 +189,13 @@ class BaseCompositeFunctor, Sign * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ) && - ( detail::is_tuple_type::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ) , - return_type>::type + requires ( + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T1 x, T2 y ) const { auto z = hydra::thrust::tuple_cat(x, y); @@ -216,13 +210,13 @@ class BaseCompositeFunctor, Sign * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_function_argument< typename std::decay::type >::value ) && - ( detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ), - return_type>::type + requires ( + (!detail::TupleType ) && + ( detail::FunctionArgumentArg ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T1 x, T2 y ) const { auto z = hydra::thrust::tuple_cat(hydra::thrust::make_tuple(x), y); @@ -236,13 +230,13 @@ class BaseCompositeFunctor, Sign * the lambda arguments in any other. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (!detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_function_argument< typename std::decay::type >::value ) && - ( detail::is_tuple_type< typename std::decay::type>::value ) && - ( detail::is_tuple_of_function_arguments< typename std::decay::type >::value ), - return_type>::type + requires ( + (!detail::TupleType ) && + ( detail::FunctionArgumentArg ) && + ( detail::TupleType ) && + ( detail::TupleOfFunctionArguments ) + ) + __hydra_host__ __hydra_device__ inline return_type operator()( T2 y, T1 x ) const { auto z = hydra::thrust::tuple_cat(hydra::thrust::make_tuple(x), y); diff --git a/hydra/detail/BooststrappedRange.inl b/hydra/detail/BooststrappedRange.inl index 494c94db2..6c0eb0f96 100644 --- a/hydra/detail/BooststrappedRange.inl +++ b/hydra/detail/BooststrappedRange.inl @@ -33,14 +33,15 @@ #include #include #include +#include namespace hydra { template -typename std::enable_if::value, - Range< hydra::thrust::permutation_iterator().begin()), +requires (hydra::detail::Iterable) +Range< hydra::thrust::permutation_iterator().begin()), hydra::thrust::transform_iterator< detail::RndUniform - ,hydra::thrust::counting_iterator,size_t > > >>::type + ,hydra::thrust::counting_iterator,size_t > > > boost_strapped_range(Iterable&& iterable, size_t seed){ using hydra::thrust::make_permutation_iterator; diff --git a/hydra/detail/CollectRange.h b/hydra/detail/CollectRange.h index 50261518e..b10a6c7bf 100644 --- a/hydra/detail/CollectRange.h +++ b/hydra/detail/CollectRange.h @@ -29,19 +29,18 @@ #ifndef COLLECTRANGE_H_ #define COLLECTRANGE_H_ - +#include namespace hydra { template +requires (hydra::detail::Iterable && hydra::detail::Iterable) auto collect( Iterable_Index& indexing_scheme, Iterable_Values& collected_values) --> typename std::enable_if::value - && hydra::detail::is_iterable::value, -Range Range().begin()), decltype(std::declval().begin())> ->::type +> { typedef hydra::thrust::permutation_iterator collect_iterator; return make_range(collect_iterator(begin(collected_values), begin(indexing_scheme) ), diff --git a/hydra/detail/Compose.h b/hydra/detail/Compose.h index 23022058f..1b4f3a9d6 100644 --- a/hydra/detail/Compose.h +++ b/hydra/detail/Compose.h @@ -37,6 +37,7 @@ #include //#include #include +#include #include #include #include @@ -120,12 +121,8 @@ class Compose: public BaseCompositeFunctor< // Conveniency function template < typename T0, typename T1, typename ...Ts > -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -detail::all_true< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value )...>::value, -Compose>::type +requires (detail::HydraCallable && detail::HydraCallable && (detail::HydraCallable && ...)) +inline Compose compose(T0 const& F0, T1 const& F1, Ts const&...Fs){ return Compose(F0, F1, Fs...); diff --git a/hydra/detail/CompositeBase.h b/hydra/detail/CompositeBase.h index 065e389fa..552432146 100644 --- a/hydra/detail/CompositeBase.h +++ b/hydra/detail/CompositeBase.h @@ -40,6 +40,7 @@ #include #include #include +#include namespace hydra { @@ -73,12 +74,13 @@ class CompositeBase {} __hydra_host__ __hydra_device__ - inline typename std::enable_if< - std::is_copy_constructible::value && - std::is_copy_constructible::value && - detail::all_true::value...>::value, - CompositeBase&>::type + inline CompositeBase& operator=(CompositeBase const& other) + requires ( + (std::is_copy_constructible_v) && + (std::is_copy_constructible_v) && + (detail::all_true...>::value) + ) { if(this==&other)return *this; @@ -131,8 +133,8 @@ class CompositeBase } - template::value, void>::type> + template + requires (std::integral) inline const hydra::Parameter& GetParameter(Int i) const { std::vector _parameters; @@ -155,8 +157,8 @@ class CompositeBase return *(_parameters[i]) ; } - template::value, void>::type> + template + requires (std::integral) inline hydra::Parameter& Parameter(Int i) { std::vector _parameters; @@ -179,8 +181,8 @@ class CompositeBase } - template::value, void>::type> + template + requires (std::integral) inline void SetParameter(Int i, hydra::Parameter const& value) { std::vector _parameters; @@ -189,8 +191,8 @@ class CompositeBase *(_parameters[i])=value; } - template::value, void>::type> + template + requires (std::integral) inline void SetParameter(Int i, double value) { std::vector _parameters; detail::add_parameters_in_tuple(_parameters, fFtorTuple ); diff --git a/hydra/detail/Copy.inl b/hydra/detail/Copy.inl index ad28e82ed..d6bd6eb7c 100644 --- a/hydra/detail/Copy.inl +++ b/hydra/detail/Copy.inl @@ -36,15 +36,15 @@ #include #include #include +#include namespace hydra { template -typename std::enable_if::value -&& hydra::detail::is_iterable::value, -Range().begin())>>::type +requires (hydra::detail::Iterable && hydra::detail::Iterable) +Range().begin())> copy(Iterable_Source&& source, Iterable_Target&& destination) { hydra::thrust::copy(std::forward(source).begin(), diff --git a/hydra/detail/CountingRange.inl b/hydra/detail/CountingRange.inl index 23bf84f3f..9135d1765 100644 --- a/hydra/detail/CountingRange.inl +++ b/hydra/detail/CountingRange.inl @@ -32,6 +32,7 @@ #include #include #include +#include namespace hydra { @@ -91,8 +92,8 @@ range(long int first, long int last ){ } template -inline typename std::enable_if< std::is_floating_point::value, - Range, detail::range::Shift> >::type +requires (std::floating_point) +inline Range, detail::range::Shift> range(T min, T max, unsigned nbins ){ T delta = (max-min)/nbins; diff --git a/hydra/detail/Decays.inl b/hydra/detail/Decays.inl index a412324d1..f3edbd51c 100644 --- a/hydra/detail/Decays.inl +++ b/hydra/detail/Decays.inl @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -340,9 +341,8 @@ public: } template - __hydra_host__ __hydra_device__ - typename std::enable_if::value, - PhaseSpaceReweight &>::type + requires (std::is_copy_assignable_v) + __hydra_host__ __hydra_device__ PhaseSpaceReweight & operator=(PhaseSpaceReweight const& other ) { @@ -456,11 +456,11 @@ Decays, hydra::detail::BackendPolicy>::Unwei template template -typename std::enable_if< - detail::is_hydra_functor::value || - detail::is_hydra_lambda::value || - detail::is_hydra_composite_functor::value, - hydra::Range, hydra::detail::BackendPolicy>::iterator>>::type +requires ( + detail::HydraCallable || + detail::HydraCompositeFunctor +) +hydra::Range, hydra::detail::BackendPolicy>::iterator> Decays, hydra::detail::BackendPolicy>::Unweight( Functor const& functor, double max_weight, size_t seed) { /* diff --git a/hydra/detail/DenseHistogram.inl b/hydra/detail/DenseHistogram.inl index 2872dbdac..22b916e62 100644 --- a/hydra/detail/DenseHistogram.inl +++ b/hydra/detail/DenseHistogram.inl @@ -40,6 +40,7 @@ #include #include #include +#include namespace hydra { @@ -519,7 +520,8 @@ DenseHistogram, detail::unidimensional >::Fi template template -inline typename std::enable_if< M==2, T >::type +requires (M==2) +inline T DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>::Interpolate( std::array const& point){ return spline2D(this->GetBinsCenters(placeholders::_0).begin(), this->GetBinsCenters(placeholders::_0).end(), @@ -529,7 +531,8 @@ DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional> template template -inline typename std::enable_if< M==3, T >::type +requires (M==3) +inline T DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>::Interpolate( std::array const& point){ return spline3D(this->GetBinsCenters(placeholders::_0).begin(), this->GetBinsCenters(placeholders::_0).end(), @@ -541,7 +544,8 @@ DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional> template template -inline typename std::enable_if< M==4, T >::type +requires (M==4) +inline T DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>::Interpolate( std::array const& point){ return spline4D( @@ -580,8 +584,8 @@ make_dense_histogram( detail::BackendPolicy, std::array cons //iterable based template< typename T, size_t N , hydra::detail::Backend BACKEND, typename Iterable> -inline typename std::enable_if< hydra::detail::is_iterable::value, -DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>>::type +requires (hydra::detail::Iterable) +inline DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional> make_dense_histogram( detail::BackendPolicy backend, std::array const& grid, std::array const& lowerlimits, std::array const& upperlimits, Iterable&& data){ @@ -591,9 +595,8 @@ make_dense_histogram( detail::BackendPolicy backend, std::array -inline typename std::enable_if< hydra::detail::is_iterable::value&& - hydra::detail::is_iterable::value, -DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>>::type +requires (hydra::detail::Iterable&& hydra::detail::Iterable) +inline DenseHistogram< T, N, detail::BackendPolicy, detail::multidimensional> make_dense_histogram( detail::BackendPolicy backend, std::arrayconst& grid, std::arrayconst& lowerlimits, std::arrayconst& upperlimits, Iterable1&& data, @@ -636,8 +639,8 @@ make_dense_histogram( detail::BackendPolicy, size_t grid, double lowerl //iterable based template< typename T, hydra::detail::Backend BACKEND, typename Iterable> -inline typename std::enable_if< hydra::detail::is_iterable::value, -DenseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional>>::type +requires (hydra::detail::Iterable) +inline DenseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional> make_dense_histogram( detail::BackendPolicy backend, size_t grid, double lowerlimits, double upperlimits, Iterable&& data){ @@ -647,9 +650,8 @@ make_dense_histogram( detail::BackendPolicy backend, size_t grid, } template< typename T, hydra::detail::Backend BACKEND, typename Iterable1,typename Iterable2 > -inline typename std::enable_if< hydra::detail::is_iterable::value&& -hydra::detail::is_iterable::value, -DenseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional>>::type +requires (hydra::detail::Iterable&& hydra::detail::Iterable) +inline DenseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional> make_dense_histogram( detail::BackendPolicy backend, size_t grid, double lowerlimits, double upperlimits, Iterable1&& data, Iterable2&& weights){ diff --git a/hydra/detail/Divide.h b/hydra/detail/Divide.h index 65d8b921f..391fadb46 100644 --- a/hydra/detail/Divide.h +++ b/hydra/detail/Divide.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -116,50 +117,40 @@ hydra::thrust::tuple, // divide: / operator two functors template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value) && -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value), -Divide >::type +requires (detail::HydraCallable && detail::HydraCallable) +inline Divide operator/(T1 const& F1, T2 const& F2) { return Divide(F1, F2); } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Divide< Constant, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Divide< Constant, T> operator/(U const cte, T const& F) { return Constant(cte)/F; } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Divide< Constant, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Divide< Constant, T> operator/( T const& F, U cte) { return F/Constant(cte); } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Divide< Constant>, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Divide< Constant>, T> operator/(hydra::complex const& cte, T const& F) { return Constant >(cte)/F; } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Divide< Constant>, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Divide< Constant>, T> operator/( T const& F, hydra::complex const& cte) { return F/Constant >(cte); @@ -168,10 +159,8 @@ operator/( T const& F, hydra::complex const& cte) // Convenience function template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ), -Divide>::type +requires (detail::HydraCallable && detail::HydraCallable) +inline Divide divide(F1 const& f1, F2 const& f2) { return Divide(f1,f2); diff --git a/hydra/detail/FCN3.inl b/hydra/detail/FCN3.inl index 3d76d506d..1734cd46d 100644 --- a/hydra/detail/FCN3.inl +++ b/hydra/detail/FCN3.inl @@ -128,11 +128,13 @@ public: private: template - typename std::enable_if<(I==nfcns), void>::type + requires ((I==nfcns)) + void load_fcn_parameters_helper(std::vector&){} template - typename std::enable_if< (I::type + requires ((I& pars){ auto vars = hydra::thrust::get(fFCNS).GetParameters().GetVariables(); @@ -153,11 +155,13 @@ private: } template - typename std::enable_if< (I==nfcns), void>::type + requires ((I==nfcns)) + void add_tasks( std::vector const& parameters, std::vector>& ) const {} template - typename std::enable_if< (I::type + requires ((I const& parameters, std::vector>& tasks ) const { tasks.push_back(std::async( diff --git a/hydra/detail/Filter.inl b/hydra/detail/Filter.inl index c0e336acc..24f4cb704 100644 --- a/hydra/detail/Filter.inl +++ b/hydra/detail/Filter.inl @@ -33,8 +33,8 @@ namespace hydra { template -inline typename std::enable_if< hydra::detail::is_iterable::value, -hydra::Range().begin())>>::type +requires (hydra::detail::Iterable) +inline hydra::Range().begin())> filter(Iterable&& container, Functor&& filter) { @@ -46,9 +46,9 @@ filter(Iterable&& container, Functor&& filter) } template -inline typename std::enable_if< hydra::detail::is_iterable::value, -std::pair().begin())>, - hydra::Range().begin())>>>::type +requires (hydra::detail::Iterable) +inline std::pair().begin())>, + hydra::Range().begin())>> segregate(Iterable&& container, Functor&& filter) { diff --git a/hydra/detail/ForEach.inl b/hydra/detail/ForEach.inl index eef834340..682056958 100644 --- a/hydra/detail/ForEach.inl +++ b/hydra/detail/ForEach.inl @@ -35,12 +35,13 @@ #include #include #include +#include namespace hydra { template - typename std::enable_if::value, - Range().begin())>>::type +requires (hydra::detail::Iterable) +Range().begin())> for_each(Iterable&& iterable, Functor const& functor) { hydra::thrust::for_each( std::forward(iterable).begin(), diff --git a/hydra/detail/FunctionArgument.h b/hydra/detail/FunctionArgument.h index 5ccce5812..c9004f569 100644 --- a/hydra/detail/FunctionArgument.h +++ b/hydra/detail/FunctionArgument.h @@ -36,6 +36,20 @@ namespace hydra { namespace detail { +/* + * Helper concepts to reduce the repetition in the function-argument + * operator overloads below. + */ + +// T is a Hydra function argument +template +concept FunctionArg = is_function_argument::value; + +// Arg1 and Arg2 together form a function-argument pack +template +concept FunctionArgPack = is_function_argument_pack::value; + + template struct FunctionArgument { @@ -78,9 +92,8 @@ struct FunctionArgument } template - __hydra_host__ __hydra_device__ - typename std::enable_if< std::is_convertible::value && (!detail::is_function_argument::value), - FunctionArgument&>::type + requires (std::is_convertible_v && (!detail::FunctionArg)) + __hydra_host__ __hydra_device__ FunctionArgument& operator=(T other) { value = other; @@ -88,9 +101,8 @@ struct FunctionArgument } template - __hydra_host__ __hydra_device__ - typename std::enable_if< std::is_convertible::value && (!detail::is_function_argument::value), - FunctionArgument&>::type + requires (std::is_convertible_v && (!detail::FunctionArg)) + __hydra_host__ __hydra_device__ FunctionArgument& operator=(hydra::thrust::device_reference const& other) { value = other; @@ -176,9 +188,8 @@ struct FunctionArgument //============================================================= template - __hydra_host__ __hydra_device__ - typename std::enable_if::value, - FunctionArgument&>::type + requires (std::is_convertible_v) + __hydra_host__ __hydra_device__ FunctionArgument& operator+=( FunctionArgument const & other) { value+=other(); @@ -186,9 +197,8 @@ struct FunctionArgument } template - __hydra_host__ __hydra_device__ - typename std::enable_if::value, - FunctionArgument&>::type + requires (std::is_convertible_v) + __hydra_host__ __hydra_device__ FunctionArgument& operator-=( FunctionArgument const & other) { value-=other(); @@ -196,9 +206,8 @@ struct FunctionArgument } template - __hydra_host__ __hydra_device__ - typename std::enable_if::value, - FunctionArgument&>::type + requires (std::is_convertible_v) + __hydra_host__ __hydra_device__ FunctionArgument& operator*=( FunctionArgument const & other) { value*=other(); @@ -206,9 +215,8 @@ struct FunctionArgument } template - __hydra_host__ __hydra_device__ - typename std::enable_if::value, - FunctionArgument&>::type + requires (std::is_convertible_v) + __hydra_host__ __hydra_device__ FunctionArgument& operator/=( FunctionArgument const & other) { value/=other(); @@ -217,9 +225,8 @@ struct FunctionArgument template - __hydra_host__ __hydra_device__ - typename std::enable_if::value, - FunctionArgument&>::type + requires (std::is_convertible_v) + __hydra_host__ __hydra_device__ FunctionArgument& operator%=( FunctionArgument const & other) { value%=other(); @@ -298,11 +305,9 @@ __hydra_host__ __hydra_device__ \ } \ \ template \ - typename std::enable_if< \ - std::is_base_of< detail::FunctionArgument, T>::value, \ - NAME& >::type \ + requires (std::is_base_of< detail::FunctionArgument, T>::value) \ __hydra_host__ __hydra_device__ \ - operator=(T const& other) \ + NAME& operator=(T const& other) \ { \ \ super_type::operator=(other); \ @@ -319,9 +324,8 @@ namespace hydra { namespace arguments { template -__hydra_host__ __hydra_device__ -typename std::enable_if::value && !detail::is_function_argument::value, -decltype(std::declval()+ std::declval() )>::type +requires (detail::FunctionArg && !detail::FunctionArg) +__hydra_host__ __hydra_device__ decltype(std::declval()+ std::declval() ) operator+( Arg1 const& a1, Arg2 const& a2) { typedef decltype(std::declval()+ @@ -331,9 +335,8 @@ operator+( Arg1 const& a1, Arg2 const& a2) { } template -__hydra_host__ __hydra_device__ -typename std::enable_if::value && !detail::is_function_argument::value, -decltype(std::declval()+ std::declval() )>::type +requires (detail::FunctionArg && !detail::FunctionArg) +__hydra_host__ __hydra_device__ decltype(std::declval()+ std::declval() ) operator+(Arg2 const& a2, Arg1 const& a1 ) { typedef decltype(std::declval()+ @@ -344,10 +347,9 @@ operator+(Arg2 const& a2, Arg1 const& a1 ) { template -__hydra_host__ __hydra_device__ -typename std::enable_if::value, -decltype(std::declval()+ - std::declval() )>::type +requires (detail::FunctionArgPack) +__hydra_host__ __hydra_device__ decltype(std::declval()+ + std::declval() ) operator+( Arg1 const& a1, Arg2 const& a2) { typedef decltype(std::declval()+ @@ -359,9 +361,8 @@ operator+( Arg1 const& a1, Arg2 const& a2) { //--------------- template -__hydra_host__ __hydra_device__ -typename std::enable_if::value && !detail::is_function_argument::value, -decltype(std::declval()- std::declval() )>::type +requires (detail::FunctionArg && !detail::FunctionArg) +__hydra_host__ __hydra_device__ decltype(std::declval()- std::declval() ) operator-( Arg1 const& a1, Arg2 const& a2) { typedef decltype(std::declval()- @@ -371,9 +372,8 @@ operator-( Arg1 const& a1, Arg2 const& a2) { } template -__hydra_host__ __hydra_device__ -typename std::enable_if::value && !detail::is_function_argument::value, -decltype(std::declval()- std::declval() )>::type +requires (detail::FunctionArg && !detail::FunctionArg) +__hydra_host__ __hydra_device__ decltype(std::declval()- std::declval() ) operator-(Arg2 const& a2, Arg1 const& a1 ) { typedef decltype(std::declval()- @@ -383,10 +383,9 @@ operator-(Arg2 const& a2, Arg1 const& a1 ) { } template -__hydra_host__ __hydra_device__ -typename std::enable_if::value, -decltype(std::declval()- - std::declval() )>::type +requires (detail::FunctionArgPack) +__hydra_host__ __hydra_device__ decltype(std::declval()- + std::declval() ) operator-( Arg1 const& a1, Arg2 const& a2) { typedef decltype(std::declval()- @@ -399,9 +398,8 @@ operator-( Arg1 const& a1, Arg2 const& a2) { //---------------- template -__hydra_host__ __hydra_device__ -typename std::enable_if::value && !detail::is_function_argument::value, -decltype(std::declval()* std::declval() )>::type +requires (detail::FunctionArg && !detail::FunctionArg) +__hydra_host__ __hydra_device__ decltype(std::declval()* std::declval() ) operator*( Arg1 const& a1, Arg2 const& a2) { typedef decltype(std::declval()- @@ -411,9 +409,8 @@ operator*( Arg1 const& a1, Arg2 const& a2) { } template -__hydra_host__ __hydra_device__ -typename std::enable_if::value && !detail::is_function_argument::value, -decltype(std::declval()* std::declval() )>::type +requires (detail::FunctionArg && !detail::FunctionArg) +__hydra_host__ __hydra_device__ decltype(std::declval()* std::declval() ) operator*(Arg2 const& a2, Arg1 const& a1 ) { typedef decltype(std::declval()- @@ -423,10 +420,9 @@ operator*(Arg2 const& a2, Arg1 const& a1 ) { } template -__hydra_host__ __hydra_device__ -typename std::enable_if::value, -decltype(std::declval()* - std::declval() )>::type +requires (detail::FunctionArgPack) +__hydra_host__ __hydra_device__ decltype(std::declval()* + std::declval() ) operator*( Arg1 const& a1, Arg2 const& a2) { typedef decltype(std::declval()* @@ -438,9 +434,8 @@ operator*( Arg1 const& a1, Arg2 const& a2) { //---------------- template -__hydra_host__ __hydra_device__ -typename std::enable_if::value && !detail::is_function_argument::value, -decltype(std::declval() / std::declval() )>::type +requires (detail::FunctionArg && !detail::FunctionArg) +__hydra_host__ __hydra_device__ decltype(std::declval() / std::declval() ) operator/( Arg1 const& a1, Arg2 const& a2) { typedef decltype(std::declval()- @@ -450,9 +445,8 @@ operator/( Arg1 const& a1, Arg2 const& a2) { } template -__hydra_host__ __hydra_device__ -typename std::enable_if::value && !detail::is_function_argument::value, -decltype(std::declval() / std::declval() )>::type +requires (detail::FunctionArg && !detail::FunctionArg) +__hydra_host__ __hydra_device__ decltype(std::declval() / std::declval() ) operator/(Arg2 const& a2, Arg1 const& a1 ) { typedef decltype(std::declval()- @@ -462,10 +456,9 @@ operator/(Arg2 const& a2, Arg1 const& a1 ) { } template -__hydra_host__ __hydra_device__ -typename std::enable_if::value, -decltype(std::declval()/ - std::declval() )>::type +requires (detail::FunctionArgPack) +__hydra_host__ __hydra_device__ decltype(std::declval()/ + std::declval() ) operator/( Arg1 const& a1, Arg2 const& a2) { typedef decltype(std::declval()/ @@ -477,14 +470,16 @@ operator/( Arg1 const& a1, Arg2 const& a2) { template -inline typename std::enable_if::value, std::ostream&>::type +requires (detail::FunctionArg) +inline std::ostream& operator<<(std::ostream& s, const hydra::thrust::device_reference& a){ s << typename Arg::name_type(a).Value(); return s; } template -inline typename std::enable_if::value, std::ostream&>::type +requires (detail::FunctionArg) +inline std::ostream& operator<<(std::ostream& s, const Arg& a){ s << a.Value(); return s; diff --git a/hydra/detail/FunctorConcepts.h b/hydra/detail/FunctorConcepts.h new file mode 100644 index 000000000..002d0fa01 --- /dev/null +++ b/hydra/detail/FunctorConcepts.h @@ -0,0 +1,72 @@ +/*---------------------------------------------------------------------------- + * + * Copyright (C) 2016 - 2023 Antonio Augusto Alves Junior + * + * This file is part of Hydra Data Analysis Framework. + * + * Hydra is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Hydra 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Hydra. If not, see . + * + *---------------------------------------------------------------------------*/ + +/* + * FunctorConcepts.h + * + * Created on: 26/06/2026 + * Author: Davide Brundu + */ + +#ifndef FUNCTORCONCEPTS_H_ +#define FUNCTORCONCEPTS_H_ + +#include +#include + +#include +#include + + +namespace hydra { + +namespace detail { + +/** + * @brief Satisfied when @c T is a Hydra functor (see hydra::detail::is_hydra_functor). + */ +template +concept HydraFunctor = is_hydra_functor::value; + +/** + * @brief Satisfied when @c T is a Hydra composite functor (see hydra::detail::is_hydra_composite_functor). + */ +template +concept HydraCompositeFunctor = is_hydra_composite_functor::value; + +/** + * @brief Satisfied when @c T is a Hydra lambda (see hydra::detail::is_hydra_lambda). + */ +template +concept HydraLambda = is_hydra_lambda::value; + +/** + * @brief Satisfied when @c T is a Hydra functor or a Hydra lambda, i.e. a + * callable that can take part in functor arithmetic. + */ +template +concept HydraCallable = HydraFunctor || HydraLambda; + +} // namespace detail + +} // namespace hydra + +#endif /* FUNCTORCONCEPTS_H_ */ diff --git a/hydra/detail/Gather.inl b/hydra/detail/Gather.inl index f5b4c1897..abfe198fb 100644 --- a/hydra/detail/Gather.inl +++ b/hydra/detail/Gather.inl @@ -37,14 +37,17 @@ #include #include #include +#include namespace hydra { template -typename std::enable_if::value - && hydra::detail::is_iterable::value - && hydra::detail::is_iterable::value, -Range().begin())>>::type +requires ( + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable +) +Range().begin())> gather(Iterable_Source&& source, Iterable_Map&& map, Iterable_Target&& target){ hydra::thrust::gather( @@ -59,9 +62,8 @@ gather(Iterable_Source&& source, Iterable_Map&& map, Iterable_Target&& target){ /* template -typename std::enable_if::value - && hydra::detail::is_iterable::value, -Range().begin())>>::type +requires (hydra::detail::Iterable && hydra::detail::Iterable) +Range().begin())> gather(Iterable_Source& source, Range&& map, Iterable_Target& target){ hydra::thrust::gather( source.begin(), source.end(), @@ -71,8 +73,8 @@ gather(Iterable_Source& source, Range&& map, Iterable_Target& targ template -typename std::enable_if::value, -Range().begin())>>::type +requires (hydra::detail::Iterable) +Range().begin())> gather(Range&& source, Range&& map, Iterable_Target& target){ hydra::thrust::gather( source.begin(), source.end(), diff --git a/hydra/detail/GenzMalikRule.h b/hydra/detail/GenzMalikRule.h index 67bc50bb6..3d4baf2d0 100644 --- a/hydra/detail/GenzMalikRule.h +++ b/hydra/detail/GenzMalikRule.h @@ -69,8 +69,9 @@ class GenzMalikRule; * */ template +requires (DIM>1) class GenzMalikRule>: -GenzMalikRuleBase1), void >::type > +GenzMalikRuleBase { typedef hydra::detail::BackendPolicy system_type; diff --git a/hydra/detail/Hash.h b/hydra/detail/Hash.h index b4af9a160..cb7dee782 100644 --- a/hydra/detail/Hash.h +++ b/hydra/detail/Hash.h @@ -69,11 +69,13 @@ namespace hydra { namespace tuple { template< typename T, unsigned int N, unsigned int I> - inline typename std::enable_if< (I == N), void >::type + requires ((I == N)) + inline void hash_tuple_helper(std::size_t&, T const&){ } template< typename T, unsigned int N, unsigned int I=0> - inline typename std::enable_if< (I < N), void >::type + requires ((I < N)) + inline void hash_tuple_helper(std::size_t& seed, T const& _tuple){ hydra::detail::hash_combine(seed, hydra::get(_tuple)); diff --git a/hydra/detail/Iterable_traits.h b/hydra/detail/Iterable_traits.h index edb3f7067..a0781c25e 100644 --- a/hydra/detail/Iterable_traits.h +++ b/hydra/detail/Iterable_traits.h @@ -30,6 +30,7 @@ #define ITERABLE_TRAITS_H_ #include +#include #include namespace hydra { @@ -75,6 +76,11 @@ decltype ( ++std::declval()))&>(), void(*hydra::rbegin(std::declval())),0)> : std::true_type { }; */ + +template +struct are_iterables: std::conditional::value...> >::type{}; + } // namespace detail } // namespace hydra diff --git a/hydra/detail/IteratorConcepts.h b/hydra/detail/IteratorConcepts.h new file mode 100644 index 000000000..70df72660 --- /dev/null +++ b/hydra/detail/IteratorConcepts.h @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------- + * + * Copyright (C) 2016 - 2023 Antonio Augusto Alves Junior + * + * This file is part of Hydra Data Analysis Framework. + * + * Hydra is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Hydra 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Hydra. If not, see . + * + *---------------------------------------------------------------------------*/ + +/* + * IteratorConcepts.h + * + * Created on: 26/06/2026 + * Author: Davide Brundu + */ + +#ifndef ITERATORCONCEPTS_H_ +#define ITERATORCONCEPTS_H_ + +#include +#include + +#include +#include +#include + +namespace hydra { + +namespace detail { + +/** + * @brief Satisfied when @c T models a Hydra iterable, i.e. exposes @c begin() + * and @c end() returning iterators (see hydra::detail::is_iterable). + */ +template +concept Iterable = is_iterable::value; + +/** + * @brief Satisfied when @c Ts model Hydra iterables, i.e. expose @c begin() + * and @c end() returning iterators (see hydra::detail::are_iterables). + */ +template +concept Iterables = are_iterables::value; + +/** + * @brief Satisfied when @c T models a Hydra reverse-iterable, i.e. exposes + * @c rbegin() and @c rend() (see hydra::detail::is_reverse_iterable). + */ +template +concept ReverseIterable = is_reverse_iterable::value; + +/** + * @brief Satisfied when @c T models an iterator (see hydra::detail::is_iterator). + */ +template +concept Iterator = is_iterator::value; + +/** + * @brief Satisfied when @c Ts model iterators (see hydra::detail::are_iterators). + */ +template +concept Iterators = are_iterators::value; + +} // namespace detail + +} // namespace hydra + +#endif /* ITERATORCONCEPTS_H_ */ diff --git a/hydra/detail/IteratorTraits.h b/hydra/detail/IteratorTraits.h index 7ff093f5c..6c4538090 100644 --- a/hydra/detail/IteratorTraits.h +++ b/hydra/detail/IteratorTraits.h @@ -30,6 +30,8 @@ #define ITERATORTRAITS_H_ #include +#include +#include #include #include @@ -57,6 +59,11 @@ struct IteratorTraits }; +template +struct are_iterators: std::conditional::value...> >::type{}; + + } // namespace detail } // namespace hydra diff --git a/hydra/detail/LogLikelihoodFCN1.inl b/hydra/detail/LogLikelihoodFCN1.inl index d46274bb3..986484c50 100644 --- a/hydra/detail/LogLikelihoodFCN1.inl +++ b/hydra/detail/LogLikelihoodFCN1.inl @@ -36,6 +36,7 @@ #include #include #include +#include namespace hydra { @@ -76,7 +77,8 @@ public: } template - inline typename std::enable_if<(M==0), double >::type + requires ((M==0)) + inline double Eval( const std::vector& parameters ) const{ using hydra::thrust::system::detail::generic::select_system; @@ -111,7 +113,8 @@ public: } template - inline typename std::enable_if<(M>0), double >::type + requires ((M>0)) + inline double Eval( const std::vector& parameters ) const{ using hydra::thrust::system::detail::generic::select_system; @@ -150,8 +153,8 @@ public: template< typename Functor, typename Integrator, typename Iterator, typename ...Iterators> -inline typename std::enable_if< detail::is_iterator::value && detail::are_iterators::value, - LogLikelihoodFCN< Pdf, Iterator , Iterators... > >::type +requires (detail::Iterator && detail::Iterators) +inline LogLikelihoodFCN< Pdf, Iterator , Iterators... > make_loglikehood_fcn(Pdf const& pdf, Iterator first, Iterator last, Iterators... weights ) { @@ -161,14 +164,17 @@ make_loglikehood_fcn(Pdf const& pdf, Iterator first, Iterato template< typename Functor, typename Integrator, typename Iterable, typename ...Iterables> -inline typename std::enable_if< (!detail::is_iterator::value) && - ((sizeof...(Iterables)==0) || !detail::are_iterators::value) && - (!hydra::detail::is_hydra_dense_histogram< typename std::remove_reference::type>::value) && - (!hydra::detail::is_hydra_sparse_histogram::type>::value) && - detail::is_iterable::value && detail::are_iterables::value , - LogLikelihoodFCN< Pdf, +requires ( + (!detail::Iterator) && + ((sizeof...(Iterables)==0) || !detail::Iterators) && + (!detail::is_hydra_dense_histogram::type>::value) && + (!detail::is_hydra_sparse_histogram::type>::value) && + (detail::Iterable) && + (detail::Iterables) +) +inline LogLikelihoodFCN< Pdf, decltype(std::declval().begin()), - decltype(std::declval().begin())... >>::type + decltype(std::declval().begin())... > make_loglikehood_fcn(Pdf const& pdf, Iterable&& points, Iterables&&... weights ) { return make_loglikehood_fcn(pdf, @@ -180,11 +186,13 @@ make_loglikehood_fcn(Pdf const& pdf, Iterable&& points, Iter template< typename Functor, typename Integrator, typename Histogram> -inline typename std::enable_if::value || - detail::is_hydra_sparse_histogram::value, -LogLikelihoodFCN< Pdf, +requires ( + detail::is_hydra_dense_histogram::value || + detail::is_hydra_sparse_histogram::value +) +inline LogLikelihoodFCN< Pdf, decltype(std::declval().GetBinsCenters().begin()), - decltype( std::declval().GetBinsContents().begin())>>::type + decltype( std::declval().GetBinsContents().begin())> make_loglikehood_fcn(Pdf const& pdf, Histogram const& points ) { return LogLikelihoodFCN< Pdf, diff --git a/hydra/detail/LogLikelihoodFCN2.inl b/hydra/detail/LogLikelihoodFCN2.inl index 608fb7daf..072ae32c4 100644 --- a/hydra/detail/LogLikelihoodFCN2.inl +++ b/hydra/detail/LogLikelihoodFCN2.inl @@ -34,6 +34,7 @@ #include #include #include +#include namespace hydra { @@ -65,7 +66,8 @@ public: } template - inline typename std::enable_if<(M==0), double >::type + requires ((M==0)) + inline double Eval( const std::vector& parameters ) const{ @@ -105,7 +107,8 @@ public: } template - inline typename std::enable_if<(M>0), double >::type + requires ((M>0)) + inline double Eval( const std::vector& parameters ) const{ using hydra::thrust::system::detail::generic::select_system; @@ -147,8 +150,11 @@ public: template -inline typename std::enable_if< hydra::detail::is_iterator::value && detail::are_iterators::value, -LogLikelihoodFCN< PDFSumExtendable, Iterator,Iterators... >>::type +requires ( + detail::Iterator && + detail::Iterators +) +inline LogLikelihoodFCN< PDFSumExtendable, Iterator,Iterators... > make_loglikehood_fcn(PDFSumExtendable const& functor, Iterator first, Iterator last, Iterators... weights ) { return LogLikelihoodFCN< PDFSumExtendable, Iterator, Iterators...>( functor, first, last, weights...); @@ -156,14 +162,17 @@ make_loglikehood_fcn(PDFSumExtendable const& functor, Iterator first, I template -inline typename std::enable_if< (!detail::is_iterator::value) && - ((sizeof...(Iterables)==0) || !detail::are_iterators::value) && - (!hydra::detail::is_hydra_dense_histogram< typename std::remove_reference::type>::value) && //is not dense/sparse histogram - (!hydra::detail::is_hydra_sparse_histogram::type>::value) && - detail::is_iterable::value && detail::are_iterables::value , -LogLikelihoodFCN< PDFSumExtendable, +requires ( + (!detail::Iterator) && + ((sizeof...(Iterables)==0) || !detail::Iterators) && + (!detail::is_hydra_dense_histogram< typename std::remove_reference::type>::value) && + (!detail::is_hydra_sparse_histogram< typename std::remove_reference::type>::value) && + (detail::Iterable) && + (detail::Iterables) +) +inline LogLikelihoodFCN< PDFSumExtendable, decltype(std::declval().begin() ), - decltype(std::declval().begin())... > >::type + decltype(std::declval().begin())... > make_loglikehood_fcn(PDFSumExtendable const& functor, Iterable&& points, Iterables&&... weights ){ return make_loglikehood_fcn( functor, @@ -173,11 +182,13 @@ make_loglikehood_fcn(PDFSumExtendable const& functor, Iterable&& points } template -inline typename std::enable_if::value || - detail::is_hydra_sparse_histogram::value, - LogLikelihoodFCN< PDFSumExtendable, +requires ( + detail::is_hydra_dense_histogram::value || + detail::is_hydra_sparse_histogram::value +) +inline LogLikelihoodFCN< PDFSumExtendable, decltype(std::declval().GetBinsCenters().begin()), - decltype(std::declval().GetBinsContents().begin()) >>::type + decltype(std::declval().GetBinsContents().begin()) > make_loglikehood_fcn(PDFSumExtendable const& functor, Histogram const& points) { return LogLikelihoodFCN< PDFSumExtendable, diff --git a/hydra/detail/LogLikelihoodFCN3.inl b/hydra/detail/LogLikelihoodFCN3.inl index 9e657277f..2f661153e 100644 --- a/hydra/detail/LogLikelihoodFCN3.inl +++ b/hydra/detail/LogLikelihoodFCN3.inl @@ -38,6 +38,7 @@ #include #include +#include namespace hydra { @@ -70,7 +71,8 @@ public: template - inline typename std::enable_if<(M==0), double >::type + requires ((M==0)) + inline double Eval( const std::vector& parameters ) const{ using hydra::thrust::system::detail::generic::select_system; @@ -110,7 +112,8 @@ public: } template - inline typename std::enable_if<(M>0), double >::type + requires ((M>0)) + inline double Eval( const std::vector& parameters ) const{ using hydra::thrust::system::detail::generic::select_system; @@ -154,22 +157,25 @@ public: template -inline typename std::enable_if< hydra::detail::is_iterator::value && detail::are_iterators::value, -LogLikelihoodFCN< PDFSumNonExtendable, Iterator,Iterators... >>::type +requires (detail::Iterator && detail::Iterators) +inline LogLikelihoodFCN< PDFSumNonExtendable, Iterator,Iterators... > make_loglikehood_fcn(PDFSumNonExtendableconst& pdf, Iterator first, Iterator last, Iterators... weights) { return LogLikelihoodFCN< PDFSumNonExtendable, Iterator,Iterators... >(pdf,first,last,weights...); } template -inline typename std::enable_if< (!detail::is_iterator::value) && - ((sizeof...(Iterables)==0) || !detail::are_iterators::value) && - (!hydra::detail::is_hydra_dense_histogram::type>::value) && - (!hydra::detail::is_hydra_sparse_histogram::type>::value) && - hydra::detail::is_iterable::value && detail::are_iterables::value, -LogLikelihoodFCN< PDFSumNonExtendable, +requires ( + (!detail::Iterator) && + ((sizeof...(Iterables)==0) || !detail::Iterators) && + (!detail::is_hydra_dense_histogram::type>::value) && + (!detail::is_hydra_sparse_histogram::type>::value) && + (detail::Iterable) && + (detail::Iterables) +) +inline LogLikelihoodFCN< PDFSumNonExtendable, decltype(std::declval().begin()), - decltype(std::declval().begin())... > >::type + decltype(std::declval().begin())... > make_loglikehood_fcn(PDFSumNonExtendable const& functor, Iterable&& points, Iterables&&... weights ) { return make_loglikehood_fcn( functor, @@ -179,11 +185,13 @@ make_loglikehood_fcn(PDFSumNonExtendable const& functor, Iterable&& poi } template -inline typename std::enable_if::value || - detail::is_hydra_sparse_histogram::value, - LogLikelihoodFCN< PDFSumNonExtendable, +requires ( + detail::is_hydra_dense_histogram::value || + detail::is_hydra_sparse_histogram::value +) +inline LogLikelihoodFCN< PDFSumNonExtendable, decltype(std::declval().GetBinsCenters().begin()), - decltype(std::declval().GetBinsContents().begin()) >>::type + decltype(std::declval().GetBinsContents().begin()) > make_loglikehood_fcn(PDFSumNonExtendable const& functor, Histogram const& points) { diff --git a/hydra/detail/Minus.h b/hydra/detail/Minus.h index aefd09a2d..f0f9a66bc 100644 --- a/hydra/detail/Minus.h +++ b/hydra/detail/Minus.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -120,50 +121,40 @@ hydra::thrust::tuple, // + operator two functors template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ), -Minus >::type +requires (detail::HydraCallable && detail::HydraCallable) +inline Minus operator-(T1 const& F1, T2 const& F2) { return Minus(F1, F2); } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Minus< Constant, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Minus< Constant, T> operator-(U const cte, T const& F) { return Constant(cte)-F; } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Minus< Constant, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Minus< Constant, T> operator-( T const& F, U cte) { return F-Constant(cte); } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Minus< Constant>, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Minus< Constant>, T> operator-(hydra::complex const& cte, T const& F) { return Constant >(cte)-F; } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Minus< Constant, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Minus< Constant, T> operator-( T const& F, hydra::complex const& cte) { return F-Constant >(cte); @@ -171,10 +162,8 @@ operator-( T const& F, hydra::complex const& cte) // Convenience function template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ), -Minus>::type +requires (detail::HydraCallable && detail::HydraCallable) +inline Minus minus(F1 const& f1, F2 const& f2) { return Minus(f1,f2); diff --git a/hydra/detail/Multiply.h b/hydra/detail/Multiply.h index f5d2241f8..6423855fc 100644 --- a/hydra/detail/Multiply.h +++ b/hydra/detail/Multiply.h @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -134,50 +135,40 @@ hydra::thrust::tuple, // multiplication: * operator two functors template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ), -Multiply >::type +requires (detail::HydraCallable && detail::HydraCallable) +inline Multiply operator*(T1 const& F1, T2 const& F2) { return Multiply(F1, F2); } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Multiply< Constant, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Multiply< Constant, T> operator*(U const cte, T const& F) { return Constant(cte)*F; } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Multiply< Constant, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Multiply< Constant, T> operator*( T const& F, U cte) { return Constant(cte)*F; } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Multiply< Constant>, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Multiply< Constant>, T> operator*(hydra::complex const& cte, T const& F) { return Constant >(cte)*F; } template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Multiply< Constant, T> >::type +requires (detail::HydraCallable && (std::is_arithmetic_v)) +inline Multiply< Constant, T> operator*( T const& F, hydra::complex const& cte) { return Constant >(cte)*F; @@ -186,12 +177,8 @@ operator*( T const& F, hydra::complex const& cte) // Convenience function // Convenience function template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -detail::all_true< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value )...>::value, -Multiply>::type +requires (detail::HydraCallable && detail::HydraCallable && (detail::HydraCallable && ...)) +inline Multiply multiply(F1 const& f1, F2 const& f2, Fs const&... functors ) { return Multiply(f1,f2, functors ... ); diff --git a/hydra/detail/Parameters.h b/hydra/detail/Parameters.h index 33df41bdd..b9fa13446 100644 --- a/hydra/detail/Parameters.h +++ b/hydra/detail/Parameters.h @@ -39,6 +39,7 @@ #include #include #include +#include namespace hydra { @@ -174,8 +175,8 @@ class Parameters{ return &fParameters[0]; } - template::value, void>::type> + template + requires (std::integral) __hydra_host__ __hydra_device__ inline const hydra::Parameter& GetParameter(Int i) const { return fParameters[i]; @@ -192,8 +193,8 @@ class Parameters{ return fParameters[i] ; } - template::value, void>::type> + template + requires (std::integral) __hydra_host__ __hydra_device__ inline hydra::Parameter& Parameter(Int i) { return fParameters[i]; @@ -210,8 +211,8 @@ class Parameters{ return fParameters[i] ; } - template::value, void>::type> + template + requires (std::integral) __hydra_host__ __hydra_device__ inline void SetParameter(Int i, hydra::Parameter const& value) { fParameters[i]=value; @@ -223,8 +224,8 @@ class Parameters{ #endif } - template::value, void>::type> + template + requires (std::integral) __hydra_host__ __hydra_device__ inline void SetParameter(Int i, double value) { fParameters[i]=value; @@ -263,8 +264,8 @@ class Parameters{ Update(); } - template::value, void>::type> + template + requires (std::integral) __hydra_host__ __hydra_device__ inline GReal_t operator[](Int i) const { return (GReal_t ) fParameters[i]; diff --git a/hydra/detail/ParametersCompositeFunctor.h b/hydra/detail/ParametersCompositeFunctor.h index a041eb040..0760ae092 100644 --- a/hydra/detail/ParametersCompositeFunctor.h +++ b/hydra/detail/ParametersCompositeFunctor.h @@ -40,6 +40,7 @@ #include #include #include +#include namespace hydra { @@ -119,8 +120,8 @@ class ParametersCompositeFunctor } - template::value, void>::type> + template + requires (std::integral) inline const hydra::Parameter& GetParameter(Int i) const { std::vector _parameters; @@ -143,8 +144,8 @@ class ParametersCompositeFunctor return *(_parameters[i]) ; } - template::value, void>::type> + template + requires (std::integral) inline hydra::Parameter& Parameter(Int i) { std::vector _parameters; @@ -167,8 +168,8 @@ class ParametersCompositeFunctor } - template::value, void>::type> + template + requires (std::integral) inline void SetParameter(Int i, hydra::Parameter const& value) { std::vector _parameters; @@ -177,8 +178,8 @@ class ParametersCompositeFunctor *(_parameters[i])=value; } - template::value, void>::type> + template + requires (std::integral) inline void SetParameter(Int i, double value) { std::vector _parameters; detail::add_parameters_in_tuple(_parameters, fFtorTuple ); diff --git a/hydra/detail/PhaseSpace.inl b/hydra/detail/PhaseSpace.inl index 4f7197f78..d46ecd532 100644 --- a/hydra/detail/PhaseSpace.inl +++ b/hydra/detail/PhaseSpace.inl @@ -35,6 +35,7 @@ #define _PHASESPACE_INL_ #include +#include namespace hydra { @@ -313,8 +314,8 @@ void PhaseSpace::Evaluate( IteratorMother mbegin, template template -inline typename std::enable_if< hydra::detail::is_iterable::value, -hydra::Range().begin())>>::type +requires (detail::Iterable) +inline hydra::Range().begin())> PhaseSpace::Evaluate(Vector4R const& mother, Iterable&& result, FUNCTOR const& ...functors) { @@ -330,9 +331,8 @@ PhaseSpace::Evaluate(Vector4R const& mother, Iterable&& result, template template -inline typename std::enable_if< hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value, - hydra::Range().begin())>>::type +requires (detail::Iterable && detail::Iterable) +inline hydra::Range().begin())> PhaseSpace::Evaluate( IterableMother&& mothers, Iterable&& result, FUNCTOR const& ...functors) { @@ -376,8 +376,8 @@ void PhaseSpace::Generate( Iterator1 begin, Iterator1 end, Iterator2 dau template template -inline typename std::enable_if< hydra::detail::is_iterable::value, - hydra::Range().begin())>>::type +requires (detail::Iterable) +inline hydra::Range().begin())> PhaseSpace::Generate(Vector4R const& mother, Iterable&& events){ /** * Run the generator and calculate the maximum weight. It takes as input the fourvector of the mother particle @@ -395,9 +395,8 @@ PhaseSpace::Generate(Vector4R const& mother, Iterable&& events){ template template -inline typename std::enable_if< hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value, - hydra::Range().begin())>>::type +requires (detail::Iterable && detail::Iterable) +inline hydra::Range().begin())> PhaseSpace::Generate( IterableMothers&& mothers, Iterable&& daughters){ /** * Run the generator and calculate the maximum weight. It takes as input the device vector with the four-vectors of the mother particle diff --git a/hydra/detail/QuasiRandomBase.h b/hydra/detail/QuasiRandomBase.h index 2340f5bd1..8a24f247e 100644 --- a/hydra/detail/QuasiRandomBase.h +++ b/hydra/detail/QuasiRandomBase.h @@ -125,9 +125,8 @@ class quasi_random_base //!Fills a range with quasi-random values. template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - sizeof...(T)==LatticeT::lattice_dimension, void>::type + requires (sizeof...(T)==LatticeT::lattice_dimension) + __hydra_host__ __hydra_device__ inline void generate(hydra::tuple& data){ generate_helper(data); } @@ -227,13 +226,13 @@ class quasi_random_base private: template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (I== LatticeT::lattice_dimension), void>::type + requires ((I== LatticeT::lattice_dimension)) + __hydra_host__ __hydra_device__ inline void generate_helper(T& ){ } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (I< LatticeT::lattice_dimension), void>::type + requires ((I< LatticeT::lattice_dimension)) + __hydra_host__ __hydra_device__ inline void generate_helper(T& data){ hydra::get(data)=this->operator()(); generate_helper(data); diff --git a/hydra/detail/Random.inl b/hydra/detail/Random.inl index 52ced8ac2..c2fa69e73 100644 --- a/hydra/detail/Random.inl +++ b/hydra/detail/Random.inl @@ -40,10 +40,11 @@ namespace hydra{ template -typename std::enable_if< - detail::random::is_iterator::value && detail::random::is_iterator::value, - Range ->::type +requires ( + detail::random::Iterator && + detail::random::Iterator +) +Range unweight( hydra::thrust::detail::execution_policy_base const& policy, IteratorData data_begin, IteratorData data_end, IteratorWeight weights_begin, double max_pdf, size_t rng_seed, size_t rng_jump) { @@ -70,10 +71,11 @@ unweight( hydra::thrust::detail::execution_policy_base const& pol template -typename std::enable_if< - detail::random::is_iterator::value && detail::random::is_iterator::value, - Range ->::type +requires ( + detail::random::Iterator && + detail::random::Iterator +) +Range unweight( detail::BackendPolicy const& policy, IteratorData data_begin, IteratorData data_end, IteratorWeight weights_begin, double max_pdf, size_t rng_seed, size_t rng_jump) { @@ -83,9 +85,11 @@ unweight( detail::BackendPolicy const& policy, IteratorData data_begin, } template< typename RNG, typename IteratorData, typename IteratorWeight> -typename std::enable_if< -detail::random::is_iterator::value && detail::random::is_iterator::value, -Range >::type +requires ( + detail::random::Iterator && + detail::random::Iterator +) +Range unweight(IteratorData data_begin, IteratorData data_end , IteratorWeight weights_begin, double max_pdf, size_t rng_seed, size_t rng_jump) { @@ -102,9 +106,11 @@ unweight(IteratorData data_begin, IteratorData data_end , IteratorWeight weights } template -typename std::enable_if< -detail::random::is_iterable::value && detail::random::is_iterable::value, -Range< decltype(std::declval().begin())> >::type +requires ( + detail::random::Iterable && + detail::random::Iterable +) +Range< decltype(std::declval().begin())> unweight( hydra::detail::BackendPolicy const& policy, IterableData&& data, IterableWeight&& weights, double max_pdf, size_t rng_seed, size_t rng_jump) { @@ -113,8 +119,11 @@ unweight( hydra::detail::BackendPolicy const& policy, IterableData&& d } template< typename RNG, typename IterableData, typename IterableWeight> -typename std::enable_if::value && detail::random::is_iterable::value, -Range< decltype(std::declval().begin())>>::type +requires ( + detail::random::Iterable && + detail::random::Iterable +) +Range< decltype(std::declval().begin())> unweight( IterableData&& data, IterableWeight&& weights, double max_pdf, size_t rng_seed, size_t rng_jump) { @@ -134,10 +143,11 @@ unweight( IterableData&& data, IterableWeight&& weights, template< typename RNG, typename Functor, typename Iterator, typename DerivedPolicy> -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterator::value, - Range ->::type +requires ( + detail::random::Callable && + detail::random::Iterator +) +Range unweight(hydra::thrust::detail::execution_policy_base const& policy, Iterator begin, Iterator end, Functor const& functor, double max_pdf, size_t rng_seed, size_t rng_jump) { @@ -174,10 +184,11 @@ unweight(hydra::thrust::detail::execution_policy_base const& pol template< typename RNG, typename Functor, typename Iterator, hydra::detail::Backend BACKEND> -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterator::value, - Range ->::type +requires ( + detail::random::Callable && + detail::random::Iterator +) +Range unweight( detail::BackendPolicy const& policy, Iterator begin, Iterator end, Functor const& functor, double max_pdf, size_t rng_seed, size_t rng_jump) { @@ -187,10 +198,11 @@ unweight( detail::BackendPolicy const& policy, Iterator begin, Iterator } template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterator::value, - Range ->::type +requires ( + detail::random::Callable && + detail::random::Iterator +) +Range unweight( Iterator begin, Iterator end, Functor const& functor, double max_pdf, size_t rng_seed, size_t rng_jump) { typedef typename hydra::thrust::iterator_system< Iterator>::type system_data_type; @@ -199,10 +211,11 @@ unweight( Iterator begin, Iterator end, Functor const& functor, double max_pdf, template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterable::value , - Range< decltype(std::declval().begin())> ->::type +requires ( + detail::random::Callable && + detail::random::Iterable +) +Range< decltype(std::declval().begin())> unweight( hydra::detail::BackendPolicy const& policy, Iterable&& iterable, Functor const& functor, double max_pdf, size_t rng_seed, size_t rng_jump) { @@ -212,10 +225,11 @@ unweight( hydra::detail::BackendPolicy const& policy, Iterable&& iterab } template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterable::value , - Range< decltype(std::declval().begin())> ->::type +requires ( + detail::random::Callable && + detail::random::Iterable +) +Range< decltype(std::declval().begin())> unweight( Iterable&& iterable, Functor const& functor, double max_pdf, size_t rng_seed, size_t rng_jump) { @@ -227,9 +241,11 @@ unweight( Iterable&& iterable, Functor const& functor, double max_pdf, size_t rn // //--------------------------------------------------------------- template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterator::value, - Range >::type +requires ( + detail::random::Callable && + detail::random::Iterator +) +Range sample(hydra::thrust::detail::execution_policy_base const& policy, Iterator begin, Iterator end, double min, double max, Functor const& functor, size_t seed, size_t rng_jump) { @@ -271,9 +287,11 @@ sample(hydra::thrust::detail::execution_policy_base const& policy } template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterator::value, -Range >::type +requires ( + detail::random::Callable && + detail::random::Iterator +) +Range sample(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, double min, double max, Functor const& functor, size_t seed, size_t rng_jump) @@ -283,9 +301,11 @@ sample(hydra::detail::BackendPolicy const& policy, } template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterator::value, -Range >::type +requires ( + detail::random::Callable && + detail::random::Iterator +) +Range sample(Iterator begin, Iterator end , double min, double max, Functor const& functor, size_t seed, size_t rng_jump) { @@ -296,9 +316,11 @@ sample(Iterator begin, Iterator end , double min, double max, } template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterable::value , -Range< decltype(std::declval().begin())>>::type +requires ( + detail::random::Callable && + detail::random::Iterable +) +Range< decltype(std::declval().begin())> sample(Iterable&& output, double min, double max, Functor const& functor, size_t seed, size_t rng_jump) { return sample(std::forward(output).begin(), std::forward(output).end(), @@ -307,10 +329,11 @@ sample(Iterable&& output, double min, double max, Functor const& functor, size_t template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterator::value, - Range ->::type +requires ( + detail::random::Callable && + detail::random::Iterator +) +Range sample( hydra::thrust::detail::execution_policy_base const& policy, Iterator begin, Iterator end , std::array const& min, std::array const& max, @@ -351,9 +374,11 @@ sample( hydra::thrust::detail::execution_policy_base const& poli } template -typename std::enable_if< -detail::random::is_callable::value && detail::random::is_iterator::value, -Range >::type +requires ( + detail::random::Callable && + detail::random::Iterator +) +Range sample(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end , std::arrayconst& min, std::arrayconst& max, @@ -364,10 +389,11 @@ sample(hydra::detail::BackendPolicy const& policy, } template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterator::value, - Range ->::type +requires ( + detail::random::Callable && + detail::random::Iterator +) +Range sample(Iterator begin, Iterator end , std::arrayconst& min, std::arrayconst& max, Functor const& functor, size_t seed, size_t rng_jump) { @@ -379,11 +405,12 @@ sample(Iterator begin, Iterator end , std::arrayconst& min, std::array template -typename std::enable_if< -detail::random::is_callable::value && -detail::random::is_iterator::value && -detail::is_tuple_type< decltype(*std::declval())>::value, -Range >::type +requires ( + detail::random::Callable && + detail::random::Iterator && + detail::is_tuple_type< decltype(*std::declval())>::value +) +Range sample(Iterator begin, Iterator end , typename Functor::argument_type const& min, typename Functor::argument_type const& max, Functor const& functor, size_t seed, size_t rng_jump) @@ -400,10 +427,11 @@ sample(Iterator begin, Iterator end , } template -typename std::enable_if< - detail::random::is_callable::value && detail::random::is_iterable::value , - Range< decltype(std::declval().begin())> ->::type +requires ( + detail::random::Callable && + detail::random::Iterable +) +Range< decltype(std::declval().begin())> sample(Iterable&& output , std::arrayconst& min, std::arrayconst& max, Functor const& functor, size_t seed, size_t rng_jump) { @@ -412,11 +440,12 @@ sample(Iterable&& output , std::arrayconst& min, std::arrayc } template -typename std::enable_if< -detail::random::is_callable::value && -detail::random::is_iterable::value && -detail::is_tuple_type< decltype(*std::declval().begin())>::value , -Range< decltype(std::declval().begin())>>::type +requires ( + detail::random::Callable && + detail::random::Iterable && + detail::is_tuple_type< decltype(*std::declval().begin())>::value +) +Range< decltype(std::declval().begin())> sample( Iterable&& output , typename Functor::argument_type const& min,typename Functor::argument_type const& max, Functor const& functor, size_t seed, size_t rng_jump) diff --git a/hydra/detail/RandomConcepts.h b/hydra/detail/RandomConcepts.h new file mode 100644 index 000000000..766aeea10 --- /dev/null +++ b/hydra/detail/RandomConcepts.h @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------------- + * + * Copyright (C) 2016 - 2023 Antonio Augusto Alves Junior + * + * This file is part of Hydra Data Analysis Framework. + * + * Hydra is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Hydra 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Hydra. If not, see . + * + *---------------------------------------------------------------------------*/ + +/* + * RandomConcepts.h + * + * Created on: 14/03/2025 + * Author: Davide Brundu + */ + +#ifndef RANDOMCONCEPTS_H_ +#define RANDOMCONCEPTS_H_ + +#include +#include + +#include +#include +#include +#include + +namespace hydra { + +namespace detail { + +template +concept HasRngFormula = has_rng_formula::value; + +template +concept IsRngFormulaConvertible = requires (Engine& engine, const FUNCTOR& functor) { + { RngFormula().Generate(engine, functor) } -> std::convertible_to::value_type>; +}; + +template +concept NotConvertibleToIteratorValue = + !std::convertible_to< + decltype(RngFormula().Generate(std::declval(), std::declval())), + typename std::iterator_traits::value_type>; + +namespace random { + +/** + * @brief Satisfied when @c T is accepted as an iterator argument by the random + * generation/sampling overloads (see hydra::detail::random::is_iterator). + */ +template +concept Iterator = is_iterator::value; + +/** + * @brief Satisfied when @c T is accepted as an iterable argument by the random + * generation/sampling overloads (see hydra::detail::random::is_iterable). + */ +template +concept Iterable = is_iterable::value; + +/** + * @brief Satisfied when @c T is a callable (functor/lambda) accepted by the + * random generation/sampling overloads (see hydra::detail::random::is_callable). + */ +template +concept Callable = is_callable::value; + +/** + * @brief Satisfied when @c Functor has an RngFormula whose result is convertible + * to @c Iterable's value type (see hydra::detail::random::is_matching_iterable). + */ +template +concept MatchingIterable = is_matching_iterable::value; + +} // namespace random + +} // namespace detail + +} // namespace hydra + + + +#endif /* RANDOMCONCEPTS_H_ */ diff --git a/hydra/detail/RandomFill.inl b/hydra/detail/RandomFill.inl index 3ad95067e..a0fc90318 100644 --- a/hydra/detail/RandomFill.inl +++ b/hydra/detail/RandomFill.inl @@ -37,7 +37,6 @@ #define RANDOMFILL_INL_ - namespace hydra{ /** @@ -47,12 +46,10 @@ namespace hydra{ * @param end ending of the range storing the generated values * @param functor distribution to be sampled */ - template< typename Engine, hydra::detail::Backend BACKEND, typename Iterator, typename FUNCTOR > - typename std::enable_if< hydra::detail::has_rng_formula::value && std::is_convertible< - decltype(std::declval>().Generate( std::declval(), std::declval())), - typename hydra::thrust::iterator_traits::value_type - >::value, void>::type - fill_random(hydra::detail::BackendPolicy const& policy, + template + requires hydra::detail::HasRngFormula && + hydra::detail::IsRngFormulaConvertible + void fill_random(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed, size_t rng_jump) { using hydra::thrust::system::detail::generic::select_system; @@ -63,7 +60,7 @@ namespace hydra{ typedef typename hydra::thrust::detail::remove_reference< decltype(select_system( system, _policy ))>::type common_system_type; - + hydra::thrust::tabulate( common_system_type(), begin, end, detail::Sampler(functor, seed, rng_jump) ); } @@ -75,11 +72,9 @@ namespace hydra{ * @param functor distribution to be sampled */ template< typename Engine, typename Iterator, typename FUNCTOR > - typename std::enable_if< hydra::detail::has_rng_formula::value && std::is_convertible< - decltype(std::declval>().Generate( std::declval(), std::declval())), - typename hydra::thrust::iterator_traits::value_type - >::value, void>::type - fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed, size_t rng_jump) + requires hydra::detail::HasRngFormula && + hydra::detail::IsRngFormulaConvertible + void fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed, size_t rng_jump) { using hydra::thrust::system::detail::generic::select_system; typedef typename hydra::thrust::iterator_system::type system_t; @@ -95,7 +90,8 @@ namespace hydra{ * @param functor distribution to be sampled */ template< typename Engine, hydra::detail::Backend BACKEND, typename Iterable, typename FUNCTOR > - typename std::enable_if< detail::random::is_matching_iterable::value, void>::type + requires (detail::random::MatchingIterable) + void fill_random(hydra::detail::BackendPolicy const& policy, Iterable&& iterable, FUNCTOR const& functor, size_t seed, size_t rng_jump){ @@ -110,8 +106,8 @@ namespace hydra{ * @param functor distribution to be sampled */ template< typename Engine, typename Iterable, typename FUNCTOR > - typename std::enable_if< detail::random::is_matching_iterable::value, - void>::type + requires (detail::random::MatchingIterable) + void fill_random(Iterable&& iterable, FUNCTOR const& functor, size_t seed, size_t rng_jump){ fill_random(std::forward(iterable).begin(), @@ -123,8 +119,8 @@ namespace hydra{ * @brief Fall back function if RngFormula is not implemented for the requested functor */ template< typename Engine, hydra::detail::Backend BACKEND, typename Iterator, typename FUNCTOR > - typename std::enable_if< !hydra::detail::has_rng_formula::value , void>::type - fill_random(hydra::detail::BackendPolicy const& policy, + requires (!hydra::detail::HasRngFormula) + void fill_random(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed, size_t rng_jump) { @@ -134,13 +130,13 @@ namespace hydra{ " which will deploy different strategy \n.") } - + /** * @brief Fall back function if RngFormula is not implemented for the requested functor */ template< typename Engine, typename Iterator, typename FUNCTOR > - typename std::enable_if< !hydra::detail::has_rng_formula::value , void>::type - fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed, size_t rng_jump) + requires (!hydra::detail::HasRngFormula) + void fill_random(Iterator begin, Iterator end, FUNCTOR const& functor, size_t seed, size_t rng_jump) { HYDRA_STATIC_ASSERT( int(std::is_class::value) ==-1 , @@ -149,16 +145,14 @@ namespace hydra{ " which will deploy different strategy ") } - + /** * @brief Fall back function if RngFormula::Generate() return value is not convertible to functor return value */ template< typename Engine, hydra::detail::Backend BACKEND, typename Iterator, typename FUNCTOR > - typename std::enable_if< !std::is_convertible< - decltype(std::declval>().Generate( std::declval(), std::declval())), - typename std::iterator_traits::value_type - >::value && hydra::detail::has_rng_formula::value, void>::type - fill_random(hydra::detail::BackendPolicy const& policy, + requires hydra::detail::HasRngFormula && + hydra::detail::NotConvertibleToIteratorValue + void fill_random(hydra::detail::BackendPolicy const& policy, Iterator begin, Iterator end, FUNCTOR const& funct, size_t seed, size_t rng_jump) { HYDRA_STATIC_ASSERT( int(std::is_class::value) ==-1 , @@ -169,21 +163,20 @@ namespace hydra{ * @brief Fall back function if RngFormula::Generate() return value is not convertible to functor return value */ template< typename Engine, typename Iterator, typename FUNCTOR > - typename std::enable_if< !std::is_convertible< - decltype(std::declval>().Generate( std::declval(), std::declval())), - typename std::iterator_traits::value_type - >::value && hydra::detail::has_rng_formula::value, void>::type - fill_random(Iterator begin, Iterator end, FUNCTOR const& funct, size_t seed, size_t rng_jump) + requires hydra::detail::HasRngFormula && + hydra::detail::NotConvertibleToIteratorValue + void fill_random(Iterator begin, Iterator end, FUNCTOR const& funct, size_t seed, size_t rng_jump) { HYDRA_STATIC_ASSERT( int(std::is_class::value) ==-1 , " Generated objects can't be stored in this container. " ) } - + /** * @brief Fall back function if the argument is not an Iterable or if it is not convertible to the Functor return value */ template< typename Engine, hydra::detail::Backend BACKEND, typename Iterable, typename FUNCTOR > - typename std::enable_if< !(detail::random::is_matching_iterable::value), void>::type + requires (!detail::random::MatchingIterable) + void fill_random(hydra::detail::BackendPolicy const& policy, Iterable&& iterable, FUNCTOR const& functor, size_t seed, size_t rng_jump) { @@ -197,7 +190,8 @@ namespace hydra{ * @brief Fall back function if the argument is not an Iterable or if it is not convertible to the Functor return value */ template< typename Engine, typename Iterable, typename FUNCTOR > - typename std::enable_if::value, void>::type + requires (!detail::random::MatchingIterable) + void fill_random(Iterable&& iterable, FUNCTOR const& functor, size_t seed, size_t rng_jump) { HYDRA_STATIC_ASSERT( int(std::is_class::value) ==-1 , diff --git a/hydra/detail/RandomIteratorTraits.h b/hydra/detail/RandomIteratorTraits.h new file mode 100644 index 000000000..844b2edd3 --- /dev/null +++ b/hydra/detail/RandomIteratorTraits.h @@ -0,0 +1,103 @@ +/*---------------------------------------------------------------------------- + * + * Copyright (C) 2016 - 2023 Antonio Augusto Alves Junior + * + * This file is part of Hydra Data Analysis Framework. + * + * Hydra is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Hydra 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Hydra. If not, see . + * + *---------------------------------------------------------------------------*/ + +/* + * RandomIteratorTraits.h + * + * Created on: 29/06/2026 + * Author: Davide Brundu + * + * Type traits used to classify the arguments accepted by the random + * generation/sampling overloads (an iterator, an iterable, a callable, or a + * functor whose RngFormula matches an iterable's value type). Kept separate + * from the engine-level hydra/detail/RandomTraits.h. + */ + +#ifndef RANDOMITERATORTRAITS_H_ +#define RANDOMITERATORTRAITS_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace hydra { + +namespace detail { + +namespace random { + +template +struct is_iterator: std::conditional< + !hydra::detail::is_hydra_composite_functor::value && + !hydra::detail::is_hydra_functor::value && + !hydra::detail::is_hydra_lambda::value && + !hydra::detail::is_iterable::value && + hydra::detail::is_iterator::value, + std::true_type, + std::false_type >::type {}; + +template +struct is_iterable: std::conditional< + !hydra::detail::is_hydra_composite_functor::value && + !hydra::detail::is_hydra_functor::value && + !hydra::detail::is_hydra_lambda::value && + hydra::detail::is_iterable::value && + !hydra::detail::is_iterator::value, + std::true_type, + std::false_type >::type {}; + +template +struct is_callable: std::conditional< + (hydra::detail::is_hydra_composite_functor::value || + hydra::detail::is_hydra_functor::value || + hydra::detail::is_hydra_lambda::value ) && + !hydra::detail::is_iterable::value && + !hydra::detail::is_iterator::value, + std::true_type, + std::false_type >::type {}; + +template< typename Engine, typename Functor, typename Iterable> +struct is_matching_iterable: std::conditional< + hydra::detail::is_iterable::value && + !hydra::detail::is_iterator::value && + (hydra::detail::is_hydra_composite_functor::value || + hydra::detail::is_hydra_functor::value || + hydra::detail::is_hydra_lambda::value ) && + hydra::detail::has_rng_formula::value && + std::is_convertible< + decltype(std::declval>().Generate( std::declval(), std::declval())), + typename hydra::thrust::iterator_traits().begin())>::value_type>::value, + std::true_type, std::false_type +>::type{}; + +} // namespace random + +} // namespace detail + +} // namespace hydra + +#endif /* RANDOMITERATORTRAITS_H_ */ diff --git a/hydra/detail/Range1.inl b/hydra/detail/Range1.inl index f28bc7857..8871e0ee4 100644 --- a/hydra/detail/Range1.inl +++ b/hydra/detail/Range1.inl @@ -36,6 +36,7 @@ #include #include +#include namespace hydra { @@ -155,8 +156,8 @@ make_reverse_range(Iterator begin, Iterator end ){ } template -typename std::enable_if::value, -Range().begin())>>::type +requires (detail::Iterable) +Range().begin())> make_range(Iterable const& container){ typedef decltype(hydra::begin(container)) iterator_type; @@ -164,8 +165,8 @@ make_range(Iterable const& container){ } template -typename std::enable_if::value, -Range().begin())>>::type +requires (detail::Iterable) +Range().begin())> make_range(Iterable&& container){ typedef decltype(hydra::begin(std::forward(container))) iterator_type; @@ -174,8 +175,8 @@ make_range(Iterable&& container){ } template -typename std::enable_if::value, -Range().rbegin())>>::type +requires (detail::ReverseIterable) +Range().rbegin())> make_reverse_range(Iterable const& container){ typedef decltype(hydra::rbegin(container)) iterator_type; @@ -183,8 +184,8 @@ make_reverse_range(Iterable const& container){ } template -typename std::enable_if::value, -Range().rbegin())>>::type +requires (detail::ReverseIterable) +Range().rbegin())> make_reverse_range(Iterable&& container){ typedef decltype(hydra::rbegin(std::forward(container))) iterator_type; diff --git a/hydra/detail/Range2.inl b/hydra/detail/Range2.inl index c5cba37f7..b080a5f6d 100644 --- a/hydra/detail/Range2.inl +++ b/hydra/detail/Range2.inl @@ -35,6 +35,8 @@ #include #include #include +#include +#include namespace hydra { @@ -138,15 +140,15 @@ private: }; template -typename hydra::thrust::detail::enable_if< detail::is_hydra_functor::value , Range >::type +requires (detail::HydraFunctor) +Range make_range(Iterator begin, Iterator end, Functor const& functor ){ return Range( begin, end, functor); } template -typename hydra::thrust::detail::enable_if< - detail::is_hydra_functor::value , - Range, Functor> >::type +requires (detail::HydraFunctor) +Range, Functor> make_reverse_range(Iterator begin, Iterator end,Functor const& functor ){ typedef hydra::thrust::reverse_iterator reverse_iterator_type; @@ -159,10 +161,8 @@ make_reverse_range(Iterator begin, Iterator end,Functor const& functor ){ template -typename hydra::thrust::detail::enable_if< - detail::is_iterable::value && - detail::is_hydra_functor::value, - Range().begin()), Functor> >::type +requires (detail::Iterable && detail::HydraFunctor) +Range().begin()), Functor> make_range(Iterable const& iterable,Functor const& functor ){ typedef decltype(hydra::begin(iterable)) iterator_type; @@ -171,10 +171,8 @@ make_range(Iterable const& iterable,Functor const& functor ){ } template -typename hydra::thrust::detail::enable_if< - detail::is_iterable::value && - detail::is_hydra_functor::value, - Range().begin()), Functor> >::type +requires (detail::Iterable && detail::HydraFunctor) +Range().begin()), Functor> make_range(Iterable&& iterable,Functor const& functor ){ typedef decltype(hydra::begin(std::forward(iterable))) iterator_type; @@ -185,10 +183,8 @@ make_range(Iterable&& iterable,Functor const& functor ){ template -typename hydra::thrust::detail::enable_if< - detail::is_reverse_iterable::value && - detail::is_hydra_functor::value , - Range().rbegin()), Functor> >::type +requires (detail::ReverseIterable && detail::HydraFunctor) +Range().rbegin()), Functor> make_reverse_range(Iterable const& iterable,Functor const& functor ){ typedef decltype(hydra::rbegin(iterable)) iterator_reverse_type; @@ -198,10 +194,8 @@ make_reverse_range(Iterable const& iterable,Functor const& functor ){ template -typename hydra::thrust::detail::enable_if< - detail::is_reverse_iterable::value && - detail::is_hydra_functor::value , - Range().rbegin()), Functor> >::type +requires (detail::ReverseIterable && detail::HydraFunctor) +Range().rbegin()), Functor> make_reverse_range(Iterable&& iterable,Functor const& functor ){ typedef decltype(hydra::rbegin( std::forward(iterable) )) iterator_reverse_type; @@ -211,11 +205,8 @@ make_reverse_range(Iterable&& iterable,Functor const& functor ){ template -typename hydra::thrust::detail::enable_if< - detail::is_iterable::value && - ( detail::is_hydra_functor::value || - detail::is_hydra_lambda::value ) , - Range().begin()), Functor> >::type +requires (detail::Iterable && detail::HydraCallable) +Range().begin()), Functor> operator|(Iterable const& iterable, Functor const& functor){ typedef decltype(hydra::begin(iterable)) iterator_type; @@ -225,11 +216,8 @@ operator|(Iterable const& iterable, Functor const& functor){ template -typename hydra::thrust::detail::enable_if< - detail::is_iterable::value && - (detail::is_hydra_functor::value || - detail::is_hydra_lambda::value ), - Range().begin()), Functor> >::type +requires (detail::Iterable && detail::HydraCallable) +Range().begin()), Functor> operator|(Iterable&& iterable, Functor const& functor){ typedef decltype(hydra::begin( std::forward(iterable) )) iterator_type; @@ -239,11 +227,10 @@ operator|(Iterable&& iterable, Functor const& functor){ } template -typename hydra::thrust::detail::enable_if< - detail::is_iterable::value , - Range< +requires (detail::Iterable) +Range< hydra::thrust::reverse_iterator< - decltype(std::declval().begin()) >>>::type + decltype(std::declval().begin()) >> reverse(Iterable&& iterable) { typedef decltype(hydra::begin(iterable)) iterator_type; diff --git a/hydra/detail/Reduce.inl b/hydra/detail/Reduce.inl index 785d366bc..3e900fce0 100644 --- a/hydra/detail/Reduce.inl +++ b/hydra/detail/Reduce.inl @@ -35,12 +35,13 @@ #include #include #include +#include namespace hydra { template -typename std::enable_if::value, -typename hydra::thrust::iterator_traits().begin())>::value_type >::type +requires (detail::Iterable) +typename hydra::thrust::iterator_traits().begin())>::value_type reduce(Iterable&& iterable){ return hydra::thrust::reduce(std::forward(iterable).begin(), @@ -50,7 +51,8 @@ reduce(Iterable&& iterable){ template().begin())>::value_type > -typename std::enable_if::value, T >::type +requires (detail::Iterable) +T reduce(Iterable&& iterable, T const& init, Functor const& binary_functor){ diff --git a/hydra/detail/Scatter.inl b/hydra/detail/Scatter.inl index b1521d1f7..aedd5c603 100644 --- a/hydra/detail/Scatter.inl +++ b/hydra/detail/Scatter.inl @@ -35,14 +35,17 @@ #include #include #include +#include namespace hydra { template -typename std::enable_if::value - && hydra::detail::is_iterable::value - && hydra::detail::is_iterable::value, -Range().begin())>>::type +requires ( + detail::Iterable && + detail::Iterable && + detail::Iterable +) +Range().begin())> scatter(Iterable_Source&& source, Iterable_Map&& map, Iterable_Target&& target){ hydra::thrust::scatter(std::forward(source).begin(), @@ -56,9 +59,8 @@ scatter(Iterable_Source&& source, Iterable_Map&& map, Iterable_Target&& target){ /* template -typename std::enable_if::value - && hydra::detail::is_iterable::value, -Range().begin())>>::type +requires (hydra::detail::Iterable && hydra::detail::Iterable) +Range().begin())> scatter(Iterable_Source& source, Range&& map, Iterable_Target& target){ hydra::thrust::scatter( source.begin(), source.end(), @@ -68,8 +70,8 @@ scatter(Iterable_Source& source, Range&& map, Iterable_Target& tar template -typename std::enable_if::value, -Range().begin())>>::type +requires (hydra::detail::Iterable) +Range().begin())> scatter(Range&& source, Range&& map, Iterable_Target& target){ hydra::thrust::scatter( source.begin(), source.end(), diff --git a/hydra/detail/Sort.inl b/hydra/detail/Sort.inl index c649f00d3..fb58ae196 100644 --- a/hydra/detail/Sort.inl +++ b/hydra/detail/Sort.inl @@ -34,13 +34,14 @@ #include #include #include +#include namespace hydra { template().begin())> -typename std::enable_if::value, -Range().begin())>>::type +requires (detail::Iterable) +Range().begin())> sort(Iterable& iterable){ hydra::thrust::sort(iterable.begin(), iterable.end() ); @@ -50,8 +51,8 @@ sort(Iterable& iterable){ template().begin())> -typename std::enable_if::value, -Range().begin())>>::type +requires (detail::Iterable) +Range().begin())> sort(Iterable& iterable, Functor const& comparator){ hydra::thrust::sort(iterable.begin(), iterable.end(), comparator); @@ -63,8 +64,8 @@ template().begin()), typename Iterator_Key=decltype(std::declval().begin()), typename Value_Key=decltype(*std::declval().begin()) > -typename std::enable_if::value, -Range().begin())>>::type +requires (detail::Iterable) +Range().begin())> sort_by_key(Iterable& iterable, Iterable_Key& keys){ using hydra::thrust::system::detail::generic::select_system; @@ -84,8 +85,8 @@ sort_by_key(Iterable& iterable, Iterable_Key& keys){ template().begin()), typename Value_Key=decltype(*std::declval>().begin()) > -typename std::enable_if::value, -Range().begin())>>::type +requires (detail::Iterable) +Range().begin())> sort_by_key(Iterable& iterable, Range keys){ using hydra::thrust::system::detail::generic::select_system; diff --git a/hydra/detail/SparseHistogram.inl b/hydra/detail/SparseHistogram.inl index 30cbb0534..73987b7a3 100644 --- a/hydra/detail/SparseHistogram.inl +++ b/hydra/detail/SparseHistogram.inl @@ -42,6 +42,7 @@ #include #include +#include namespace hydra { @@ -508,7 +509,8 @@ SparseHistogram,detail::unidimensional >:: template template -inline typename std::enable_if< M==2, T >::type +requires (M==2) +inline T SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>::Interpolate( std::array const& point){ return spline2D(this->GetBinsCenters(placeholders::_0).begin(), this->GetBinsCenters(placeholders::_0).end(), @@ -518,7 +520,8 @@ SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional template template -inline typename std::enable_if< M==3, T >::type +requires (M==3) +inline T SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>::Interpolate( std::array const& point){ return spline3D(this->GetBinsCenters(placeholders::_0).begin(), this->GetBinsCenters(placeholders::_0).end(), @@ -530,7 +533,8 @@ SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional template template -inline typename std::enable_if< M==4, T >::type +requires (M==4) +inline T SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>::Interpolate( std::array const& point){ return spline4D( @@ -570,8 +574,8 @@ make_sparse_histogram( detail::BackendPolicy, std::array gri //iterable based template< typename T, size_t N , hydra::detail::Backend BACKEND, typename Iterable> -inline typename std::enable_if< hydra::detail::is_iterable::value, -SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>>::type +requires (hydra::detail::Iterable) +inline SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional> make_sparse_histogram( detail::BackendPolicy backend, std::array grid, std::arraylowerlimits, std::array upperlimits, Iterable&& data){ @@ -581,9 +585,8 @@ make_sparse_histogram( detail::BackendPolicy backend, std::array -inline typename std::enable_if< hydra::detail::is_iterable::value&& -hydra::detail::is_iterable::value, -SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional>>::type +requires (hydra::detail::Iterable&& hydra::detail::Iterable) +inline SparseHistogram< T, N, detail::BackendPolicy, detail::multidimensional> make_sparse_histogram( detail::BackendPolicy backend, std::array grid, std::arraylowerlimits, std::array upperlimits, Iterable1&& data, @@ -626,8 +629,8 @@ make_sparse_histogram( detail::BackendPolicy, size_t grid, double lower //iterable based template< typename T, hydra::detail::Backend BACKEND, typename Iterable> -inline typename std::enable_if< hydra::detail::is_iterable::value, -SparseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional>>::type +requires (hydra::detail::Iterable) +inline SparseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional> make_sparse_histogram( detail::BackendPolicy backend, size_t grid, double lowerlimits, double upperlimits, Iterable&& data){ @@ -637,9 +640,8 @@ make_sparse_histogram( detail::BackendPolicy backend, size_t grid, } template< typename T, hydra::detail::Backend BACKEND, typename Iterable1,typename Iterable2 > -inline typename std::enable_if< hydra::detail::is_iterable::value&& -hydra::detail::is_iterable::value, -SparseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional>>::type +requires (hydra::detail::Iterable&& hydra::detail::Iterable) +inline SparseHistogram< T, 1, detail::BackendPolicy, detail::unidimensional> make_sparse_histogram( detail::BackendPolicy backend, size_t grid, double lowerlimits, double upperlimits, Iterable1&& data, diff --git a/hydra/detail/Spline.inl b/hydra/detail/Spline.inl index c463b6120..d7b1127aa 100644 --- a/hydra/detail/Spline.inl +++ b/hydra/detail/Spline.inl @@ -47,6 +47,8 @@ #include #include #include +#include +#include namespace hydra { @@ -78,7 +80,8 @@ inline Iterator lower_bound(Iterator first, Iterator last, const T& value) } template -inline typename std::enable_if< std::is_convertible::value, T>::type +requires (std::is_convertible_v) +inline T __hydra_host__ __hydra_device__ cubic_spline(size_t i, size_t N, T const (&X)[4] , T const (&Y)[4], T value ){ @@ -134,11 +137,12 @@ cubic_spline(size_t i, size_t N, T const (&X)[4] , T const (&Y)[4], T value ) template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value, Type>::type +requires ( + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline Type spline(Iterator1 first, Iterator1 last, Iterator2 measurements, Type value) { using hydra::thrust::min; @@ -156,14 +160,14 @@ spline(Iterator1 first, Iterator1 last, Iterator2 measurements, Type value) { } template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value , - Type >::type +requires ( + detail::Iterable && + detail::Iterable && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline Type spline(Iterable1&& abscissae, Iterable2&& ordinate, Type value){ return spline( std::forward(abscissae).begin(), diff --git a/hydra/detail/Spline2D.inl b/hydra/detail/Spline2D.inl index fb7cf308d..a3e2627ec 100644 --- a/hydra/detail/Spline2D.inl +++ b/hydra/detail/Spline2D.inl @@ -30,13 +30,14 @@ #ifndef SPILINE2D_INL_ #define SPILINE2D_INL_ - +#include #include #include #include #include #include +#include namespace hydra { @@ -54,13 +55,14 @@ namespace hydra { * @return */ template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value && - std::is_convertible::value, double>::type +requires ( + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline2D(IteratorX firstx, IteratorX lastx, IteratorY firsty, IteratorY lasty, IteratorM measurements, TypeX x, TypeY y) { //get the neighbors on x and y-direction first @@ -112,17 +114,17 @@ spline2D(IteratorX firstx, IteratorX lastx, IteratorY firsty, IteratorY lasty, I } template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value , - double >::type +requires ( + detail::Iterable && + detail::Iterable && + detail::Iterable && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline2D(IterableX&& abscissa_x, IterableY&& abscissa_y, IterableM measurements, TypeX x, TypeX y){ diff --git a/hydra/detail/Spline3D.inl b/hydra/detail/Spline3D.inl index b85f0f151..1355892df 100644 --- a/hydra/detail/Spline3D.inl +++ b/hydra/detail/Spline3D.inl @@ -30,28 +30,30 @@ #ifndef SPILINE3D_INL_ #define SPILINE3D_INL_ - +#include #include #include #include #include #include +#include namespace hydra { template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value, double>::type +requires ( + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline3D(IteratorX firstx, IteratorX lastx, IteratorY firsty, IteratorY lasty, IteratorZ firstz, IteratorZ lastz, @@ -124,20 +126,20 @@ spline3D(IteratorX firstx, IteratorX lastx, } template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value , - double >::type +requires ( + detail::Iterable && + detail::Iterable && + detail::Iterable && + detail::Iterable && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline3D(IterableX&& abscissa_x, IterableY&& abscissa_y, IterableZ&& abscissa_z, IterableM measurements, TypeX x, TypeX y, TypeZ z ){ diff --git a/hydra/detail/Spline4D.inl b/hydra/detail/Spline4D.inl index 27a3116d8..3032e1725 100644 --- a/hydra/detail/Spline4D.inl +++ b/hydra/detail/Spline4D.inl @@ -30,13 +30,14 @@ #ifndef SPILINE4D_INL_ #define SPILINE4D_INL_ - +#include #include #include #include #include #include +#include namespace hydra { @@ -44,17 +45,18 @@ namespace hydra { template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value_type, double >::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value, double>::type +requires ( + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v::value_type, double > && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline4D(IteratorX firstx, IteratorX lastx, IteratorY firsty, IteratorY lasty, IteratorW firstw, IteratorW lastw, @@ -142,23 +144,23 @@ spline4D(IteratorX firstx, IteratorX lastx, } template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value && - std::is_convertible::value , - double >::type +requires ( + detail::Iterable && + detail::Iterable && + detail::Iterable && + detail::Iterable && + detail::Iterable && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v && + std::is_convertible_v +) +__hydra_host__ __hydra_device__ inline double spline3D(IterableX&& abscissa_x, IterableY&& abscissa_y, IterableW&& abscissa_w, IterableZ&& abscissa_z, IterableM measurements, TypeX x, TypeX y, TypeW w, TypeZ z ){ diff --git a/hydra/detail/Sum.h b/hydra/detail/Sum.h index 2853ffc8f..119ad8ef2 100644 --- a/hydra/detail/Sum.h +++ b/hydra/detail/Sum.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -137,10 +138,8 @@ hydra::thrust::tuple, * operator+ for two functors. */ template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ), -Sum >::type +requires (detail::HydraCallable && detail::HydraCallable) +inline Sum operator+(T1 const& F1, T2 const& F2) { return Sum(F1, F2); @@ -150,10 +149,8 @@ operator+(T1 const& F1, T2 const& F2) * operator+ for a value and a functor. */ template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Sum< Constant, T> >::type +requires (detail::HydraCallable && std::is_arithmetic_v) +inline Sum< Constant, T> operator+(U const cte, T const& F) { return Constant(cte)+F; @@ -163,10 +160,8 @@ operator+(U const cte, T const& F) * operator+ for a value and a functor. */ template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Sum< Constant, T> >::type +requires (detail::HydraCallable && std::is_arithmetic_v) +inline Sum< Constant, T> operator+( T const& F, U cte) { return Constant(cte)+F; @@ -176,10 +171,8 @@ operator+( T const& F, U cte) * operator+ for a complex value and a functor. */ template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Sum< Constant>, T> >::type +requires (detail::HydraCallable && std::is_arithmetic_v) +inline Sum< Constant>, T> operator+(hydra::complex const& cte, T const& F) { return Constant >(cte)+F; @@ -189,10 +182,8 @@ operator+(hydra::complex const& cte, T const& F) * operator+ for a complex value and a functor. */ template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(std::is_arithmetic::value), -Sum< Constant, T> >::type +requires (detail::HydraCallable && std::is_arithmetic_v) +inline Sum< Constant, T> operator+( T const& F, hydra::complex const& cte) { return Constant >(cte)+F; @@ -201,12 +192,9 @@ operator+( T const& F, hydra::complex const& cte) // Convenience function template -inline typename std::enable_if< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value ) && -detail::all_true< -(detail::is_hydra_functor::value || detail::is_hydra_lambda::value )...>::value, -Sum>::type +requires (detail::HydraCallable && detail::HydraCallable && + (detail::HydraCallable && ...)) +inline Sum sum(F1 const& f1, F2 const& f2, Fs const&... functors ) { return Sum(f1,f2, functors ... ); diff --git a/hydra/detail/Transform.inl b/hydra/detail/Transform.inl index 0256ef5a8..583a8e03b 100644 --- a/hydra/detail/Transform.inl +++ b/hydra/detail/Transform.inl @@ -36,14 +36,15 @@ #include #include #include +#include namespace hydra { template().begin())> -typename std::enable_if::value, -Range().begin())>>::type +requires (hydra::detail::Iterable) +Range().begin())> transform(Iterable_Input&& iterable_input, Iterable_Output&& iterable_output, Functor const& unary_functor){ hydra::thrust::transform(std::forward(iterable_input).begin(), diff --git a/hydra/detail/TupleConcepts.h b/hydra/detail/TupleConcepts.h new file mode 100644 index 000000000..925ca239e --- /dev/null +++ b/hydra/detail/TupleConcepts.h @@ -0,0 +1,76 @@ +/*---------------------------------------------------------------------------- + * + * Copyright (C) 2016 - 2023 Antonio Augusto Alves Junior + * + * This file is part of Hydra Data Analysis Framework. + * + * Hydra is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Hydra 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Hydra. If not, see . + * + *---------------------------------------------------------------------------*/ + +/* + * TupleConcepts.h + * + * Created on: 28/06/2026 + * Author: Davide Brundu + */ + +#ifndef TUPLECONCEPTS_H_ +#define TUPLECONCEPTS_H_ + +#include +#include + +#include + +namespace hydra { + +namespace detail { + +/** + * @brief Satisfied when @c T (after decay) is a Hydra/Thrust tuple type + * (see hydra::detail::is_tuple_type). + */ +template +concept TupleType = is_tuple_type>::value; + +/** + * @brief Satisfied when @c T (after decay) is a tuple whose elements are all + * Hydra function arguments (see hydra::detail::is_tuple_of_function_arguments). + */ +template +concept TupleOfFunctionArguments = is_tuple_of_function_arguments>::value; + +/** + * @brief Satisfied when @c T (after decay) is a Hydra function argument, i.e. a + * type derived from hydra::detail::FunctionArgument (see + * hydra::detail::is_function_argument). Named with the @c Arg suffix to avoid + * clashing with the @c FunctionArgument class template. + */ +template +concept FunctionArgumentArg = is_function_argument>::value; + +/** + * @brief Satisfied when the pack @c T... is a valid set of call arguments for a + * functor whose signature tuple is @c Signature + * (see hydra::detail::is_valid_type_pack). + */ +template +concept ValidTypePack = is_valid_type_pack::value; + +} // namespace detail + +} // namespace hydra + +#endif /* TUPLECONCEPTS_H_ */ diff --git a/hydra/detail/TupleUtility.h b/hydra/detail/TupleUtility.h index ede13a9a5..56d042873 100644 --- a/hydra/detail/TupleUtility.h +++ b/hydra/detail/TupleUtility.h @@ -55,13 +55,13 @@ namespace tuple_utility { } // namespace tuple_utility template - __hydra_host__ __hydra_device__ - typename std::enable_if< detail::is_tuple::value, T>::type + requires (detail::is_tuple::value) + __hydra_host__ __hydra_device__ T tupler( T const& data ) { return data;} template - __hydra_host__ __hydra_device__ - typename std::enable_if::value, hydra::tuple >::type + requires (!detail::is_tuple::value) + __hydra_host__ __hydra_device__ hydra::tuple tupler( T const& data ) { return hydra::make_tuple( data ); } } // namespace detail diff --git a/hydra/detail/ZipIteratorUtility.h b/hydra/detail/ZipIteratorUtility.h index 51b1d9a20..a61f81f9d 100644 --- a/hydra/detail/ZipIteratorUtility.h +++ b/hydra/detail/ZipIteratorUtility.h @@ -155,14 +155,16 @@ template struct flat_tuple: merged_tuple< typename do_tuple::type... > {}; template -typename std::enable_if::value, T>::type +requires (is_tuple::value) +T tupler( T const& data ) { return data; } template -typename std::enable_if< !is_tuple::value , std::tuple >::type +requires (!is_tuple::value) +std::tuple tupler( T const& data ) { return std::make_tuple( data ); @@ -205,8 +207,8 @@ namespace detail { template -typename std::enable_if< all_true::value...>::value, - typename detail::merged_zip_iterator::type >::type +requires (all_true::value...>::value) +typename detail::merged_zip_iterator::type zip_iterator_cat( T const&... zip_iterators) { return hydra::thrust::make_zip_iterator( @@ -216,19 +218,17 @@ zip_iterator_cat( T const&... zip_iterators) namespace meld_iterators_ns { template +requires (detail::is_iterator::value && detail::is_zip_iterator::value) auto convert_to_tuple(T&& iterator) --> typename std::enable_if< detail::is_iterator::value && - detail::is_zip_iterator::value, - decltype( std::declval().get_iterator_tuple() ) >::type +-> decltype( std::declval().get_iterator_tuple() ) { return std::forward(iterator).get_iterator_tuple(); } template +requires (detail::is_iterator::value && (!detail::is_zip_iterator::value)) auto convert_to_tuple(T&& iterator) --> typename std::enable_if< detail::is_iterator::value && - (!detail::is_zip_iterator::value), -hydra::thrust::tuple >::type +-> hydra::thrust::tuple { return hydra::thrust::make_tuple(std::forward(iterator)); } diff --git a/hydra/detail/cufft/BaseCuFFT.h b/hydra/detail/cufft/BaseCuFFT.h index 77042ccb3..680a2a084 100644 --- a/hydra/detail/cufft/BaseCuFFT.h +++ b/hydra/detail/cufft/BaseCuFFT.h @@ -50,6 +50,7 @@ //Hydra wrappers #include +#include namespace hydra { @@ -120,8 +121,8 @@ class BaseCuFFT template().begin())::value_type> - inline typename std::enable_if::value - && detail::is_iterable::value, void>::type + requires (std::is_convertible_v && hydra::detail::Iterable) + inline void LoadInputData( Iterable&& container) { diff --git a/hydra/detail/fftw/BaseFFTW.h b/hydra/detail/fftw/BaseFFTW.h index 4255eceb2..b2b502ede 100644 --- a/hydra/detail/fftw/BaseFFTW.h +++ b/hydra/detail/fftw/BaseFFTW.h @@ -49,6 +49,7 @@ //Hydra wrappers #include +#include namespace hydra { @@ -120,8 +121,8 @@ class BaseFFTW template().begin())::value_type> - inline typename std::enable_if::value - && detail::is_iterable::value, void>::type + requires (std::is_convertible_v && hydra::detail::Iterable) + inline void LoadInputData( Iterable&& container) { diff --git a/hydra/detail/functors/GetBinCenter.h b/hydra/detail/functors/GetBinCenter.h index ff03f01e6..31a6fd024 100644 --- a/hydra/detail/functors/GetBinCenter.h +++ b/hydra/detail/functors/GetBinCenter.h @@ -90,12 +90,14 @@ struct GetBinCenter: public hydra::thrust::unary_function - __hydra_host__ __hydra_device__ inline typename std::enable_if< (I==N), void >::type + requires ((I==N)) + __hydra_host__ __hydra_device__ inline void multiply( size_t (&)[N] , size_t& ) { } template - __hydra_host__ __hydra_device__ inline typename std::enable_if< (I::type + requires ((I - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (I==N), void >::type + requires ((I==N)) + __hydra_host__ __hydra_device__ inline void get_indexes(size_t, size_t (&)[N]) {} //begin of the recursion template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (I::type + requires ((I // multiply static array elements //---------------------------------------- template< size_t J> - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (J==N), void >::type + requires ((J==N)) + __hydra_host__ __hydra_device__ inline void multiply( size_t (&)[N] , size_t& ) { } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (J::type + requires ((J //end of recursion template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (J==N), void >::type + requires ((J==N)) + __hydra_host__ __hydra_device__ inline void get_indexes(size_t, size_t (&)[N]) {} //begin of the recursion template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (J::type + requires ((J - __hydra_host__ __hydra_device__ - typename hydra::thrust::detail::enable_if< I== N, void>::type + requires (I== N) + __hydra_host__ __hydra_device__ void get_global_bin(const size_t (&)[N], size_t& )const{ } template - __hydra_host__ __hydra_device__ - typename hydra::thrust::detail::enable_if< (I< N), void>::type + requires ((I< N)) + __hydra_host__ __hydra_device__ void get_global_bin(const size_t (&indexes)[N], size_t& index) const { size_t prod =1; @@ -190,8 +190,8 @@ struct GetGlobalBin<1,T>: public hydra::thrust::unary_function } template - __hydra_host__ __hydra_device__ - typename std::enable_if< std::is_convertible_v, size_t>::type + requires (std::is_convertible_v) + __hydra_host__ __hydra_device__ size_t operator()(ConvertibleType const& value) const { T X = value; diff --git a/hydra/detail/functors/LogLikelihood.h b/hydra/detail/functors/LogLikelihood.h index 6896ab65a..ea98a8b09 100644 --- a/hydra/detail/functors/LogLikelihood.h +++ b/hydra/detail/functors/LogLikelihood.h @@ -91,9 +91,9 @@ struct LogLikelihood ~LogLikelihood(){} template + requires (!std::is_same::value) __hydra_host__ __hydra_device__ inline - GReal_t operator()(size_t index, const typename std::enable_if< !std::is_same::value, void >::type* dummy=0 ){ + GReal_t operator()(size_t index){ auto C = (cache_value_type) fCacheBegin[index]; auto X = ((point_type) fDataBegin[index]).GetCoordinates() ; @@ -104,9 +104,9 @@ struct LogLikelihood } template + requires (std::is_same::value) __hydra_host__ __hydra_device__ inline - GReal_t operator()(size_t index, const typename std::enable_if< std::is_same::value, void >::type* dummy=0 ){ + GReal_t operator()(size_t index){ auto X = ((point_type) fDataBegin[index]).GetCoordinates() ; diff --git a/hydra/detail/functors/ProcessGenzMalikQuadrature.h b/hydra/detail/functors/ProcessGenzMalikQuadrature.h index 733daa302..cf1034b18 100644 --- a/hydra/detail/functors/ProcessGenzMalikQuadrature.h +++ b/hydra/detail/functors/ProcessGenzMalikQuadrature.h @@ -178,13 +178,13 @@ struct ProcessGenzMalikUnaryCall \f$ \int_a^b f(x)\,dx \approx \frac{b-a}{2} \sum_{i=1}^n w_i f\left(\frac{b-a}{2}x_i + \frac{a+b}{2}\right) \f$. */ template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (I== hydra::thrust::tuple_size::value), void >::type + requires ((I== hydra::thrust::tuple_size::value)) + __hydra_host__ __hydra_device__ inline void get_transformed_abscissa_helper( Abscissa const& , TransAbscissa& ){} template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (I < hydra::thrust::tuple_size::value), void >::type + requires ((I < hydra::thrust::tuple_size::value)) + __hydra_host__ __hydra_device__ inline void get_transformed_abscissa_helper( Abscissa const& abscissa, TransAbscissa& transformed_abscissa ){ hydra::thrust::get(transformed_abscissa) = @@ -210,13 +210,13 @@ struct ProcessGenzMalikUnaryCall //----------------------- template - __hydra_host__ __hydra_device__ - typename std::enable_if< (I==N),void >::type + requires ((I==N)) + __hydra_host__ __hydra_device__ void get_dim_helper( T const&, int& , int& ){ } template - __hydra_host__ __hydra_device__ - typename std::enable_if< (I< N),void >::type + requires ((I< N)) + __hydra_host__ __hydra_device__ void get_dim_helper( T const& X, int& result, int& found_zeros ){ result += hydra::thrust::get(X)>0.0 || hydra::thrust::get(X) < 0.0 ?I:0.0; diff --git a/hydra/detail/functors/ProcessSPlot.h b/hydra/detail/functors/ProcessSPlot.h index 6818aa079..9bb4a7375 100644 --- a/hydra/detail/functors/ProcessSPlot.h +++ b/hydra/detail/functors/ProcessSPlot.h @@ -94,13 +94,13 @@ struct CovMatrixUnary template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I == N*N),void >::type + requires ((I == N*N)) + __hydra_host__ __hydra_device__ inline void set_matrix(double denominator, T&&, hydra::Eigen::Matrix&){ } template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < N*N),void >::type + requires ((I < N*N)) + __hydra_host__ __hydra_device__ inline void set_matrix(double denominator, T&& ftuple, hydra::Eigen::Matrix& fcovmatrix ) { fcovmatrix(index::I, index::J ) = \ @@ -211,8 +211,8 @@ struct SWeights template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (V < 0), tuple_t >::type + requires ((V < 0)) + __hydra_host__ __hydra_device__ inline tuple_t //inline tuple_t operator()(Type x) { @@ -231,8 +231,8 @@ struct SWeights } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (V >= 0), double >::type + requires ((V >= 0)) + __hydra_host__ __hydra_device__ inline double //inline tuple_t operator()(Type x) { diff --git a/hydra/detail/utility/Generic.h b/hydra/detail/utility/Generic.h index 6260bbd49..e631f3c9e 100644 --- a/hydra/detail/utility/Generic.h +++ b/hydra/detail/utility/Generic.h @@ -33,6 +33,7 @@ //std #include #include +#include namespace hydra { @@ -188,12 +189,14 @@ template struct CanConvert{ // multiply std::array elements //---------------------------------------- template - typename std::enable_if< (I==N), void >::type + requires ((I==N)) + void multiply( std::array const& , T& ) { } template - typename std::enable_if< (I::type + requires ((I const& obj, T& result ) { result = I==0? 1.0: result; @@ -205,12 +208,14 @@ template struct CanConvert{ // multiply static array elements //---------------------------------------- template - typename std::enable_if< (I==N), void >::type + requires ((I==N)) + void multiply(const T (&)[N] , T& ) { } template - typename std::enable_if< (I::type + requires ((I struct CanConvert{ //------------------------- //end of recursion template - typename std::enable_if< (I==DIM) && (std::is_integral::value), void >::type + requires ((I==DIM) && (std::integral)) + void get_indexes(size_t , std::array const& , std::array& ) {} //begin of the recursion template - typename std::enable_if< (I::value), void >::type + requires ((I)) + void get_indexes(size_t index, std::array const& depths, std::array& indexes) { @@ -251,13 +258,15 @@ template struct CanConvert{ //------------------------- //end of recursion template - typename std::enable_if< (I==DIM) && (std::is_integral::value), void >::type + requires ((I==DIM) && (std::integral)) + void get_indexes(size_t , const T ( &)[DIM], T (&)[DIM]) {} //begin of the recursion template - typename std::enable_if< (I::value), void >::type + requires ((I)) + void get_indexes(size_t index,const T ( &depths)[DIM], T (&indexes)[DIM] ) { diff --git a/hydra/detail/utility/LSB.h b/hydra/detail/utility/LSB.h index 7706dc2e3..decee2de9 100644 --- a/hydra/detail/utility/LSB.h +++ b/hydra/detail/utility/LSB.h @@ -33,6 +33,7 @@ #include #include #include +#include namespace hydra { @@ -49,12 +50,8 @@ namespace detail { * 64 bit implementation */ template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_integral::value && - !(std::is_signed::value) && - (sizeof(Integer)==8) - , unsigned>::type +requires (std::integral && !(std::is_signed::value) && (sizeof(Integer)==8)) +__hydra_host__ __hydra_device__ inline unsigned lsb( Integer x){ if(!x) return 64; @@ -109,12 +106,8 @@ lsb( Integer x){ * 32 bit implementation */ template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_integral::value && - !(std::is_signed::value) && - (sizeof(Integer)==4) - , unsigned>::type +requires (std::integral && !(std::is_signed::value) && (sizeof(Integer)==4)) +__hydra_host__ __hydra_device__ inline unsigned lsb( Integer x){ if(!x) return 32; diff --git a/hydra/detail/utility/MSB.h b/hydra/detail/utility/MSB.h index 05b717c3e..d8630a268 100644 --- a/hydra/detail/utility/MSB.h +++ b/hydra/detail/utility/MSB.h @@ -33,6 +33,7 @@ #include #include #include +#include namespace hydra { @@ -49,12 +50,12 @@ namespace detail { * 64 bit implementation */ template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_integral::value && - !(std::is_signed::value) && - (std::numeric_limits::digits==64) - , unsigned>::type +requires ( + std::integral && + !(std::is_signed::value) && + (std::numeric_limits::digits==64) +) +__hydra_host__ __hydra_device__ inline unsigned msb( Integer x){ if(!x) return 64; @@ -100,12 +101,12 @@ msb( Integer x){ * 32 bit implementation */ template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_integral::value && - !(std::is_signed::value) && - (std::numeric_limits::digits<=32) - , unsigned>::type +requires ( + std::integral && + !(std::is_signed::value) && + (std::numeric_limits::digits<=32) +) +__hydra_host__ __hydra_device__ inline unsigned msb( Integer x){ if(!x) return 32; @@ -146,12 +147,8 @@ msb( Integer x){ */ /* template -__hydra_host__ __hydra_device__ -inline typename std::enable_if< - std::is_integral::value && - !(std::is_signed::value) && - (std::numeric_limits::digits==16) - , unsigned>::type +requires (std::integral && !(std::is_signed::value) && (std::numeric_limits::digits==16)) +__hydra_host__ __hydra_device__ inline unsigned msb( Integer const& x){ if(!x) return 16; diff --git a/hydra/detail/utility/Permutation.h b/hydra/detail/utility/Permutation.h index 17e87daf3..10f5af188 100644 --- a/hydra/detail/utility/Permutation.h +++ b/hydra/detail/utility/Permutation.h @@ -37,6 +37,7 @@ #include #include #include +#include namespace hydra { @@ -77,7 +78,8 @@ Iterator rotate(Iterator first, Iterator n_first, Iterator last) } template -typename std::enable_if::value, void>::type +requires (std::integral) +void __hydra_host__ __hydra_device__ nth_permutation(Iterator begin, Iterator end, Integer n, Comparator comp) { diff --git a/hydra/detail/utility/Permute.h b/hydra/detail/utility/Permute.h index 71b12a3c4..873b23501 100644 --- a/hydra/detail/utility/Permute.h +++ b/hydra/detail/utility/Permute.h @@ -34,6 +34,7 @@ #include #include #include +#include namespace hydra { @@ -77,7 +78,8 @@ using hydra::detail::iter_swap; } template -typename std::enable_if::value, void>::type +requires (std::integral) +void __hydra_host__ __hydra_device__ nth_permutation(Iterator begin, Iterator end, Integer n, Comparator comp) { diff --git a/hydra/detail/utility/StreamSTL.h b/hydra/detail/utility/StreamSTL.h index ff16df2a2..e3083c875 100644 --- a/hydra/detail/utility/StreamSTL.h +++ b/hydra/detail/utility/StreamSTL.h @@ -43,12 +43,14 @@ namespace hydra { /** array streamer helper **/ template< size_t N, typename T, size_t I> -inline typename std::enable_if<(I==N), void>::type +requires ((I==N)) +inline void stream_array_helper(std::ostream& , std::array const& ) { } template< size_t N, typename T, size_t I=0> -inline typename std::enable_if< (I < N), void>::type +requires ((I < N)) +inline void stream_array_helper(std::ostream& os, std::array const& obj) { char separator = (I==N-1)?char(0):','; @@ -70,12 +72,14 @@ inline std::ostream& operator<<(std::ostream& os, std::array const& obj) /** tuple streamer helper **/ template -inline typename std::enable_if<(I==sizeof ...(T)), void>::type +requires ((I==sizeof ...(T))) +inline void stream_tuple_helper(std::ostream& , std::tuple const& ) { } template -inline typename std::enable_if< (I < sizeof ...(T)), void>::type +requires ((I < sizeof ...(T))) +inline void stream_tuple_helper(std::ostream& os, std::tuple const& obj) { char separator = (I==sizeof ...(T)-1)?char(0):char(','); diff --git a/hydra/detail/utility/Utility_Tuple.h b/hydra/detail/utility/Utility_Tuple.h index 3663a1732..fb39a5816 100644 --- a/hydra/detail/utility/Utility_Tuple.h +++ b/hydra/detail/utility/Utility_Tuple.h @@ -50,6 +50,31 @@ namespace hydra { namespace detail { + // ----------------------------------------------------------------------- + // Helper concepts to express the recursion / validity constraints of the + // tuple utilities below more concisely. + // ----------------------------------------------------------------------- + + // compile-time recursion guards (base case / recursive step) + template + concept LoopEnd = (I == Bound); + + template + concept LoopGoing = (I < Bound); + + // every type in Ts... is convertible to Target + template + concept AllConvertibleTo = (std::is_convertible_v && ...); + + // every type in Head, Tail... is the same + template + concept AllSame = are_all_same::value; + + // usable as an accumulation result (real or complex) + template + concept Accumulable = std::is_convertible_v || + std::is_constructible_v, T>; + //--------------------------------------- // get the type of a tuple with a given the type and the number of elements /* @@ -111,13 +136,13 @@ namespace hydra { //-------------------------------------- template - __hydra_host__ __hydra_device__ inline - typename std::enable_if< I==N,void>::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void max_helper( T const&, C&, size_t&){} template - __hydra_host__ __hydra_device__ inline - typename std::enable_if< I < N, void>::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void max_helper( T const& tuple, C& max_value, size_t& max_index){ max_index = max_value > hydra::thrust::get(tuple) ? max_index : I; @@ -197,14 +222,14 @@ namespace hydra { //--------------------------------------------- // get a reference to a tuple object by index template - __hydra_host__ __hydra_device__ inline - typename hydra::thrust::detail::enable_if<(I == hydra::thrust::tuple_size::value), void>::type + requires LoopEnd::value> + __hydra_host__ __hydra_device__ inline void _get_element(const size_t , T& , R*& ) { } template - __hydra_host__ __hydra_device__ inline - typename hydra::thrust::detail::enable_if<( I < hydra::thrust::tuple_size::value), void>::type + requires LoopGoing::value> + __hydra_host__ __hydra_device__ inline void _get_element(const size_t index, T& t, R*& ptr ) { @@ -382,22 +407,14 @@ namespace hydra { //--------------------------------------- // set a generic array with tuple values template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if< - I == (sizeof...(OtherTypes) + 1) && - std::is_convertible::value && - all_true< std::is_convertible::value...>::value, - void >::type + requires (LoopEnd && AllConvertibleTo) + __hydra_host__ __hydra_device__ inline void assignArrayToTuple(hydra::thrust::tuple &, ArrayType const*) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if< - (I < sizeof...(OtherTypes)+1) && - std::is_convertible::value && - all_true< std::is_convertible::value...>::value, - void >::type + requires (LoopGoing && AllConvertibleTo) + __hydra_host__ __hydra_device__ inline void assignArrayToTuple(hydra::thrust::tuple& t, ArrayType const* Array ) { hydra::thrust::get(t) = Array[I]; @@ -408,22 +425,14 @@ namespace hydra { // set a generic array with tuple values /* template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if< - I == (sizeof...(OtherTypes) + 1) && - std::is_convertible::value && - all_true< std::is_convertible::value...>::value, - void>::type + requires (LoopEnd && std::is_convertible_v::value && all_true< std::is_convertible_v::value...>::value) + __hydra_host__ __hydra_device__ inline void assignArrayToTuple(hydra::thrust::tuple &, ArrayType* ) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if< - (I < sizeof...(OtherTypes)+1) && - std::is_convertible::value && - all_true< std::is_convertible::value...>::value, - void >::type + requires (LoopGoing && std::is_convertible_v::value && all_true< std::is_convertible_v::value...>::value) + __hydra_host__ __hydra_device__ inline void assignArrayToTuple(hydra::thrust::tuple & t, ArrayType* Array ) { hydra::thrust::get(t) = (typename ArrayType::args_type) Array[I]; @@ -432,22 +441,14 @@ namespace hydra { */ //--------------------------------------- template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if< - I == (sizeof...(OtherTypes) + 1) && - std::is_convertible::value && - all_true::value...>::value, - void>::type + requires (LoopEnd && AllConvertibleTo) + __hydra_host__ __hydra_device__ inline void assignArrayToTuple(hydra::thrust::detail::tuple_of_iterator_references &, ArrayType const* ) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if< - (I < sizeof...(OtherTypes)+1) && - std::is_convertible::value && - all_true::value...>::value, - void >::type + requires (LoopGoing && AllConvertibleTo) + __hydra_host__ __hydra_device__ inline void assignArrayToTuple(hydra::thrust::detail::tuple_of_iterator_references & t, ArrayType const* Array ) { hydra::thrust::get(t) = Array[I]; @@ -456,14 +457,14 @@ namespace hydra { //--------------------------------------- // set a std::array with tuple values template - inline typename hydra::thrust::detail::enable_if::value, void>::type + requires (LoopEnd && AllSame) + inline void tupleToArray(hydra::thrust::tuple const&, std::array&) {} template - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(OtherTypes)+1) && - are_all_same::value, void >::type + requires (LoopGoing && AllSame) + inline void tupleToArray(hydra::thrust::tuple const& t, std::array& Array) { @@ -475,22 +476,14 @@ namespace hydra { //--------------------------------------- // set a std::array with tuple values template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (I == sizeof...(Tail) + 1) && - std::is_convertible< Head, Type>::value && - all_true::value ... >::value, - void >::type + requires (LoopEnd && AllConvertibleTo) + __hydra_host__ __hydra_device__ inline void assignTupleToArray(hydra::thrust::tuple const&, Type(&)[sizeof...(Tail)+1]) { } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (I < sizeof...(Tail) + 1) && - std::is_convertible< Head, Type>::value && - all_true::value ... >::value, - void >::type + requires (LoopGoing && AllConvertibleTo) + __hydra_host__ __hydra_device__ inline void assignTupleToArray(hydra::thrust::tuple const& Tuple, Type (&Array)[sizeof...(Tail)+1]) { @@ -501,22 +494,14 @@ namespace hydra { //----------------- // set a std::array with tuple values template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (I == sizeof...(Tail) + 1) && - std::is_convertible< Head, Type>::value && - all_true::value ... >::value, - void >::type + requires (LoopEnd && AllConvertibleTo) + __hydra_host__ __hydra_device__ inline void assignTupleToArray(hydra::thrust::tuple const&, std::array&) { } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (I < sizeof...(Tail) + 1) && - std::is_convertible< Head, Type>::value && - all_true::value ... >::value, - void >::type + requires (LoopGoing && AllConvertibleTo) + __hydra_host__ __hydra_device__ inline void assignTupleToArray(hydra::thrust::tuple const& Tuple, std::array& Array) { @@ -527,22 +512,14 @@ namespace hydra { //--------------------------------------- // set a std::array with tuple values template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (I == sizeof...(Tail) + 1) && - std::is_convertible< typename remove_device_reference::type, Type>::value && - all_true::type, Type>::value ... >::value, - void >::type + requires (LoopEnd && std::is_convertible_v< typename remove_device_reference::type, Type> && all_true::type, Type> ... >::value) + __hydra_host__ __hydra_device__ inline void assignTupleToArray(hydra::thrust::detail::tuple_of_iterator_references const&, Type(&)[sizeof...(Tail)+1]) { } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (I < sizeof...(Tail) + 1) && - std::is_convertible< typename remove_device_reference::type, Type>::value && - all_true::type, Type>::value ... >::value, - void >::type + requires (LoopGoing && std::is_convertible_v< typename remove_device_reference::type, Type> && all_true::type, Type> ... >::value) + __hydra_host__ __hydra_device__ inline void assignTupleToArray(hydra::thrust::detail::tuple_of_iterator_references const& Tuple, Type (&Array)[sizeof...(Tail)+1]) { @@ -553,22 +530,14 @@ namespace hydra { //----------------- // set a std::array with tuple values template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (I == sizeof...(Tail) + 1) && - std::is_convertible< typename remove_device_reference::type, Type>::value && - all_true::type, Type>::value ... >::value, - void >::type + requires (LoopEnd && std::is_convertible_v< typename remove_device_reference::type, Type> && all_true::type, Type> ... >::value) + __hydra_host__ __hydra_device__ inline void assignTupleToArray(hydra::thrust::detail::tuple_of_iterator_references const&, std::array&) { } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< - (I < sizeof...(Tail) + 1) && - std::is_convertible< typename remove_device_reference::type, Type>::value && - all_true::type, Type>::value ... >::value, - void >::type + requires (LoopGoing && std::is_convertible_v< typename remove_device_reference::type, Type> && all_true::type, Type> ... >::value) + __hydra_host__ __hydra_device__ inline void assignTupleToArray(hydra::thrust::detail::tuple_of_iterator_references const& Tuple, std::array& Array) { @@ -580,16 +549,14 @@ namespace hydra { //--------------------------------------- // set a generic array with tuple values template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::value, void>::type + requires (LoopEnd && AllSame) + __hydra_host__ __hydra_device__ inline void tupleToArray(hydra::thrust::tuple const &, typename std::remove_reference::type*) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(OtherTypes)+1) && - are_all_same::value, void >::type + requires (LoopGoing && AllSame) + __hydra_host__ __hydra_device__ inline void tupleToArray(hydra::thrust::tuple const & t, typename std::remove_reference::type* Array) { @@ -602,13 +569,13 @@ namespace hydra { namespace utils { template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::value, void >::type + requires LoopEnd::value> + __hydra_host__ __hydra_device__ inline void _tuple_to_array(TupleType const& , ArrayType* ){ } template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::value, void >::type + requires LoopGoing::value> + __hydra_host__ __hydra_device__ inline void _tuple_to_array(TupleType const & _tuple, ArrayType* _array) { _array[I] = hydra::thrust::get( _tuple); @@ -618,11 +585,11 @@ namespace hydra { } // namespace utils // entry point template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if< - (detail::is_instantiation_of::value || - detail::is_instantiation_of::value), - void>::type tupleToArray(TupleType const& _tuple, ArrayType* _array){ + requires ( + (detail::is_instantiation_of::value) || + (detail::is_instantiation_of::value) + ) + __hydra_host__ __hydra_device__ inline void tupleToArray(TupleType const& _tuple, ArrayType* _array){ utils::_tuple_to_array(_tuple, _array); } @@ -653,14 +620,14 @@ namespace hydra { // set array of pointers to point to the tuple elements template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I == hydra::thrust::tuple_size::value) && is_homogeneous::value, void>::type + requires (LoopEnd::value> && is_homogeneous::value) + __hydra_host__ __hydra_device__ inline void set_ptrs_to_tuple(T& , Array_Type** ) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < hydra::thrust::tuple_size::value) && is_homogeneous::value, void>::type + requires (LoopGoing::value> && is_homogeneous::value) + __hydra_host__ __hydra_device__ inline void set_ptrs_to_tuple(T& t, Array_Type** Array) { Array[I] = &hydra::thrust::get(t); @@ -672,19 +639,23 @@ namespace hydra { template - void ptr_setter( T1*& ptr, typename hydra::thrust::detail::enable_if::value, T2 >::type* el ){ ptr=el; } + requires (hydra::thrust::detail::is_same::value) + void ptr_setter( T1*& ptr, T2* el ){ ptr=el; } template - void ptr_setter( T1*&, typename hydra::thrust::detail::enable_if::value, T2 >::type* ){ } + requires (!hydra::thrust::detail::is_same::value) + void ptr_setter( T1*&, T2* ){ } template - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + inline void set_ptr_to_tuple_element(const int, std::tuple&, Ptr*&) { } template - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)), void >::type + requires LoopGoing + inline void set_ptr_to_tuple_element(const int index, std::tuple & t, Ptr*& ptr) { if(index == I ) ptr_setter>::type>( ptr, &std::get(t)); @@ -696,14 +667,14 @@ namespace hydra { //--------------------------------------- //get a element of a given tuple by index. value is stored in x template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void get_tuple_element(const int, hydra::thrust::tuple const&, T& ) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)), void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void get_tuple_element(const int index, hydra::thrust::tuple const& t, T& x) { if(index == I)x=T( hydra::thrust::get(t)); @@ -714,14 +685,14 @@ namespace hydra { //--------------------------------------- //set a element of a given tuple by index to value x template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void set_tuple_element(const int, hydra::thrust::tuple const&, T& ) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)), void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void set_tuple_element(const int index, hydra::thrust::tuple& t, const T& x) { if(index == I) hydra::thrust::get(t)=x; @@ -732,14 +703,14 @@ namespace hydra { // evaluate a void functor taking as argument // a given tuple element template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void eval_on_tuple_element(int, hydra::thrust::tuple const&, FuncT const&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)), void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void eval_on_tuple_element(int index, hydra::thrust::tuple const& t, FuncT const& f) { if (index == 0) std::forward(f)(hydra::thrust::get(t)); @@ -752,14 +723,14 @@ namespace hydra { // arg and return on r //-------------------------------------- template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void eval_tuple_element(Return_Type&, int, hydra::thrust::tuple const&, ArgType const&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)), void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void eval_tuple_element(Return_Type& r, int index, hydra::thrust::tuple const& t, ArgType const& arg) { if (index == 0) @@ -775,14 +746,14 @@ namespace hydra { // element taking as argument ArgType const& // arg and return on r template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void sum_tuple(Return_Type&, hydra::thrust::tuple&&, ArgType&&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)), void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void sum_tuple(Return_Type& r, hydra::thrust::tuple&& t, ArgType&& arg) { r = r+ (Return_Type) hydra::thrust::get( std::forward>(t))(std::forward(arg)); @@ -791,14 +762,14 @@ namespace hydra { template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void sum_tuple(Return_Type&, hydra::thrust::tuple const&, ArgType const&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)), void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void sum_tuple(Return_Type& r, hydra::thrust::tupleconst& t, ArgType const& arg) { r = r+ (Return_Type) hydra::thrust::get(t)(arg); @@ -807,14 +778,14 @@ namespace hydra { template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void sum_tuple2(Return_Type&, hydra::thrust::tuple&&, ArgType1&&, ArgType2&& ) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)), void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void sum_tuple2(Return_Type& r, hydra::thrust::tuple&& t, ArgType1&& arg1, ArgType2&& arg2) { r = r + (Return_Type) hydra::thrust::get(t)(arg1, arg2); @@ -823,14 +794,14 @@ namespace hydra { } template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void sum_tuple2(Return_Type&, hydra::thrust::tupleconst&, ArgType1 const&, ArgType2 const& ) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)), void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void sum_tuple2(Return_Type& r, hydra::thrust::tuple const& t, ArgType1 const& arg1, ArgType2 const& arg2) { r = r + (Return_Type) hydra::thrust::get(t)(arg1, arg2); @@ -843,14 +814,14 @@ namespace hydra { // element taking as argument ArgType & // arg and return on r template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void multiply_tuple(Return_Type&, hydra::thrust::tuple const&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)),void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void multiply_tuple(Return_Type& r, hydra::thrust::tupleconst& t) { r = r*( (Return_Type) hydra::thrust::get(t)); @@ -858,14 +829,14 @@ namespace hydra { } template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void multiply_tuple(Return_Type&, hydra::thrust::tuple&&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)),void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void multiply_tuple(Return_Type& r, hydra::thrust::tuple&& t) { r = r*( (Return_Type) hydra::thrust::get(std::forward< hydra::thrust::tuple >(t))); @@ -873,14 +844,14 @@ namespace hydra { } template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void product_tuple(Return_Type&, hydra::thrust::tuple const&, ArgType const&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)),void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void product_tuple(Return_Type& r, hydra::thrust::tuple const& t, ArgType const& arg) { r = r*( (Return_Type) hydra::thrust::get(t)(arg)); @@ -889,14 +860,14 @@ namespace hydra { template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void product_tuple(Return_Type&, hydra::thrust::tuple &&, ArgType&&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)),void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void product_tuple(Return_Type& r, hydra::thrust::tuple&& t, ArgType&& arg) { r = r*( (Return_Type) hydra::thrust::get(std::forward< hydra::thrust::tuple >(t))(std::forward(arg))); @@ -904,14 +875,14 @@ namespace hydra { } template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void product_tuple2(Return_Type&, hydra::thrust::tuple const&, ArgType1 const&, ArgType2 const&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < (sizeof...(Tp))),void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void product_tuple2(Return_Type& r, hydra::thrust::tuple const& t, ArgType1 const& arg1, ArgType2 const& arg2) { r = r*((Return_Type) hydra::thrust::get(t)(arg1, arg2)); @@ -920,14 +891,14 @@ namespace hydra { template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void product_tuple2(Return_Type&, hydra::thrust::tuple&&, ArgType1&&, ArgType2&&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < (sizeof...(Tp))),void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void product_tuple2(Return_Type& r, hydra::thrust::tuple&& t, ArgType1&& arg1, ArgType2&& arg2) { r = r*((Return_Type) hydra::thrust::get(std::forward< hydra::thrust::tuple >(t))(std::forward(arg1), std::forward(arg2))); @@ -936,14 +907,14 @@ namespace hydra { } template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void product_tuple3(Return_Type&, hydra::thrust::tuple const&, ArgType1 const&, ArgType2 const&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < N),void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void product_tuple3(Return_Type& r, hydra::thrust::tuple const& t, ArgType1 const& arg1, ArgType2 const& arg2) { r = r*((Return_Type) hydra::thrust::get(t)(arg1, arg2)); @@ -952,14 +923,14 @@ namespace hydra { template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void product_tuple3(Return_Type&, hydra::thrust::tuple&&, ArgType1&&, ArgType2&&) {} template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < N),void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void product_tuple3(Return_Type& r, hydra::thrust::tuple&& t, ArgType1&& arg1, ArgType2&& arg2) { r = r*((Return_Type) hydra::thrust::get(std::forward< hydra::thrust::tuple >(t))(std::forward(arg1), std::forward(arg2))); @@ -1118,12 +1089,14 @@ namespace hydra { // set functors in tuple template - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + inline void set_functors_in_tuple(hydra::thrust::tuple&, const std::vector&) {} template - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)),void >::type + requires LoopGoing + inline void set_functors_in_tuple(hydra::thrust::tuple& t, const std::vector& parameters) { hydra::thrust::get(t).SetParameters(parameters); @@ -1132,12 +1105,14 @@ namespace hydra { template - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + inline void print_parameters_in_tuple(hydra::thrust::tuple&) {} template - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)),void >::type + requires LoopGoing + inline void print_parameters_in_tuple(hydra::thrust::tuple& t) { hydra::thrust::get(t).PrintRegisteredParameters(); @@ -1145,12 +1120,14 @@ namespace hydra { } template - inline typename hydra::thrust::detail::enable_if::type + requires LoopEnd + inline void add_parameters_in_tuple(std::vector& , hydra::thrust::tuple&) {} template - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(Tp)),void >::type + requires LoopGoing + inline void add_parameters_in_tuple(std::vector& user_parameters, hydra::thrust::tuple& t) { hydra::thrust::get(t).AddUserParameters(user_parameters); @@ -1172,8 +1149,8 @@ namespace hydra { //accumulate by sum - template::value || std::is_constructible,Return_Type>::value >::type > + template + requires Accumulable __hydra_host__ __hydra_device__ inline Return_Type accumulate(ArgType& x, hydra::thrust::tuple& t) { @@ -1182,8 +1159,8 @@ namespace hydra { return r; } - template::value || std::is_constructible,Return_Type>::value >::type > + template + requires Accumulable __hydra_host__ __hydra_device__ inline Return_Type accumulate(ArgType const& x, hydra::thrust::tuple const& t) { @@ -1193,7 +1170,8 @@ namespace hydra { } template::value || std::is_constructible,Return_Type>::value>::type> + typename ... Tp> + requires Accumulable __hydra_host__ __hydra_device__ inline Return_Type accumulate2(ArgType1& x, ArgType2& y, hydra::thrust::tuple& t) { @@ -1204,7 +1182,8 @@ namespace hydra { template::value || std::is_constructible,Return_Type>::value>::type> + typename ... Tp> + requires Accumulable __hydra_host__ __hydra_device__ inline Return_Type accumulate2(ArgType1 const& x, ArgType2 const& y, hydra::thrust::tuple const& t) { @@ -1215,8 +1194,8 @@ namespace hydra { //accumulate by product - template::value || std::is_constructible,Return_Type>::value >::type> + template + requires Accumulable __hydra_host__ __hydra_device__ inline Return_Type product(ArgType const& x, hydra::thrust::tuple const& t) { @@ -1226,8 +1205,8 @@ namespace hydra { } //accumulate by product - template::value || std::is_constructible,Return_Type>::value >::type> + template + requires Accumulable __hydra_host__ __hydra_device__ inline Return_Type product(ArgType& x, hydra::thrust::tuple & t) { @@ -1236,8 +1215,8 @@ namespace hydra { return r; } - template::value || std::is_constructible,Return_Type>::value >::type> + template + requires Accumulable __hydra_host__ __hydra_device__ inline Return_Type product2(ArgType1 const& x, ArgType2 const& y, hydra::thrust::tuple const& t) { @@ -1247,8 +1226,8 @@ namespace hydra { return r; } - template::value || std::is_constructible,Return_Type>::value >::type> + template + requires Accumulable __hydra_host__ __hydra_device__ inline Return_Type product2(ArgType1& x, ArgType2& y, hydra::thrust::tuple& t) { @@ -1259,14 +1238,14 @@ namespace hydra { } template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I == sizeof...(T)),void >::type + requires LoopEnd + __hydra_host__ __hydra_device__ inline void add_tuple_values(GReal_t& , hydra::thrust::tuple const&) { } template - __hydra_host__ __hydra_device__ - inline typename hydra::thrust::detail::enable_if<(I < sizeof...(T)),void >::type + requires LoopGoing + __hydra_host__ __hydra_device__ inline void add_tuple_values(GReal_t& result, hydra::thrust::tuple const& tpl ) { result += hydra::thrust::get(tpl); diff --git a/hydra/functions/Chebychev.h b/hydra/functions/Chebychev.h index be2482988..087d8cc11 100644 --- a/hydra/functions/Chebychev.h +++ b/hydra/functions/Chebychev.h @@ -133,13 +133,13 @@ class Chebychev:public BaseFunctor, Signature, Order+ private: template - __hydra_host__ __hydra_device__ - inline typename std::enable_if<(I==Order+1), void >::type + requires ((I==Order+1)) + __hydra_host__ __hydra_device__ inline void polynomial_helper( const double(&)[Order+1], const double, double&) const {} template - __hydra_host__ __hydra_device__ - inline typename std::enable_if<(I::type + requires ((I, 1> private: template - __hydra_host__ __hydra_device__ inline - typename std::enable_if<(I==N), void >::type + requires ((I==N)) + __hydra_host__ __hydra_device__ inline void polynomial_integral_helper( const double, const double(&)[N], double&) const {} template - __hydra_host__ __hydra_device__ inline - typename std::enable_if<(I::type + requires ((I #include #include +#include namespace hydra { @@ -356,7 +357,8 @@ void Dispose(){ template - inline typename std::enable_if::type + requires (FFTC ==detail::CuFFT) + inline void sync_data() { hydra::thrust::copy_n( fFFTData, fNSamples, fDeviceData ); @@ -364,7 +366,8 @@ void Dispose(){ } template - inline typename std::enable_if::type + requires (FFTC !=detail::CuFFT) + inline void sync_data() { hydra::thrust::copy_n(device_system_type(), fFFTData, fNSamples, fDeviceData ); @@ -386,8 +389,9 @@ void Dispose(){ template::type>::type> -inline typename std::enable_if< std::is_floating_point::value, ConvolutionFunctor, detail::FFTPolicy, ArgType>>::type +requires (std::floating_point) +inline ConvolutionFunctor, detail::FFTPolicy, ArgType> make_convolution( detail::BackendPolicy const&, detail::FFTPolicy const&, Functor const& functor, Kernel const& kernel, T kmin, T kmax, unsigned nsamples=1024, bool interpolate=true, bool power_up=true) { diff --git a/hydra/functions/Polynomial.h b/hydra/functions/Polynomial.h index 233a99357..7ab65e9a9 100644 --- a/hydra/functions/Polynomial.h +++ b/hydra/functions/Polynomial.h @@ -119,13 +119,13 @@ class Polynomial:public BaseFunctor, Signature, Orde template - __hydra_host__ __hydra_device__ - inline typename std::enable_if<(I==-1), void >::type + requires ((I==-1)) + __hydra_host__ __hydra_device__ inline void polynomial_helper( const double(&)[Order+1], const double, double&) const {} template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< (I < Order) &&( I>=0), void >::type + requires ((I < Order) &&( I>=0)) + __hydra_host__ __hydra_device__ inline void polynomial_helper( const double(&coef)[Order+1], const double x, double& p) const { p = p*x + coef[I]; @@ -133,8 +133,8 @@ class Polynomial:public BaseFunctor, Signature, Orde } template - __hydra_host__ __hydra_device__ - inline typename std::enable_if< I==(Order), void >::type + requires (I==(Order)) + __hydra_host__ __hydra_device__ inline void polynomial_helper( const double(&coef)[Order+1], const double x, double& p) const { p=coef[I]; @@ -174,13 +174,13 @@ class IntegrationFormula< Polynomial, 1> private: template - __hydra_host__ __hydra_device__ - inline typename std::enable_if<(I==N), void >::type + requires ((I==N)) + __hydra_host__ __hydra_device__ inline void polynomial_integral_helper( const double, const double(&)[N], double&) const {} template - __hydra_host__ __hydra_device__ - inline typename std::enable_if<(I::type + requires ((I(x)/(I+1); diff --git a/hydra/functions/Spline2DFunctor.h b/hydra/functions/Spline2DFunctor.h index e5c1413d9..b720b4382 100644 --- a/hydra/functions/Spline2DFunctor.h +++ b/hydra/functions/Spline2DFunctor.h @@ -48,6 +48,7 @@ #include #include #include +#include namespace hydra { @@ -163,12 +164,13 @@ make_spline2D(IteratorX firstX, IteratorX lastX, IteratorY firstY, IteratorY las } template -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value, - Spline2DFunctor< decltype(std::declval().begin()) ,decltype(std::declval().begin()), - decltype(std::declval().begin()), ArgTypeX, ArgTypeY> >::type +requires ( + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable +) +inline Spline2DFunctor< decltype(std::declval().begin()) ,decltype(std::declval().begin()), + decltype(std::declval().begin()), ArgTypeX, ArgTypeY> make_spline2D(IterableX&& x, IterableY&& y, IterableZ&& z) { @@ -186,11 +188,11 @@ typedef decltype(std::declval().begin()) IteratorZ; template -inline typename std::enable_if< std::is_convertible::value, -Spline2DFunctor< +requires (std::is_convertible_v) +inline Spline2DFunctor< decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_0).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_1).begin()), -decltype(std::declval, detail::multidimensional > >().GetBinsContents().begin()), double, double>>::type +decltype(std::declval, detail::multidimensional > >().GetBinsContents().begin()), double, double> make_spline( DenseHistogram, detail::multidimensional > const& histogram ) { @@ -209,11 +211,11 @@ typedef decltype(std::declval().GetBinsContents().begin()) Iter template -inline typename std::enable_if< std::is_convertible::value, -Spline2DFunctor< +requires (std::is_convertible_v) +inline Spline2DFunctor< decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_0).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_1).begin()), -decltype(std::declval, detail::multidimensional > >().GetBinsContents().begin()), double, double>>::type +decltype(std::declval, detail::multidimensional > >().GetBinsContents().begin()), double, double> make_spline( SparseHistogram, detail::multidimensional > const& histogram ) { diff --git a/hydra/functions/Spline3DFunctor.h b/hydra/functions/Spline3DFunctor.h index faa26200f..d86ddff53 100644 --- a/hydra/functions/Spline3DFunctor.h +++ b/hydra/functions/Spline3DFunctor.h @@ -48,6 +48,7 @@ #include #include #include +#include namespace hydra { @@ -184,13 +185,14 @@ make_spline3D(IteratorX firstX, IteratorX lastX, IteratorY firstY, IteratorY las } template -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value, - Spline3DFunctor< decltype(std::declval().begin()) ,decltype(std::declval().begin()), - decltype(std::declval().begin()), decltype(std::declval().begin()), ArgTypeX, ArgTypeY, ArgTypeZ> >::type +requires ( + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable +) +inline Spline3DFunctor< decltype(std::declval().begin()) ,decltype(std::declval().begin()), + decltype(std::declval().begin()), decltype(std::declval().begin()), ArgTypeX, ArgTypeY, ArgTypeZ> make_spline3D(IterableX&& x, IterableY&& y, IterableZ&& z, IterableM&& measurements) { @@ -212,12 +214,12 @@ typedef decltype(std::declval().begin()) IteratorM; template -inline typename std::enable_if< std::is_convertible::value, -Spline3DFunctor< +requires (std::is_convertible_v) +inline Spline3DFunctor< decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_0).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_1).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_2).begin()), -decltype(std::declval, detail::multidimensional > >().GetBinsContents().begin()), double, double, double>>::type +decltype(std::declval, detail::multidimensional > >().GetBinsContents().begin()), double, double, double> make_spline( DenseHistogram, detail::multidimensional > const& histogram ) { @@ -238,12 +240,12 @@ typedef decltype(std::declval().GetBinsContents().begin()) Iter template -inline typename std::enable_if< std::is_convertible::value, -Spline3DFunctor< +requires (std::is_convertible_v) +inline Spline3DFunctor< decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_0).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_1).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_2).begin()), -decltype(std::declval, detail::multidimensional > >().GetBinsContents().begin()), double, double, double>>::type +decltype(std::declval, detail::multidimensional > >().GetBinsContents().begin()), double, double, double> make_spline( SparseHistogram, detail::multidimensional > const& histogram ) { diff --git a/hydra/functions/Spline4DFunctor.h b/hydra/functions/Spline4DFunctor.h index 46064923b..75b95dcb8 100644 --- a/hydra/functions/Spline4DFunctor.h +++ b/hydra/functions/Spline4DFunctor.h @@ -48,6 +48,7 @@ #include #include #include +#include namespace hydra { @@ -224,19 +225,20 @@ make_spline4D(IteratorX firstX, IteratorX lastX, template -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value, - Spline4DFunctor< +requires ( + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable && + hydra::detail::Iterable +) +inline Spline4DFunctor< decltype(std::declval().begin()), decltype(std::declval().begin()), decltype(std::declval().begin()), decltype(std::declval().begin()), decltype(std::declval().begin()), - ArgTypeX, ArgTypeY, ArgTypeW, ArgTypeZ> >::type + ArgTypeX, ArgTypeY, ArgTypeW, ArgTypeZ> make_spline4D(IterableX&& x, IterableY&& y, IterableW&& w, IterableZ&& z, IterableM&& measurements) { @@ -257,14 +259,14 @@ typedef decltype(std::declval().begin()) IteratorM; template -inline typename std::enable_if< std::is_convertible::value, -Spline4DFunctor< +requires (std::is_convertible_v) +inline Spline4DFunctor< decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_0).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_1).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_2).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_3).begin()), decltype(std::declval, detail::multidimensional > >().GetBinsContents().begin()), -double, double, double, double>>::type +double, double, double, double> make_spline( DenseHistogram, detail::multidimensional > const& histogram ){ typedef DenseHistogram, detail::multidimensional > histogram_type; @@ -286,14 +288,14 @@ typedef decltype(std::declval().GetBinsContents().begin()) Iter template -inline typename std::enable_if< std::is_convertible::value, -Spline4DFunctor< +requires (std::is_convertible_v) +inline Spline4DFunctor< decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_0).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_1).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_2).begin()), decltype(std::declval, detail::multidimensional> >().GetBinsCenters(placeholders::_3).begin()), decltype(std::declval, detail::multidimensional > >().GetBinsContents().begin()), -double, double, double, double>>::type +double, double, double, double> make_spline( SparseHistogram, detail::multidimensional > const& histogram ){ typedef SparseHistogram, detail::multidimensional > histogram_type; diff --git a/hydra/functions/SplineFunctor.h b/hydra/functions/SplineFunctor.h index e8deb06fd..a40315b03 100644 --- a/hydra/functions/SplineFunctor.h +++ b/hydra/functions/SplineFunctor.h @@ -48,6 +48,7 @@ #include #include #include +#include namespace hydra { @@ -158,11 +159,9 @@ make_spline(Iterator1 firstX, Iterator1 lastX, Iterator2 firstY ) } template -inline typename std::enable_if< - hydra::detail::is_iterable::value && - hydra::detail::is_iterable::value, - SplineFunctor< decltype(std::declval().begin()), - decltype(std::declval().begin()), ArgType> >::type +requires (hydra::detail::Iterable && hydra::detail::Iterable) +inline SplineFunctor< decltype(std::declval().begin()), + decltype(std::declval().begin()), ArgType> make_spline(Iterable1&& x, Iterable2&& y) { diff --git a/hydra/functions/Utils.h b/hydra/functions/Utils.h index 7a24bbf00..39ef8bf80 100644 --- a/hydra/functions/Utils.h +++ b/hydra/functions/Utils.h @@ -67,14 +67,14 @@ namespace detail { template - __hydra_host__ __hydra_device__ - inline typename std::enable_if::type + requires (I==N) + __hydra_host__ __hydra_device__ inline void pow_helper(T const, T&){} template - inline __hydra_host__ __hydra_device__ - typename std::enable_if< (I< N), void >::type + requires ((I< N)) + inline __hydra_host__ __hydra_device__ void pow_helper(T const x, T& r){ r *= x ; pow_helper(x,r); diff --git a/hydra/multiarray.h b/hydra/multiarray.h index cbf5980bb..677c03ef5 100644 --- a/hydra/multiarray.h +++ b/hydra/multiarray.h @@ -47,6 +47,8 @@ #include #include #include +#include +#include namespace hydra { @@ -132,7 +134,8 @@ class multiarray> hydra::thrust::fill(begin(), end(), value ); } - template::value>::type > + template + requires (std::integral) multiarray(hydra::pair::type > const& pair){ __resize(pair.first); hydra::thrust::fill(begin(), end(), pair.second ); @@ -163,12 +166,8 @@ class multiarray> hydra::thrust::copy(first, last, begin()); } - template< typename Iterable, - typename = typename std::enable_if< - (detail::is_iterable::value) && - !(detail::is_iterator::value) && - (std::is_convertible().begin()), value_type>::value) - >::type > + template< typename Iterable> + requires ((hydra::detail::Iterable) && !(detail::is_iterator::value) && (std::is_convertible().begin()), value_type>::value)) multiarray(Iterable&& other ) { __resize( hydra::thrust::distance( @@ -291,8 +290,8 @@ class multiarray> template< typename InputIterator> - inline typename hydra::thrust::detail::enable_if< - detail::is_instantiation_of< hydra::thrust::zip_iterator, InputIterator>::value, void>::type + requires (detail::is_instantiation_of< hydra::thrust::zip_iterator, InputIterator>::value) + inline void insert(iterator pos, InputIterator first, InputIterator last) { size_type position = hydra::thrust::distance(begin(), pos); @@ -708,11 +707,13 @@ class multiarray> //__________________________________________ // pop_back template - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __pop_back(){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __pop_back() { std::get(fData).pop_back(); @@ -722,11 +723,13 @@ class multiarray> //__________________________________________ // resize template - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __resize(size_type){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __resize(size_type n) { std::get(fData).resize(n); @@ -736,11 +739,13 @@ class multiarray> //__________________________________________ // push_back template - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __push_back( value_type const& ){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __push_back( value_type const& value ) { std::get(fData).push_back( hydra::thrust::get(value) ); @@ -750,11 +755,13 @@ class multiarray> //__________________________________________ // clear template - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __clear(){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __clear( ) { std::get(fData).clear(); @@ -764,11 +771,13 @@ class multiarray> //__________________________________________ // shrink_to_fit template - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __shrink_to_fit(){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __shrink_to_fit( ) { std::get(fData).shrink_to_fit(); @@ -778,11 +787,13 @@ class multiarray> //__________________________________________ // shrink_to_fit template - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __reserve(size_type ){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __reserve(size_type size ) { std::get(fData).reserve(size); @@ -792,11 +803,13 @@ class multiarray> //__________________________________________ // erase template - inline typename hydra::thrust::detail::enable_if<(I == N), void>::type + requires ((I == N)) + inline void __erase_helper( size_type ){ } template - inline typename hydra::thrust::detail::enable_if<(I < N), void>::type + requires ((I < N)) + inline void __erase_helper(size_type position ) { std::get(fData).erase( @@ -815,11 +828,13 @@ class multiarray> // erase template - inline typename hydra::thrust::detail::enable_if<(I == N), void>::type + requires ((I == N)) + inline void __erase_helper( size_type , size_type ){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void>::type + requires ((I < N)) + inline void __erase_helper( size_type first_position, size_type last_position) { std::get(fData).erase( @@ -839,11 +854,13 @@ class multiarray> //__________________________________________ // insert template - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __insert_helper( size_type , const value_type&){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __insert_helper( size_type position, const value_type &x) { std::get(fData).insert( @@ -863,11 +880,13 @@ class multiarray> //__________________________________________ // insert template - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __insert_helper( size_type , size_type , const value_type&){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __insert_helper( size_type position, size_type n, const value_type &x) { std::get(fData).insert( @@ -885,11 +904,13 @@ class multiarray> //__________________________________________ // insert template - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __insert(size_type, InputIterator const&, InputIterator const& ){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __insert(size_type position, InputIterator const& first, InputIterator const& last ) { std::get(fData).insert(std::get(fData).begin() + position, diff --git a/hydra/multivector.h b/hydra/multivector.h index ed254408d..d1aa5d0f8 100644 --- a/hydra/multivector.h +++ b/hydra/multivector.h @@ -50,6 +50,8 @@ #include #include #include +#include +#include namespace hydra { @@ -174,7 +176,8 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy > object to copy from. */ - template::value>::type > + template + requires (std::integral) multivector(hydra::pair > const& pair) { __resize(pair.first); @@ -224,12 +227,8 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy::value) && - !(detail::is_iterator::value) && - (std::is_convertible().begin()), value_type>::value) - >::type > + template< typename Iterable> + requires ((hydra::detail::Iterable) && !(detail::is_iterator::value) && (std::is_convertible().begin()), value_type>::value)) multivector(Iterable&& other ) { __resize( hydra::thrust::distance( @@ -434,10 +433,8 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicyAssignable. */ template< typename InputIterator> - inline typename hydra::thrust::detail::enable_if< - detail::is_zip_iterator::value && - std::is_convertible::value_type, - value_type>::value, void>::type + requires (detail::is_zip_iterator::value && std::is_convertible::value_type, value_type>::value) + inline void insert(iterator pos, InputIterator first, InputIterator last) { size_type position = hydra::thrust::distance(begin(), pos); @@ -827,9 +824,9 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy + requires (hydra::detail::Iterable && ...) auto meld( Iterables&& ...iterables) - -> typename std::enable_if::value...>::value, - hydra::Range(iterables).begin()... ))>>::type + -> hydra::Range(iterables).begin()... ))> { auto first = detail::meld_iterators(begin(), std::forward(iterables).begin()... ); auto last = detail::meld_iterators(end(), std::forward(iterables).end()... ); @@ -913,11 +910,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __pop_back(){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __pop_back() { hydra::thrust::get(fData).pop_back(); @@ -928,11 +927,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __resize(size_type){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __resize(size_type n) { hydra::thrust::get(fData).resize(n); @@ -942,11 +943,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __push_back( value_type const& ){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __push_back( value_type const& value ) { hydra::thrust::get(fData).push_back( hydra::thrust::get(value) ); @@ -956,11 +959,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __clear(){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __clear( ) { hydra::thrust::get(fData).clear(); @@ -970,11 +975,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __shrink_to_fit(){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __shrink_to_fit( ) { hydra::thrust::get(fData).shrink_to_fit(); @@ -984,11 +991,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __reserve(size_type ){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __reserve(size_type size ) { hydra::thrust::get(fData).reserve(size); @@ -998,11 +1007,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void>::type + requires ((I == N)) + inline void __erase_helper( size_type ){ } template - inline typename hydra::thrust::detail::enable_if<(I < N), void>::type + requires ((I < N)) + inline void __erase_helper(size_type position ) { hydra::thrust::get(fData).erase( @@ -1021,11 +1032,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void>::type + requires ((I == N)) + inline void __erase_helper( size_type , size_type ){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void>::type + requires ((I < N)) + inline void __erase_helper( size_type first_position, size_type last_position) { hydra::thrust::get(fData).erase( @@ -1045,11 +1058,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __insert_helper( size_type , const value_type&){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __insert_helper( size_type position, const value_type &x) { hydra::thrust::get(fData).insert( @@ -1069,11 +1084,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __insert_helper( size_type, size_type, const value_type & ){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __insert_helper( size_type position, size_type n, const value_type &x) { hydra::thrust::get(fData).insert( @@ -1091,11 +1108,13 @@ class multivector< hydra::thrust::tuple, hydra::detail::BackendPolicy - inline typename hydra::thrust::detail::enable_if<(I == N), void >::type + requires ((I == N)) + inline void __insert(size_type , InputIterator , InputIterator ){} template - inline typename hydra::thrust::detail::enable_if<(I < N), void >::type + requires ((I < N)) + inline void __insert(size_type position, InputIterator first, InputIterator last ) { hydra::thrust::get(fData).insert(hydra::thrust::get(fData).begin() + position,