]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/icl/include/boost/icl/type_traits/type_to_string.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / icl / include / boost / icl / type_traits / type_to_string.hpp
1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2007-2009: Joachim Faulhaber
3 +------------------------------------------------------------------------------+
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENCE.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7 +-----------------------------------------------------------------------------*/
8 #ifndef BOOST_ICL_TYPE_TO_STRING_HPP_JOFA_080416
9 #define BOOST_ICL_TYPE_TO_STRING_HPP_JOFA_080416
10
11 #include <stdio.h>
12 #include <string>
13 #include <sstream>
14
15 #include <boost/type_traits/is_integral.hpp>
16 #include <boost/type_traits/is_float.hpp>
17 #include <boost/mpl/if.hpp>
18
19 namespace boost{ namespace icl
20 {
21 //--------------------------------------------------------------------------
22 template<class Type>
23 struct type_to_string
24 {
25 /** Convert the type to it's typestring */
26 static std::string apply();
27 };
28
29
30 //--------------------------------------------------------------------------
31 template<>inline std::string type_to_string<bool>::apply() { return "bool"; }
32 template<>inline std::string type_to_string<char>::apply() { return "char"; }
33 template<>inline std::string type_to_string<short>::apply(){ return "short"; }
34 template<>inline std::string type_to_string<int>::apply() { return "int"; }
35 template<>inline std::string type_to_string<long>::apply() { return "long"; }
36 template<>inline std::string type_to_string<long long>::apply(){ return "Long"; }
37
38 template<>inline std::string type_to_string<unsigned char>::apply(){ return "char+"; }
39 template<>inline std::string type_to_string<unsigned short>::apply(){ return "short+"; }
40 template<>inline std::string type_to_string<unsigned int>::apply() { return "int+"; }
41 template<>inline std::string type_to_string<unsigned long>::apply() { return "long+"; }
42 template<>inline std::string type_to_string<unsigned long long>::apply(){ return "Long+"; }
43
44 template<>inline std::string type_to_string<float>::apply() { return "flt"; }
45 template<>inline std::string type_to_string<double>::apply() { return "dbl"; }
46 template<>inline std::string type_to_string<std::string>::apply() { return "string"; }
47
48 //-------------------------------------------------------------------------
49 template<template<class> class Templ>
50 struct unary_template_to_string
51 {
52 static std::string apply();
53 };
54
55 template <template<class>class Unary, class Type>
56 struct type_to_string<Unary<Type> >
57 {
58 static std::string to_string()
59 {
60 return unary_template_to_string<Unary>::apply()+"<"+type_to_string<Type>::apply()+">";
61 }
62 };
63
64 // ---------------------------------------------------------------------------
65 template<template<class,class>class Templ>
66 struct binary_template_to_string
67 {
68 static std::string apply();
69 };
70
71 template <template<class Type1, class Type2>class Binary, class Type1, class Type2>
72 struct type_to_string<Binary<Type1, Type2> >
73 {
74 static std::string apply()
75 {
76 return binary_template_to_string<Binary>::apply()+
77 "<"+type_to_string<Type1>::apply()+","+type_to_string<Type2>::apply()+">";
78 }
79 };
80
81 }} // namespace boost icl
82
83 #endif
84
85