Files
rippled/include/xrpl/basics/ToString.h
Bart 34ef577604 refactor: Replace include guards by '#pragma once' (#6322)
This change replaces all include guards in the `src/` and `include/` directories by `#pragma once`.
2026-02-04 09:50:21 -05:00

46 lines
711 B
C++

#pragma once
#include <string>
#include <type_traits>
namespace xrpl {
/** to_string() generalizes std::to_string to handle bools, chars, and strings.
It's also possible to provide implementation of to_string for a class
which needs a string implementation.
*/
template <class T>
typename std::enable_if<std::is_arithmetic<T>::value, std::string>::type
to_string(T t)
{
return std::to_string(t);
}
inline std::string
to_string(bool b)
{
return b ? "true" : "false";
}
inline std::string
to_string(char c)
{
return std::string(1, c);
}
inline std::string
to_string(std::string s)
{
return s;
}
inline std::string
to_string(char const* s)
{
return s;
}
} // namespace xrpl