Can you describe what a virtual static function would mean?
I suspect that one reason that C++ has been reluctant to add support
for virtual static functions, is that no one seems to know what one is.
(The following are my definitions. They probably diverge from the standard
in the details.)
### Function requirements: "member" vs. "static"
A normal member function is one that requires an object *within the body
of the function*. It can be considered an "object level" function.
A static function is one that does not have an object instance passed into
it. It could be considered a "class level" function.
### Dispatch: "compile-time" vs. "run-time" binding
A call to a function can be bound at compile time ("statically" (ugh!)) or
at run time (dynamically). The latter is what virtual functions give you.
These above concepts are orthogonal to each other. You get four
combinations:
1) Object member function bound at compile time ("normal" object function
call: o->fun()).
2) Static function bound at compile time (ClassName::fun())
3) Object member function bound at run time ("virtual" function call:
o->vfun()
4) Static function bound at run time through an object instance (o->svfun())
Case number 4 is "virtual static" and requires an object to bind the
function, but the function call itself is "static", i.e. the function does
not require an object within its body and semantically is not an object
member function. You just use the object to dispatch to the right static
function.
I have wanted this in the past for dynamically invoking class-level
functions that are also invoked elsewhere without an object (static
binding). I usually end up with a static function for static binding *and*
a virtual function calling it for dynamic dispatch, but then I need to use
some less-than-ideal naming since they can't be called the same thing in
the class.
To the OP:
The best argument I've heard why this feature doesn't work is that if you
have a "vs" function then try to call *another* "vs" function
from within the first that you call, there is no object to dispatch with.
The chain is broken. Once you look at it from that perspective, you
realize a first-level call would work, but anything after that would be
limited enough to break normal C++ semantics (in my opinion).
- Jay