template <class A> class ExternalFunction1
{
public:
ExternalFunction1(void (*func)(A)) : func(func)
{ }
void run(ScriptStack &stack)
{
A arg = *((A)stack.pop(sizeof(A)));
func(arg);
}
void (*func)(A);
};
When I make an instance of this class like this:
ExternalFunction<int> func(simpleFunction);
It works just how I expect it to. Poping the argument off my stack and passing it to the actual function just fine.
However, if I try to do something like this:
ExternalFunction<const int&> func(simpleFunction);
It wont compile, obviously because you cant instantiate something of type "const int&"
So, my question is, is there any way using templates to kind of extract the "base type" of a template?
So for example, If A was "const int&" what I want is "int"
That way, I can extract my argument from the stack without the const and the &
Sorry if thats a little confusing, let me know if I can explain it better.
THanks
template question
So, I have this very simple class used for my script system.
thanks a bunch, that looks like exactly what I need.
I cant use boost in my project though, do you know how these might be implemented?
I cant use boost in my project though, do you know how these might be implemented?
If you "can't use boost", just copy and paste from the boost headers. remove_const and remove_reference are each only a few lines long.
gotcha, I implemented it based on boosts implementations.
Now, this might be a silly question, but how exactly do I use for example remove_reference?
I have tried many different things just to test it like:
but no luck
Now, this might be a silly question, but how exactly do I use for example remove_reference?
I have tried many different things just to test it like:
void test(const int& param){ remove_reference<const int&> plain_int = param; ...}
but no luck
If you clicked on the link I gave, and then clicked on the remove_reference link on that page, you'd see a table contained expressions and their results. The expressions all look something like remove_reference<int>::type.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement