template<class T, class G>
class twoTemplateClass {
public:
void gg() {}
};
asMETHOD( twoTemplateClass<int,int>, gg); // error c2645
asSMethodPtr<sizeof(void ( twoTemplateClass<int,int>::*)())>::Convert((void (twoTemplateClass<int,int>::*)())(&twoTemplateClass<int,int>::gg)); // compile properly.
I directly expand the c and m inside of asMethod, it compiles fine. Is there some problem with Macro expanding? Cheers
asMethod
This code will produce compiling error:
The preprocessor doesn't recognize the template brackets so it looks like you're passing three arguments to the macro rather than two. Try using a typedef for your template. Ex:
typedef twoTemplateClass<int,int> myTwoTemplateClass;asMETHOD(myTwoTemplateClass, gg);
It works.
interesting:
if you have a function template with two arguements, you do this:
It works, but with method, it doesn't.
it looks like compiler can not understand this:
after it expands the term.
Anyway, thanks for the help!
because everytime
interesting:
if you have a function template with two arguements, you do this:
asFUNCTION((templateFptr<int,int>));
It works, but with method, it doesn't.
it looks like compiler can not understand this:
void ( twoTemplateClass<int,int>::*)()
after it expands the term.
Anyway, thanks for the help!
because everytime
Quote:
Original post by SiCrane
The preprocessor doesn't recognize the template brackets so it looks like you're passing three arguments to the macro rather than two. Try using a typedef for your template. Ex:typedef twoTemplateClass<int,int> myTwoTemplateClass;asMETHOD(myTwoTemplateClass, gg);
asMETHOD((tmpl<int>),mthd) expands to
while asFUNCTION((tmpl<int>)) expands to
The first creates an invalid syntax because of the extra parenthesis, but in the second the parenthesis envelopes the entire expression thus doesn't invalidate the syntax.
Unfortunately I don't think there is any other solution than what SiCrane already suggested, i.e. to use a typedef.
asSMethodPtr<sizeof(void ((tmpl<int>)::*)())>::Convert((void ((tmpl<int>)::*)())(&(tmpl<int>)::mthd))
while asFUNCTION((tmpl<int>)) expands to
asFunctionPtr((tmpl<int>))
The first creates an invalid syntax because of the extra parenthesis, but in the second the parenthesis envelopes the entire expression thus doesn't invalidate the syntax.
Unfortunately I don't think there is any other solution than what SiCrane already suggested, i.e. to use a typedef.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Quote:
Original post by dxj19831029
It works.
interesting:
if you have a function template with two arguements, you do this:asFUNCTION((templateFptr<int,int>));
It works, but with method, it doesn't.
it looks like compiler can not understand this:void ( twoTemplateClass<int,int>::*)()
after it expands the term.
The preprocessor is a macro processor fitted to the C programming language, so it will recognise the nestedness of braces. This means the preprocessor will recognise "," as the argument seperator, when it is at the "top-level". But when it is inside a "nest" of "(" and ")" (those nests may contain more nests), it will eat up the "," and write it to the final result.
It will also recognise string literals. Have a look at the following piece of C-code (just for demonstration purposes, actually bad code):
#include <stdio.h>#define ifif(cond, then) if (cond) thenint main() { int i = 0; // "," eaten because it is inside "(" and ")" ifif ( (0==i), printf ("is zero:%i", i);) // "," eaten because it is inside "(" and ")", has nothing to do with curly braces ifif ( (0!=i), {printf ("ain't zero:%i", i); }) // ","'s will be eaten because it's inside a string literal ifif ( (2==i), char *s = ",,,,,,,"; ) // will fail. demonstrates uselessness of curly-braces in that respect. //ifif ( (0!=i), { puts("ain't"), printf (" zero, dude:%i", i); }); return 0;}
Oh, and btw, let this be an example why you should *never* misuse the C preprocessor as a general purpose text processor, i.e. don't use for anything not C-like.
Thanks for the tips (All). it really helps me a lot.
:).
:).
Quote:
Original post by phresnel Quote:
Original post by dxj19831029
It works.
interesting:
if you have a function template with two arguements, you do this:asFUNCTION((templateFptr<int,int>));
It works, but with method, it doesn't.
it looks like compiler can not understand this:void ( twoTemplateClass<int,int>::*)()
after it expands the term.
The preprocessor is a macro processor fitted to the C programming language, so it will recognise the nestedness of braces. This means the preprocessor will recognise "," as the argument seperator, when it is at the "top-level". But when it is inside a "nest" of "(" and ")" (those nests may contain more nests), it will eat up the "," and write it to the final result.
It will also recognise string literals. Have a look at the following piece of C-code (just for demonstration purposes, actually bad code):
*** Source Snippet Removed ***
Oh, and btw, let this be an example why you should *never* misuse the C preprocessor as a general purpose text processor, i.e. don't use for anything not C-like.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement