|
std::string | tostr (int val) |
| Converts an integer to a std::string.
|
|
std::string | tostr (unsigned int val) |
| Converts an unsigned integer to a std::string.
|
|
std::string | tostr (long val) |
| Converts a long integer to a std::string.
|
|
std::string | tostrhex (unsigned long val) |
| Converts an unsigned long integer to a hexadecimal std::string.
|
|
std::string | tostr (void *val) |
| Converts a pointer to a hexadecimal std::string.
|
|
std::string | tostr (unsigned long val) |
| Converts an unsigned long integer to a std::string.
|
|
std::string | tostr (long long val) |
| Converts a long long integer to a std::string.
|
|
std::string | tostr (unsigned long long val) |
| Converts an unsigned long long integer to a std::string.
|
|
std::string | tostr (float val) |
| Converts a float to a std::string.
|
|
std::string | tostr (double val) |
| Converts a double to a std::string.
|
|
std::string | tostr (long double val) |
| Converts a long double to a std::string.
|
|
std::string | tostr (const char *sz) |
| Converts a C-style string to a std::string.
|
|
std::string | tostr (std::string str_) |
| Returns the given std::string.
|
|
Utility functions for converting various data types to std::string.
This header file provides a set of inline functions to convert different data types to their string representations using std::to_string and custom formatting. The provided functions handle conversions for integral types, floating-point types, pointers, and C-style strings.
Example usage:
int num = 42;
std::string str = tostr(num);
float fnum = 3.14f;
std::string fstr = tostr(fnum);
void* ptr = static_cast<void*>(&num);
std::string ptrstr = tostr(ptr);
const char*
cstr =
"hello";
std::string str = tostr(
cstr);