- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm unable to use partial template specializations in my code using the intel 11.0.72 compiler on win32.
my full template looks like this:
template
void Matrix::Avarage()
But when i want to use a partial specialization on the folowing line
template
void Matrix ParallelMode::MPI>::Avarage()
I get the folowing error
error: template argument list must match the parameter list
Any suggestions?
my full template looks like this:
template
void Matrix
But when i want to use a partial specialization on the folowing line
template
void Matrix
I get the folowing error
error: template argument list must match the parameter list
Any suggestions?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In C++ function templates cannot be partially specialized, but class
templates can. Therefore, the workaround is to make a single generic
function template that calls a member function of a generic class
template. Then write a partial specialization for the class template
that does what you want. In other words write a specialization of the Matrix class
like this:
template
class Matrix {
public:
void Avarage();
};
template
class Matrix
{
public:
void Avarage();
};
template
void Matrix
template
void Matrix
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In C++ function templates cannot be partially specialized, but class
templates can. Therefore, the workaround is to make a single generic
function template that calls a member function of a generic class
template. Then write a partial specialization for the class template
that does what you want. In other words write a specialization of the Matrix class
like this:
template
class Matrix {
public:
void Avarage();
};
template
class Matrix
{
public:
void Avarage();
};
template
void Matrix
template
void Matrix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Judith!
But one more question. Should I repeat the complete matix definition (like all other member fuctions and the member variables) for each partial specialization?
But one more question. Should I repeat the complete matix definition (like all other member fuctions and the member variables) for each partial specialization?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - gert.massa
Thanks Judith!
But one more question. Should I repeat the complete matix definition (like all other member fuctions and the member variables) for each partial specialization?
But one more question. Should I repeat the complete matix definition (like all other member fuctions and the member variables) for each partial specialization?
It would probably be easier to use the generic template class as a base class for any functions that don't need to be partly specialized, i.e.:
template
class Matrix
public Matrix
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page