Can you cache a virtual function lookup in C++?

前端 未结 9 1144
故里飘歌
故里飘歌 2021-01-31 15:39

Say I have a virtual function call foo() on an abstract base class pointer, mypointer->foo(). When my app starts up, based on the contents of a file, it chooses to instantiate a

9条回答
  •  情深已故
    2021-01-31 16:15

    I asked a very similar question recently, and got the answer that it's possible as a GCC extension, but not portably:

    C++: Pointer to monomorphic version of virtual member function?

    In particular, I also tried it with Clang and it doesn't support this extension (even though it supports many other GCC extensions).

提交回复
热议问题