c++typeid

What does the integer shown in typeid().name() mean?


What does the integer shown in the output of typeid().name() mean? For example:

#include<iostream>
#include<typeinfo>

class implementer{
public :
    void forNameSake()
    {
    }
};

int main()
{
    implementer imp2;
    std::cout<<typeid(imp2).name();
}

Gives the output:

11implementer

What does the 11 in the output mean?


Solution

  • What does the 11 in the output mean?

    In this particular case, most probably it means the length of the identifier that follows. implementer is 11 characters.

    You might be interested in https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.name, specifically in the <source-name> ::= <positive length number> <identifier> part.