absolute value of vector of vertors
This code does not compile.
TNL::Containers::Vector<TNL::Containers::StaticVector<3,int>, TNL::Devices::Host, size_t> vec;
vec.setSize(2);
vec = TNL::Containers::StaticVector<3,int>{1,-2,3};
TNL::abs(a); // error
The compiler does not see this funciton from the context of function Abs::evaluate
:
////
// Abs
template< int Size, typename Real >
__cuda_callable__
auto
abs( const Containers::StaticVector< Size, Real >& a )
{
return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Abs >( a );
}
and the only visible function from the context is this one.
template< class T,
std::enable_if_t< ! std::is_unsigned<T>::value, bool > = true>
__cuda_callable__ inline
T abs( const T& n );
It does not apply the right function because the function abs( const Containers::StaticVector< Size, Real >& a )
is in the namespace TNL instead of TNL::Containers as its argument is. Moreover, the Abs::evaluate
calls TNL::abs
which does not trigger ADL (argument dependent lookup), see this. By the way that is the reason why operators +,-, etc. works properly. The same problem applies to other expression functions.