TooN 2.1
|
Is a number a field? i.e., +, -, *, / defined. More...
#include <TooN.h>
Static Public Attributes | |
static const int | value = numeric_limits<C>::is_specialized |
Is a number a field? i.e., +, -, *, / defined.
Specialize this to make TooN work properly with new types. See, for example functions/fadbad.h
Specifically, is the type on the default field. Because of the conversion rules of C++, TooN uses a rather loose definition of field. The a type is on the default field if arithmetic works between it and any builtin numeric type. So, for instance unsigned char and float are considered to be on the default field even though by themselves they form very different fields.
See also Field.
The reason for this is so that makeVector(1, 0, 0)
behaves as expected even though it will actually be a Vector<3,int>
.
The primary reason for this is to allow SFINAE to work properly. This is required if there are the following two functions:
Vector<> * X //Generic type X
Vector<> * DiagonalMatrix<>
If one of the functions is a substitution failure, then it will be ignored, allowing the functions to coexist happily. However, not all types of failure are substitution failures. TooN's type deduction happens when determining the return type of the function. This is too early, so the wrong kind of error in the return type deduction causes an error, rather than a substitution failure. The IsField mechanism makes it the right kind of error, thereby allowing a substitution failuer to occur.