|
If you are using VS 2005 ensure that you have service pack 1 installed as this will generate code with better support for intel duo processors.
|
|
|
|
|
Hello,
no i use vs6 with sp6.
thanks
termal
|
|
|
|
|
template< typename A, typename B> class CMyClass{
...
}
I need to do template specialization only to set A=MyTypeName , so...what syntax is required?
something like this? (in the .cpp file?)
template<:confused::confused:,typename B>
CMyClass<MyTypeName,B>::foo(){..}
Russell
|
|
|
|
|
Doesn't work as when adding default values to parameters in a function definition?
I mean something like:
template < typename A /*= MyTypeName*/, typename B >
or something like that.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
no, sorry,...I have to specialize MyTypeName1 , MyTypeName2 and MyTypeName3 , so default values are not the solution.
I need a 'partial' specialization, I think. But I don't find the right sintax.
Russell
|
|
|
|
|
But this partial spezialitation is to use the same template function with different typenames but doing differnt things if one type or another? or to support different typenames with the same functionality?
I think I don't understand you correctly.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
|
Have you seen the article that is in an answer in the message below??
this article[^]
Maybe you can take something there. I have found it ok, and maybe, that with the typename T and the explicit instatiation is the solution you are looking for.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
I don't work very often with that kind of things but I think that template specialization only works at the class level, not at the method level: you need to specialize your class and there, you can override the functions you like.
I think, in your situation it will be like this:
template <typename B><br />
class CMyClass<MyTypeName,B><br />
{<br />
};
I'm not 100% sure thought, so you'll have to check.
|
|
|
|
|
And what about ...?
template < class A, class B >
class CMyClass < A, B >::foo (class A1)
{
if (A1->IsKindOf (RUNTIME_CLASS ( A )))
else
}
EDIT: I actually am not sure if I understand the question right. A bit more info would be nice.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
sure...in that way it could work, but I prefere to use a simple "template specialization" it works well if all typename s must be specialized. But this is the first time that I have to specialize only a typename , so I I'm trying to find the correct sintax.
thanks for your time
Russell
|
|
|
|
|
I'm trying... I'll tell you the results tomorrow.
thanks
Russell
|
|
|
|
|
Hi,
I have found out (the hard way!) that you can't have a .cpp file with your function definitions if you are using a template class. All your function definitions must be in the .h file. Why is this?
Thanks for any info.
|
|
|
|
|
You can put the code in a C++ file, you just need to change how you define your templates.
I would not recommend that though, justuse a header file it's much easier.
regards,
|
|
|
|
|
Hi,
Thanks for that, but do you know why the C++ compilier objects to having function definitions in the .cpp ?
Thanks.
|
|
|
|
|
AFAIK it is because template code is generated by your compiler. It means that when you have a template instantiation (something like list<float> ) your compiler will generate code corresponding to this template type. To be able to generate the code, it needs the complete function implementation.
|
|
|
|
|
You do *not* have to have definitions in th ecpp.
You do this to (partially) separate interface and implementation.
With templates, every instantiation (for type A, type B etc) creates a new, distinct type: vector<A> is different from vector<B>.
And for this instantiation, the compiler needs the complete definition of the template. Therefore it is easiest to put the template in the header, to have it ready when you need it.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Yes, all in the .h file.
Only specializations must be putted in the .cpp file (declaraion, of course, in the .h file).
minkowski wrote: Why is this?
I think that this has only a reason related to how the compiler works to elaborates the templates.
I hope that this isn't a problem for you.
Russell
|
|
|
|
|
minkowski wrote: Why is this?
See here[^]
|
|
|
|
|
I have a list control of CListCtrl type and it has 3 columns. I want to hide the first column(of course, it will work internally). Is it possible?
|
|
|
|
|
Just out of curiosity, why do you need/want to do this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Cant you make it of zero width?
- NS -
|
|
|
|
|
How about setting the width of that column to zero?
MS
|
|
|
|
|
Can you more explain why you need to do it?
|
|
|
|
|
plz tel the Difference between debug and release builds.
|
|
|
|