Hi Julian
The wrapper would be invoked explicitly (A is a blitz array):
testWrapper<T>(reinterpret_cast<MKL_Traits<T>::mType *>(A.data()),&i);
My question was more a general one, in the sense of, why does this not work in VC++ while it does in g++. Is this non standard use of the templates? In VC++ the problem is not that it can't find the templates, it that it refuses to recognise the specialisations as specialisations of that template, the error it gives is:
c:\Documents and Settings\crega\My Documents\Visual Studio Projects\templateTest\templateTest.cpp(16) : error C2912: explicit specialization; 'void testWrapper<float>(MKL_Traits<T>::mType *,int *)' is not a specialization of a function template
with
[
T=float
]
g++ has no problem with it.
As you said, the templates don't really add any advantage over overloading, I checked the generated assembly over the weekend, and I am going with overloading, but I am still curious as to why my code did not work with visual studio.
Thanks for your help
Carlos A. Rega, PhD
Development Scientist
Malvern Instruments Ltd
Grovewood Rd, Malvern
WR14 1XZ
Tel: +44 (0)1684 581 304
Fax: +44 (0)1684 892 789
e-mail: carlos.rega@malvern.co.uk
|
| Julian Cummings <cummings@cacr.caltech.edu>
Sent by: blitz-support-bounces@oonumerics.org
11/06/2004 21:06
Please respond to Support list for Blitz++
|
To: carlos.rega@malvern.co.uk
cc: Support list for Blitz++ <blitz-support@oonumerics.org>
Subject: Re: [Blitz-support] Template support in VC++ .NET |
Hi Carlos,
I am still not clear on how you are invoking your testWrapper function
template. When you have an array of complex values, do you pass a
std::complex<float>* or a MKL_Complex8* as the first argument to
testWrapper? Also, do you specify the template argument, or do you
assume that the compiler should be able to deduce this? If you pass a
MKL_Complex8* as the first argument to testWrapper, I do not believe
that the compiler can automatically deduce that the template argument
should be std::complex<float>, since T=MKL_Complex8 would produce the
same exported type mType. If instead you pass a std::complex<float>*,
it will not be automatically converted to a MKL_Complex8*, so you have
to explicitly cast the pointer to the proper type.
I can see the value of using the MKL_Traits struct to allow a general
representation of your matrix decomposition class, but I don't think the
function template testWrapper adds any value here, since it has to be
fully specialized anyway. Using a non-templated overloaded wrapper
function just seems simpler to me in this case, and there should be no
difference in terms of function inlining. By the way, there is an error
in your code for testWrapper below. The typename keyword should not be
used in the specializations of the testWrapper function template, only
in the general template.
Regards, Julian C.
--------------------------------------------------------------------------------------------------------------------
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed.
If you have received this email in error please notify the
originator of the message.
Any views expressed in this message are those of the individual
sender, except where the sender specifies and with authority,
states them to be the views of Malvern Instruments.