I had fingered out what I should do now :)
Indeed, I initially want some 'partial template specialization' for the template function, which is not currently supported in the C++ standard(which _might_ be in the next C++0x). But I do find some workaround for that:
// declare a template class with a friend template function.
template<typena me B, typename D>
class mycast{
friend D* fun_cast<B,D>(B *...
User Profile
Collapse
-
How to specialized the template function when its parameter type are same?
template <class A, class B> inline B* mycast( A* a)
{
return dynamic_cast<B> (a);
}
// try to specialize the mycast to handle when B==A, such as:
template <class A> inline A* mycast(A* a)
{
return a; // since type B is identical to A.
}
// OR what else I should do to implement this function??????
//....somewhere we try to use mycast()...
No activity results to display
Show More
Leave a comment: