Blitz logo

Blitz Support :

From: James Evans (jrevans1_at_[hidden])
Date: 2004-10-14 11:39:23


Is it planned for Blitz to switch over to use proper template specialization instead of many overloaded methods with run-time checking?

There are issues that arise from not using specialization, for example:

If someone were to write a class like the following:

class Matrix: public blitz::Array<double, 2> {
   ...
}

the compiler is allowed to completely generate code for all methods of a 'blitz::Array<double, 2>' The problem arrises in functions such as 'resizeAndPreserve' where you say something like the following in the implementation:
T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2), storage_);

base() will return a TinyVector<int, 2>;
shape(...) will return a TinyVector<int, 3>;

this generates an invalid function prototype and fails even though this code will never get called. It is acceptable for the compiler to generate the necessary code however.

I realize that specializing 11 different classes can be repetetive and disgusting for maintenance, but in the long run it may be the best option.

--James Evans

PS: If you haven't looked at gcc-3.4x yet, it is much more stricter when it comes to standards compliance (especially in the are of templates). I havn't compiled blitz with it yet, but have other projects and have a feeling other things will break.