Classdesc  3.D29
typeName_epilogue.h
1 /*
2  @copyright Russell Standish 2000-2013
3  @author Russell Standish
4  This file is part of Classdesc
5 
6  Open source licensed under the MIT license. See LICENSE for details.
7 */
8 
9 #ifndef TYPENAME_EPILOGUE_H
10 #define TYPENAME_EPILOGUE_H
11 
12 namespace classdesc
13 {
14  // generically handle new integral types
15  template <class T> typename
16  enable_if< Not<is_const<T> >,std::string>::T
17  integralTypeName()
18  {
19  std::ostringstream os;
20  os<<CHAR_BIT*sizeof(T);
21  return (is_unsigned<T>::value?"unsigned int":"int")+os.str()+"_t";
22  }
23 
24 // template <class T> typename
25 // enable_if< is_const<T>, std::string>::T integralTypeName()
26 // {return "const "+integralTypeName<typename std::remove_const<T>::type>();}
27 
28  template <class T> typename
29  enable_if<And<Not<is_const<T> >,is_integral<T> >,std::string>::T
30  typeNamep() {return integralTypeName<T>();}
31 
32  template <class T> typename
33  enable_if<And<Not<is_const<T> >,Not<is_integral<T> > >,std::string>::T
34  typeNamep() {return tn<T>::name();}
35 
36  template <class T> typename
37  enable_if<is_const<T>,std::string>::T
38  typeNamep() {return "const "+typeName<typename remove_const<T>::type>();}
39 
40  template <class T> std::string typeName() {return typeNamep<T>();}
41 
42 // template <class T>
43 // struct tn<const T>
44 // {
45 // static std::string name() {return "const "+typeName<T>();}
46 // };
47 }
48 #endif