00001 #ifndef NMWR_GB_AS_STRING_H 00002 #define NMWR_GB_AS_STRING_H 00003 00004 00005 00006 // $LICENSE 00007 00008 00009 00010 #include <strstream.h> 00011 #include <string> 00012 00013 template<class T> 00014 inline std::string as_string(const T& t) 00015 { 00016 std::strstream s; 00017 s << t << std::ends; 00018 int n = strlen(s.str()); 00019 char* copy = new char[n+1]; 00020 strcpy(copy,s.str()); 00021 00022 return std::string(copy); 00023 } 00024 00025 #endif