From 11c5695f29d68fd881eb042075facad1f01bac9a Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 9 Jan 2007 02:05:01 +0000 Subject: This is better, and proved working git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6275 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/inspircd.h | 21 +++++++++++---------- 1 file 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 inline void DELETE(T* x) /** Template functions to convert any input type to std::string */ -template std::string ConvNumeric(N in) +template 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 inline std::string ConvToStr(const int in) +inline std::string ConvToStr(const int in) { return ConvNumeric(in); } -template inline std::string ConvToStr(const long in) +inline std::string ConvToStr(const long in) { return ConvNumeric(in); } -template inline std::string ConvToStr(const unsigned long in) +inline std::string ConvToStr(const unsigned long in) { return ConvNumeric(in); } -template inline std::string ConvToStr(const char* in) +inline std::string ConvToStr(const char* in) { return in; } -template inline std::string ConvToStr(const long in) +inline std::string ConvToStr(const bool in) { return (in ? "1" : "0"); } -template inline std::string ConvToStr(const T &in) +template inline std::string ConvToStr(const T &in) { std::stringstream tmp; if (!(tmp << in)) return std::string(); -- cgit v1.2.3