Andrey Semashev wrote:
On 02/10/18 18:43, Peter Dimov via Boost wrote:
But, if you really wanted to know, libstdc++ in a situation like the above (when the function has to be virtual because it's f.ex. specified that way by the standard) does something like the following:
#if cpp11
virtual int __f( boost::function
const& F ) = 0; virtual int f( std::function const& F ) = 0; #else
virtual int f( boost::function
const& F ) = 0; virtual int __f( std::function const& F ) = 0; #endif
except of course we don't have std::function in C++03 mode, so even declaring __f will be a problem.
If you rely on the particular algorithm of vftable slot allocation,
I've never heard of a vtable slot allocation algorithm that is not the particular one that everyone uses.
declaring is not a problem - you can declare pretty much whatever virtual function. It's not going to be called anyway and its sole purpose is to reserve a particular slot.
It is going to be called, when a C++11 exe calls a C++03 library. It's true that you can declare whatever you want (within limits - the calling convention must stay the same), but you can't use it because it's not going to be whatever you declared, it's going to be std::function.