C++ template in the template as?

There's a line:
template<typename t>
class QueueList {
 QueueList ();

 void push (const T i);

 T pop ();


 typedef struct node {
 T item; 
 node * next;
 } node;

 typedef node * link; 

 int size; 
 link head; 
 link tail; 

template<typename t>
QueueList<t>::QueueList () {
 size = 0; 
 head = NULL; 
 tail = NULL; 

template<typename t>
void QueueList<t>::push (const T i) {

 link t = tail;

 tail = (link) new node;

 tail->next = NULL;

 tail->item = i;

 if (isEmpty ())

 head = tail;


 t->next = tail;


It placed structure:
struct listStruct{

 unsigned long limit;
 void (*func)(char *); 

Create a queue:
QueueList <liststruct> list;</liststruct>

And everything works but!
How to add a structure like this:

template<typename t>
struct listStruct{

 unsigned long limit; 

 void (*func)(T);

I would be grateful for any help in solving this problem.

The design view: templatetypename T> class C {...} swears...
September 18th 19 at 23:45
3 answers
September 18th 19 at 23:47
If the type T in the construction of void (*func)(T) must be the same as in the ambient class, then the template before listStruct it should be removed altogether. If the type must be other (as you can guess from the topic questions), then use a different type identifier, such as template struct listStruct {...}. The idea is that all this should be written in the message from the compiler.
September 18th 19 at 23:49
Write a partial specialization of the template QueueList.
template<template <typename> class C, typename T>
class QueueList< C<t> > {};</t></template>
And as it will look like a method call of a class and template structure?

template "<"class C, typename T">"
struct listStruct{

unsigned long limit;

void (C::*func)(T);

Create A QueueList "<""<"MyClass char*">" listStruct">" list; ? - Trevor_Gerhol commented on September 18th 19 at 23:52
As I understand it, listStruct is a simple wrapper for the callable object you want to add any function with one parameter(but any type) and no return value. Of course, I can say about the fact that one more specialization for class methods -
template<template <typename, typename> class C, class ClassType, typename ParamType>
class QueueList< C<classtype, paramtype> > {};<br>
but this question is too broad to answer here. I can only give the direction of the search, including on habré there were article on this subject - type erasure. If you are using C++11, there is std::function, std::bind, if not, that is boost, where the new standard they are moved.</classtype,></template>
- Destin_Grim commented on September 18th 19 at 23:55
Yes, you understand correctly. Boost is not possible to use this code to MK. I will try. Thank you for your participation. - Trevor_Gerhol commented on September 18th 19 at 23:58
September 18th 19 at 23:51
QueueList<liststruct<int> > queue;</liststruct<int>

don't forget probelem before the last '>'
(in With++ 11 do not care)

Find more questions by tags C++