Skip to content
Snippets Groups Projects
Commit d82ceca8 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Math.h: disable scalar functions for array/class types to avoid possible...

Math.h: disable scalar functions for array/class types to avoid possible ambiguity with vector expressions
parent e4d7a2b5
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !49. Comments created here will be created in the context of that merge request.
...@@ -79,7 +79,7 @@ ResultType max( const T1& a, const T2& b ) ...@@ -79,7 +79,7 @@ ResultType max( const T1& a, const T2& b )
* \brief This function returns absolute value of given number \e n. * \brief This function returns absolute value of given number \e n.
*/ */
template< class T, template< class T,
std::enable_if_t< ! std::is_unsigned<T>::value, bool > = true > std::enable_if_t< ! std::is_unsigned<T>::value && ! std::is_class<T>::value, bool > = true >
__cuda_callable__ inline __cuda_callable__ inline
T abs( const T& n ) T abs( const T& n )
{ {
...@@ -147,7 +147,9 @@ ResultType argAbsMax( const T1& a, const T2& b ) ...@@ -147,7 +147,9 @@ ResultType argAbsMax( const T1& a, const T2& b )
/** /**
* \brief This function returns the result of \e base to the power of \e exp. * \brief This function returns the result of \e base to the power of \e exp.
*/ */
template< typename T1, typename T2, typename ResultType = typename std::common_type< T1, T2 >::type > template< typename T1, typename T2, typename ResultType = typename std::common_type< T1, T2 >::type,
// enable_if is necessary to avoid ambiguity in vector expressions
std::enable_if_t< ! std::is_class<T1>::value && ! std::is_class<T2>::value, bool > = true >
__cuda_callable__ inline __cuda_callable__ inline
ResultType pow( const T1& base, const T2& exp ) ResultType pow( const T1& base, const T2& exp )
{ {
...@@ -458,7 +460,9 @@ void swap( Type& a, Type& b ) ...@@ -458,7 +460,9 @@ void swap( Type& a, Type& b )
* It extracts the sign of the number \e a. In other words, the signum function projects * It extracts the sign of the number \e a. In other words, the signum function projects
* negative numbers to value -1, positive numbers to value 1 and zero to value 0. * negative numbers to value -1, positive numbers to value 1 and zero to value 0.
*/ */
template< class T > template< class T,
// enable_if is necessary to avoid ambiguity in vector expressions
std::enable_if_t< ! HasSubscriptOperator<T>::value, bool > = true >
__cuda_callable__ __cuda_callable__
T sign( const T& a ) T sign( const T& a )
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment