# functor parameters

This topic is 4792 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hey! I am trying to pass a function into a functor's argument typelist. But this function is templated. Then I got some nasty compiler errors claiming that the argument type cannot be matched. So i was wondering if i might have missed out some kind of template magic... heres what i have tested so far:
//declare functor type
typedef Functor<bool,TYPELIST_2(int,void*)> RegType;

//the way the functor executes its callback
//which wont work though
(*regFunc)(0,CreateFunc<isPolymorphic>);

//this templated function cannot seemed to fit in the functor's 2nd argument
template<bool isPolymorphic>
BaseClass<isPolymorphic>* MyNamespace::CreateFunc()
{
return new DerivedClass<isPolymorphic>();
}

//the way the functor executes its callback
//which will work
(*regFunc)(0,CreateFunc);

//this templated function cannot seemed to fit in the functor's 2nd argument
BaseClass<true>* MyNamespace::CreateFunc()
{
return new DerivedClass<true>();
}


thx!

##### Share on other sites
You can't do that; you either have to pass in an explicit template function (fill in the types fot its parameters), or you need to create a functor generator that takes the template function as a template-template parameter and can produce a functor later when you have the types.

Post the code where you actually try to create a RegType functor.

For the line:
(*regFunc)(0,CreateFunc<isPolymorphic>);
isPolymorphic has to be a compile-time boolean, but it looks like you're trying passing to pass it an arguement.

Also, add a space to this declaration:
typedef Functor<bool,TYPELIST_2(int,void*)> RegType;
typedef Functor<bool,TYPELIST_2(int,void*) > RegType;

It might fail to compile otherwise as I think the pre-processed output would have a >>.

##### Share on other sites
ah i see.
i revamped the code to use another way to get ard that problem.
thx!

1. 1
2. 2
3. 3
frob
15
4. 4
5. 5

• 11
• 20
• 12
• 13
• 14
• ### Forum Statistics

• Total Topics
632146
• Total Posts
3004433

×