c++typeinfo

Strange output of std::typeid::name()


I used typeid to get the type names of the std::vector::size_type and a zero sized class A with the following code (cppreference):

#include<iostream>
#include <vector>
#include <typeinfo>

using namespace std;

class A {};

int main()
{
    vector<int> v(10); 

    vector<int>::size_type s = v.size(); 

    A a; 

    cout << typeid(s).name() << endl;
    cout << typeid(a).name() << endl;

};

And I got this as output:

m
1A

I guess that "1" before "A" is a result of the Empty Base Class Optimization, but what does "m" stand for and is this normal?

I am using the following gcc version: g++ (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3


Solution

  • G++ uses implementation-defined naming for the types, but it also offers the utility c++filt to make them human-readable:

    $ ./test | c++filt -t
    unsigned long
    A