Reputation: 1655
I've the following types:
typedef unsigned int uint32;
typedef void* ptr;
struct memory_options {};
struct memory_provider {};
template <typename options>
struct memory_track {};
template <typename options>
struct no_memory_track : public memory_track<options> {};
template<typename options>
struct defrag_memory_track : public memory_track<options> {};
template<typename options>
struct full_memory_track : public memory_track<options> {};
template <typename options, typename prov, typename track>
struct memory_algorithm : public track < options > {};
int main()
{
}
This types used to define a custom memory manager.
The problem is the class memory_algorithm
will inherit from another class, that class will always take a template parameter
that represent memory_options
class, i call it options
. The base class may be a partial specialization from memory_track
or a subclass from it, so in memory_algorithm
i passed 2 template parameters one represents the class name - i.e. track
- and the other represent the memory_options
class - i.e. options
- now whenever i tried to compile the code with sample test unit using GCC and Visual C++ 2008 i got the error:
for visual c++:
missing ',' before '<'
see reference to class template instantiation 'memory_algorithm' being compiled
for GCC:
error: expected template-name before '<' token
error: expected '{' before '<' token
error: expected unqualified-id before '<' token
What is the problem and how to fix it?
Upvotes: 3
Views: 1291
Reputation: 126432
If I understand your question correctly, what you need is probably to make track
a template template parameter, rather than a regular type parameter:
template <typename options, typename prov, template<typename> class track>
// ^^^^^^^^^^^^^^^^^^^^^^^^
struct memory_algorithm : public track < options > {};
Upvotes: 4