Template Template trouble
How can I write a function that takes as argument a object of a template class ?
For example:
1 2
|
template<class type>
struct simple{};
|
I tried to write a funtion which takes an template class object:
1 2
|
template<class cName,class tArg>
void func(cName<tArg> obj){}
|
And call func:
1 2
|
simple<int>a;
func<simple,int>(a);
|
But of course I got errors. Which is the proper way to do this ?
Thanks :)
1 2 3 4 5
|
template< template<class> class Name, class Arg >
void func( Name<Arg> obj )
//call
func(a); //you shouldn't need to specify the types
|
Thanks dude :)
Wouldn't it work to do this ? :
1 2
|
template<template<class Arg> class Name>
void func( Name<Arg> obj )
|
It kinda makes more sense...
Topic archived. No new replies allowed.