mercredi 29 mars 2017

storing pointer to member function does not work for clang++

when i use clang++ i can only call the pointer-to-member function i can't cast it or assign it to a variable to call i when needed (i want to store this variable to an array of functions) but with g++ i can do that take this for example

class Base {
    public:
        typedef void (Base::*A)();
        virtual void some_func() = 0;
};
class B: public Base {
    public:
        void some_func() {
            return
        }
};
int main() {
    B b;
    auto h = (Base::A)&Base::some_func;
    typedef void (*my_function)();
    auto some_func = (my_function)(b.*h);
    some_func();
    return 0;
}

with g++ this do compile and run, but with clang++ i get reference to non-static member function must be called; did you mean to call it with no arguments? ( please note that i can't use any std::x functions in my code because the code run on bare metal

Aucun commentaire:

Enregistrer un commentaire