mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Replace std::to_string with locale-independent alternative
This commit is contained in:
parent
58c72880ff
commit
d056df033a
19 changed files with 71 additions and 58 deletions
|
|
@ -8,6 +8,8 @@
|
|||
#include <attributes.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <locale>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -52,4 +54,16 @@ NODISCARD inline bool ValidAsCString(const std::string& str) noexcept
|
|||
return str.size() == strlen(str.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale-independent version of std::to_string
|
||||
*/
|
||||
template <typename T>
|
||||
std::string ToString(const T& t)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale::classic());
|
||||
oss << t;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
#endif // BITCOIN_UTIL_STRENCODINGS_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue