Call in-library only class member


I'm trying to call class members which are not used within the original source code and therefore are not declared within bitcode. An example would be calling std::vector<T>::size(). Right now I'm using a helper function, e.g.

int f(vector<int> &v) {
     return (int)v.size();

However, this solution is not as elegant as I would like it to have, mostly due to the fact that with changing T i have to provide additional code. So I wondered whether it is possible to declare a function and recompile the resulting bitcode again with the result that the correct function of the object gets called.

From what I can see from [1] Kenneth Uildriks mentions JIT and also that a declaration can be included. But I'm unable to link this proposed solution to my actual problem.


[1]: How can we call an object's virtual function inside IR?