Add util::type_name
This commit is contained in:
parent
7b929ec951
commit
fca22c93e2
2 changed files with 31 additions and 0 deletions
18
libs/util/include/psemek/util/type_name.hpp
Normal file
18
libs/util/include/psemek/util/type_name.hpp
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <typeinfo>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace psemek::util
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string type_name(std::type_info const & type);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::string const & type_name()
|
||||||
|
{
|
||||||
|
static std::string const result = type_name(typeid(T));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
13
libs/util/source/type_name.cpp
Normal file
13
libs/util/source/type_name.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include <psemek/util/type_name.hpp>
|
||||||
|
|
||||||
|
#include <boost/core/demangle.hpp>
|
||||||
|
|
||||||
|
namespace psemek::util
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string type_name(std::type_info const & type)
|
||||||
|
{
|
||||||
|
return boost::core::demangle(type.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue