Search code examples
c++visual-c++dll

How to get the decorated name of a member function programmatically? (in MSVC will be better)


The reason I want to understand it is that I'm going to make a DLL loader class like this:

class DymanicLibraryLoader
{
    //some code
    template <typename FnPtrT>
    FnPtrT GetFunction(std::type_info& fn_type, std::string_view pretty_name)
    {
        //code
    }
};
//...
DynamicLibrary dll {...};
typedef void (SomeClass::* FnPtr)(int);
std::type_info& fntype = typeid(FnPtr);
auto fnptr = dll.GetFunction(fntype, "function")

//...

Solution

  • Have you tried std::typeinfo::raw_name()?