Two answers spring to mind:
The non-const version is a closer match.
If it called the const overload for the non-const case, then under what circumstances would it ever call the non-const overload?
You can get it to use the other overload by casting a
to a const Foo *
.
Edit: From C++ Annotations
Earlier, in section 2.5.11 the concept
of function overloading was
introduced. There it noted that member
functions may be overloaded merely by
their const attribute. In those cases,
the compiler will use the member
function matching most closely the
const-qualification of the object: