Since the post by tabstop didn't illuminate:
Code:
#include <iostream>
#include <string>
#include <vector>
#include <typeinfo>
#include <cxxabi.h>
using namespace std;
template <typename T> vector<T>* addDepth(T x)
{
int status(0);
cout << abi::__cxa_demangle(typeid(vector<T>).name(), 0, 0, &status) << "\n\n";
return new vector<T>;
}
template <typename T> vector<T> mangevector(const T & t)
{
int status(0);
cout << abi::__cxa_demangle(typeid(vector<T>).name(), 0, 0, &status) << "\n\n";
return vector<T>();
}
int main(void) {
void *vec;
for (int i=0; i < 5; i++) {
if (i==0) addDepth(5);
else addDepth(vec);
}
int status(0);
cout << abi::__cxa_demangle(typeid(vec).name(), 0, 0, &status) << "\n\n";
mangevector(mangevector(mangevector(mangevector(mangevector(vector<int>())))));
return 0;
}
notice the rather... obvious difference between what you think you are getting and what you are really getting.
(Feel free to remove the G++ '
Code:
abi::__cxa_demangle(typeid(vec).name(), 0, 0, &status)
' in favor of '' for other compilers.)
Soma