[ox/model] Add string type template parameter to getModelTypeName

This commit is contained in:
Gary Talent 2021-12-01 01:34:05 -06:00
parent 2c8f4cec2c
commit 97bf81ba23

View File

@ -44,8 +44,8 @@ struct TypeNameCatcher {
}; };
template<typename T> template<typename T, typename Str = const char*>
constexpr const char *getModelTypeName() noexcept { constexpr Str getModelTypeName() noexcept {
auto a = std::allocator<T>(); auto a = std::allocator<T>();
auto t = a.allocate(1); auto t = a.allocate(1);
TypeNameCatcher nc; TypeNameCatcher nc;
@ -54,14 +54,14 @@ constexpr const char *getModelTypeName() noexcept {
return nc.name; return nc.name;
} }
template<typename T> template<typename T, typename Str = const char*>
constexpr const char *getModelTypeName(T *val) noexcept { constexpr Str getModelTypeName(T *val) noexcept {
TypeNameCatcher nc; TypeNameCatcher nc;
oxIgnoreError(model(&nc, val)); oxIgnoreError(model(&nc, val));
return nc.name; return nc.name;
} }
template<typename T> template<typename T, typename Str = const char*>
constexpr auto ModelTypeName_v = getModelTypeName<T>(); constexpr auto ModelTypeName_v = getModelTypeName<T, Str>();
} }