Hey,
I’m currently trying to get a kind of special template to work. This is a very minimal example to show exactly what’s going wrong.
Here’s the Template:
template <typename ClassT, int (ClassT::*Func)() const>
class TEST
{
};
This code is the Entity.h file of my project:
TEST<Entity, &Entity::getA> test = TEST<Entity, &Entity::getA>();
The code compiles fine for iOS with Xcode but does not for Android with the following errors. It’s no option to do the initializing in the constructor - I know that works, but I need this to be one-liners in the .h file.
This is the error log:
jni/../../Classes/Entity.h:37:54: warning: extra qualification 'Entity::' on member 'getA' [-fpermissive]
TEST<Entity, &Entity::getA> yoyo = TEST<Entity, &Entity::getA>();
^
jni/../../Classes/Entity.h:37:62: error: expected ';' at end of member declaration
TEST<Entity, &Entity::getA> yoyo = TEST<Entity, &Entity::getA>();
^
jni/../../Classes/Entity.h:37:62: error: 'TEST<Entity, &Entity::getA>& Entity::getA' conflicts with a previous declaration
jni/../../Classes/Entity.h:29:9: note: previous declaration 'int Entity::getA() const'
int getA() const {
^
jni/../../Classes/Entity.h:37:66: error: expected unqualified-id before '>' token
TEST<Entity, &Entity::getA> yoyo = TEST<Entity, &Entity::getA>();
^
jni/../../Classes/Entity.h:37:45: error: wrong number of template arguments (1, should be 2)
TEST<Entity, &Entity::getA> yoyo = TEST<Entity, &Entity::getA>();
^
A friend told me that I could try to tag you here, @elvman, since you’re advanced in C++. Would be cool if you could have a look, but of course every single answer is highly appreciated!