Developer Documentation
Loading...
Searching...
No Matches
typename.hh
1#pragma once
2
7
8#include <string>
9#include <typeinfo>
10#include <vector>
11#include <OpenMesh/Core/Mesh/Handles.hh>
12#include <OpenMesh/Core/Geometry/VectorT.hh>
13
14namespace OpenMesh {
15
16template <typename T>
17std::string get_type_name()
18{
19#ifdef _MSC_VER
20 // MSVC'S type_name returns only a friendly name with name() method,
21 // to get a unique name use raw_name() method instead
22 return typeid(T).raw_name();
23#else
24 // GCC and clang curently return mangled name as name(), there is no raw_name() method
25 return typeid(T).name();
26#endif
27}
28
29template <typename T>
30bool is_correct_type_name(const std::string& name)
31{
32#ifdef _MSC_VER
33 // MSVC'S type_name returns only a friendly name with name() method,
34 // to get a unique name use raw_name() method instead
35 const char* correct_name = typeid(T).raw_name();
36#else
37 // GCC and clang curently return mangled name as name(), there is no raw_name() method
38 const char* correct_name = typeid(T).name();
39#endif
40 size_t pos = 0;
41 while (pos < name.size() && correct_name[pos] != 0 ) {
42 if (correct_name[pos] != name[pos]) {
43 return false;
44 }
45 ++pos;
46 }
47 return correct_name[pos] == 0 && pos == name.size();
48}
49
50}//namespace OpenMesh