Ahh, such interesting posts that detail my exact thought process before I posted this question
I knew it would get thoughts rolling!
1. "texcoord_dimension" is NOT a variable. If it was, it would be illegal to declare an array like int blah[texcoord_dimension] in my class, and that''s perfectly possible.
2. Yes, the precompiler is a single-pass thing, per source file, NORMALLY, but not for header files. The template is declared in a header, and the header is included in your source file when you need it. For an example of this, look at the Mesa3D source code, the triangle rasterisers. They have a #define based C template in a header file, and it is included multiple times in the same source file, to different effect each time because the macros in the header file are redefined each time. So that''s why I thought it COULD be possible to use #if.
3. #if doesn''t work. Don''t ask me why, I can''t explain it, but it''s not all that unexpected. It probably has to do with the way templates are parsed, and what kind of constructs the template parameters are internally. Most likely, they are invisible to the preprocessor, so the condition is always false.
I guess I could look it up in the C++ specs, but that would be more effort than it''s worth
. I don''t want to use preprocessor macros!
4. Relying on the compiler to optimise. I have thought about this. The only problem is that I can''t force it to strip a class member using that method. I can''t put an if-statement into a class declaration.
Oh well, I guess I''m just sick trying to do these things using templates! It would just be handy because I''ll have to change those vertex classes too damn often for it to be fun to rewrite the class constantly.
#pragma DWIM // Do What I Mean!
~ Mad Keith ~
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.