Sign in to follow this  

functor parameters

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this