File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,17 @@ struct ToStringHelper {
3030 template <unsigned BASE_BITS,
3131 typename T,
3232 typename std::enable_if<std::is_integral<T>::value, int >::type = 0 >
33- static std::string BaseConvert (T value) {
33+ static std::string BaseConvert (const T& value) {
34+ auto v = static_cast <uint64_t >(value);
3435 char ret[3 * sizeof (T)];
3536 char * ptr = ret + 3 * sizeof (T) - 1 ;
3637 *ptr = ' \0 ' ;
3738 const char * digits = " 0123456789abcdef" ;
3839 do {
39- unsigned digit = value & ((1 << BASE_BITS) - 1 );
40+ unsigned digit = v & ((1 << BASE_BITS) - 1 );
4041 *--ptr =
4142 (BASE_BITS < 4 ? static_cast <char >(' 0' + digit) : digits[digit]);
42- } while ((value >>= BASE_BITS) != 0 );
43+ } while ((v >>= BASE_BITS) != 0 );
4344 return ptr;
4445 }
4546 template <unsigned BASE_BITS,
@@ -56,8 +57,8 @@ std::string ToString(const T& value) {
5657}
5758
5859template <unsigned BASE_BITS, typename T>
59- std::string ToBaseString (T& & value) {
60- return ToStringHelper::BaseConvert<BASE_BITS>(std::forward<T>( value) );
60+ std::string ToBaseString (const T & value) {
61+ return ToStringHelper::BaseConvert<BASE_BITS>(value);
6162}
6263
6364inline std::string SPrintFImpl (const char * format) {
You can’t perform that action at this time.
0 commit comments