
On 02/10/18 20:13, Peter Dimov via Boost wrote:
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.
Well, yes, but that's not a problem for libstdc++, because, presumably, it is always compiled with the latest C++ supported by the compiler. So the std::function declaration is only replaced with a dummy when it cannot be called. Maybe a similar convention is possible for Boost as well, i.e. we support linking executables compiled only for C++ <= N, where N is the version that Boost was compiled for. It's difficult to enforce, though.