![]() |
Blitz Support : |
From: Julian Cummings (cummings_at_[hidden])
Date: 2004-10-18 21:29:54
Hello James,
I take your point about the overloaded methods for the Array class. Several
of these methods use a run-time assertion on the value of D in order to
check that the method was called with the right number of arguments for the
Array dimension. I suppose that these checks could be converted into
compile-time assertions instead. The trouble I see with doing this is that
not all compilers properly handle the instantiation of methods of a class
template, so I don't know if this would be a universal solution. I hesitate
to move to specializations for D={1-11}; that would be a huge pain. I have
not yet looked into porting issues for gcc 3.4, but I will try that in the
near future.
Regards, Julian C.
Dr. Julian C. Cummings Office: PB-111
Caltech/CACR, MC 158-79 Phone: 626-395-2543
1200 E. California Blvd. Fax: 626-584-5917
Pasadena, CA 91125
-----Original Message-----
From: blitz-support-bounces_at_[hidden]
[mailto:blitz-support-bounces_at_[hidden]] On Behalf Of James Evans
Sent: Thursday, October 14, 2004 9:39 AM
To: blitz-support_at_[hidden]
Subject: [Blitz-support] Template Specialization
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.