summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-09 02:05:01 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-09 02:05:01 +0000
commit11c5695f29d68fd881eb042075facad1f01bac9a (patch)
tree95ca54bb9dbc64ceafeba420737adc8e226b570c
parent525b7e3409884946cde5ddd6b0e8180e668032a3 (diff)
This is better, and proved working
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6275 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/inspircd.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 5e9bed45d..678ebf0a5 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -64,48 +64,49 @@ template<typename T> inline void DELETE(T* x)
/** Template functions to convert any input type to std::string
*/
-template<typename N> std::string ConvNumeric(N in)
+template<typename T> inline std::string ConvNumeric(const T &in)
{
char res[MAXBUF];
char* out = res;
- long quotient = in;
+ T quotient = in;
while (quotient) {
- *out = "0123456789"[ std::abs( quotient % 10 ) ];
+ *out = "0123456789"[ std::abs( (long)quotient % 10 ) ];
++out;
quotient /= 10;
}
if ( in < 0)
*out++ = '-';
*out = 0;
- return std::reverse(res,out);
+ std::reverse(res,out);
+ return res;
}
-template <int> inline std::string ConvToStr(const int in)
+inline std::string ConvToStr(const int in)
{
return ConvNumeric(in);
}
-template <long> inline std::string ConvToStr(const long in)
+inline std::string ConvToStr(const long in)
{
return ConvNumeric(in);
}
-template <unsigned long> inline std::string ConvToStr(const unsigned long in)
+inline std::string ConvToStr(const unsigned long in)
{
return ConvNumeric(in);
}
-template <const char*> inline std::string ConvToStr(const char* in)
+inline std::string ConvToStr(const char* in)
{
return in;
}
-template <bool> inline std::string ConvToStr(const long in)
+inline std::string ConvToStr(const bool in)
{
return (in ? "1" : "0");
}
-template <typename T> inline std::string ConvToStr(const T &in)
+template <class T> inline std::string ConvToStr(const T &in)
{
std::stringstream tmp;
if (!(tmp << in)) return std::string();