-
Notifications
You must be signed in to change notification settings - Fork 1
/
is_string.h
49 lines (43 loc) · 1 KB
/
is_string.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* File: is_string.h
* Author: massimo
*
* Created on October 17, 2017, 1:54 PM
*/
#pragma once
#include <string>
#ifndef NO_DEMANGLE
#include <cxxabi.h>
////////////////////////////////////////////////////////////////////////////////
namespace memvar
{
template <typename T>
std::string
type ()
{
std::string result;
int status;
char* demangled = abi::__cxa_demangle(typeid(T).name(),
nullptr, nullptr, &status);
result = demangled;
free(demangled);
return result;
}
#else
// no demangling
template <typename T>
std::string
type ()
{
return typeid(T).name();
}
#endif
template <typename T>
struct is_string
{
static inline const bool value = std::is_same<T, std::string>::value ||
std::is_same<T, std::wstring>::value ||
std::is_same<T, std::u16string>::value ||
std::is_same<T, std::u32string>::value;
};
} // namespace memvar