oomph::HasMagnitude< T, class > Struct Template Reference

Compile-time test to determine if a type T has a notion of "magnitude", i.e. if std::abs(T) is a valid expression. More...

#include <oomph_definitions.h>

+ Inheritance diagram for oomph::HasMagnitude< T, class >:

Detailed Description

template<class T, class = void>
struct oomph::HasMagnitude< T, class >

Compile-time test to determine if a type T has a notion of "magnitude", i.e. if std::abs(T) is a valid expression.

The primary template defaults to "false".

A partial specialisation (below) is selected automatically via SFINAE ("Substitution Failure Is Not An Error") if the expression

std::abs(std::declval<T>())

is valid. In that case HasMagnitude<T>::value evaluates to true.

This facility is used to prevent compilation failures in generic code where operations involving std::abs() only make sense for numerical types.

Example: HasMagnitude<double>::value -> true HasMagnitude<std::complex<double>>::value -> true HasMagnitude<Vector<double>>::value -> false

Definition at line 122 of file oomph_definitions.h.


The documentation for this struct was generated from the following file: