Is it possible to have a “non virtual pointer” in c++ ( ie a pointer that calls the methods directly without dynamic dispatch). This is because I am trying to do something like this:
template <typename T>
class Ref {
T* value; // I am 100% sure that value points to an actual T object.
/* constructors and stuff */
auto operator -> () {
return value;
}
};
But this will unnecessarily call virtual functions when I know the dynamic type of value to be T... I know that the user could enforce the usage of non-virtual functions like so:
X->Base::foo();
But that seems like another burden for the user. How can this be done automatically?