13 #ifndef TINYMPL_TO_STRING_HPP
14 #define TINYMPL_TO_STRING_HPP
16 #include <tinympl/string.hpp>
24 template<
class T,T value,T base = 10,
class =
void>
struct to_string_impl
26 typedef typename to_string_impl<T,value / base,base>::type head;
27 typedef typename to_string_impl<T,value % base,base>::type tail;
28 typedef typename head::template append<tail>::type type;
32 template<
class T,T value,T base>
struct to_string_impl<T,value,base,
33 typename std::enable_if<(value < 0)>::type>
35 typedef typename to_string_impl<T,-value,base>::type tail;
36 typedef typename tail::template insert_c<0,
'-'>::type type;
40 template<
class T,T value,T base>
struct to_string_impl<T,value,base,
41 typename std::enable_if<(value >= 0 && value < base)>::type>
43 static_assert( value >= 0 && value < 16,"Base > 16 not supported
");
45 typedef basic_string<char,
48 'a' + value - 10)> type;
58 template<class T,T value> using to_string = detail::to_string_impl<T,value>;
60 template<class T,T value> using to_string_t = typename to_string<T,value>::type;
63 template<int value> using to_string_i = detail::to_string_impl<int,value>;
64 template<int value> using to_string_i_t = typename to_string_i<value>::type;
67 template<long value> using to_string_l = detail::to_string_impl<long,value>;
68 template<long value> using to_string_l_t = typename to_string_l<value>::type;
71 template<unsigned value> using to_string_u = detail::to_string_impl<unsigned,value>;
72 template<unsigned value> using to_string_u_t = typename to_string_u<value>::type;
75 template<long long value> using to_string_ll = detail::to_string_impl<long long,value>;
76 template<long long value> using to_string_ll_t = typename to_string_ll<value>::type;
82 #endif // TINYMPL_TO_STRING_HPP