-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypeName_epilogue.h
63 lines (53 loc) · 1.6 KB
/
typeName_epilogue.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
@copyright Russell Standish 2000-2013
@author Russell Standish
This file is part of Classdesc
Open source licensed under the MIT license. See LICENSE for details.
*/
#ifndef CLASSDESC_TYPENAME_EPILOGUE_H
#define CLASSDESC_TYPENAME_EPILOGUE_H
#include "classdesc.h"
#include "typeName-allCDs.h"
namespace classdesc
{
// generically handle new integral types
template <class T> typename
enable_if< Not<is_const<T> >,std::string>::T
integralTypeName()
{
std::ostringstream os;
os<<CHAR_BIT*sizeof(T);
return (is_unsigned<T>::value?"unsigned int":"int")+os.str()+"_t";
}
template <class T> typename
enable_if<And<Not<is_const<T> >,is_integral<T> >,std::string>::T
typeNamep() {return integralTypeName<T>();}
#if defined(__cplusplus) && __cplusplus>=201103L
template <class T>
struct tn<T, void_t<typename std::iterator_traits<T>::value_type>>
{
static std::string name() {return "iterator";}
};
#endif
template <class T> typename
enable_if<
And<
And<Not<is_const<T> >,Not<is_integral<T> > >,
Not<is_function<T> >
>,std::string>::T
typeNamep() {return tn<T>::name();}
template <class T> typename
enable_if<is_const<T>,std::string>::T
typeNamep() {return "const "+typeName<typename remove_const<T>::type>();}
template <class T>
typename enable_if<And<Not<is_function<T> >,Not<is_member_function_pointer<T> > >, std::string>::T
typeName() {return typeNamep<T>();}
#if defined(__cplusplus) && __cplusplus>=201103L
template <class T>
struct tn<T&&>
{
static std::string name() {return typeName<T>();}
};
#endif
}
#endif