In C++ if you were to write a class just as an example:
Code:
enum CharacterClass
{
Fist = 1 << 0,
Blade = 1 << 1,
RedMage = 1 << 2,
Archer = 1 << 3,
BlueMage = 1 << 4,
};
template<CharacterClass ChrClass = Fist>
struct StartUp
{
static void GiveStats(Player &plr)
{
plr.Damage += 300;
}
};
template<>
struct StartUp<Blade>
{
static void GiveStats(Player &plr)
{
plr.Damage += 400;
}
};
We'd know that we could call:
Code:
StartUp<Fist>::GiveStats(Character);
To get 300 more Damage as noted in this example.
However when compiling this code with the code editor it first generates
Code:
template<CharacterClass = Fist>
struct StartUp;
template<>
struct StartUp;
Where as our argument list just got missing!
Then it'd also compile something like this into header files!
Code:
template<>
struct StartUp<Blade>
{
static void GiveStats(Player &plr);
};
template<CharacterClass ChrClass >
struct StartUp
{
static void GiveStats(Player &plr);
public:
StartUp();
};
template<CharacterClass ChrClass = Fist>
void StartUp<ChrClass>::GiveStats(Player &plr)
{
plr.Damage += 300;
}
template<CharacterClass ChrClass = Fist>
StartUp<ChrClass>::StartUp() : ChrClass(Fist) {}
And in a Cpp file this
Code:
void Unique StartUp 256677E4::GiveStats(Player &plr)
{
plr.Damage += 400;
}
Well, now we can start losing track of how many errors there possibly are in the compiled code..
This COULD work if it was changed around abit..
Code:
//Top Of @@Headers.h
template<CharacterClass = Fist>
struct StartUp;
template<>
struct StartUp<Blade>;
//SeperateHeaderFile
template<CharacterClass ChrClass >
struct StartUp
{
static void GiveStats(Player &plr);
public:
StartUp();
};
//SeperateHeaderFile
template<>
struct StartUp<Blade>
{
static void GiveStats(Player &plr);
};
So all we did in our Header files was to add argument list and some few things were deleted (Constructor body and GiveStats function)
instead we make a small few changes to those, and add those into cpp file.
Code:
void StartUp<Fist>::GiveStats(Player &plr)
{
plr.Damage += 400;
}
void StartUp<Blade>::GiveStats(Player &plr)
{
plr.Damage += 400;
}
StartUp<Fist>::StartUp() {}
You could either do that.. Or for partial template specialization that you include *that/those* header files last and keeping it 100% c++ style and still keeping..
Code:
//Top Of @@Headers.h
template<CharacterClass = Fist>
struct StartUp;
template<>
struct StartUp<Blade>;
But I could imagine that you've never thought about partial template specialization but it's a very nice feature and i'm using templates commonly and many systems that i've built standalone that I am importing are using just this method.
Now this all being said there's the argument list missing, and also redefinitions of default parameters. There's the constructor with an initialization list for the default argument?? and there are incorrect function names.
Now I'm not sure that this is a bug as i mentioned, but i'd highly appreciate it being added/fixed!
Note never tried partial template specialization using polymorphism and virtual base classes etc.
Best Regards TBJokers.