File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,17 @@ struct ToStringHelper {
30
30
template <unsigned BASE_BITS,
31
31
typename T,
32
32
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);
34
35
char ret[3 * sizeof (T)];
35
36
char * ptr = ret + 3 * sizeof (T) - 1 ;
36
37
*ptr = ' \0 ' ;
37
38
const char * digits = " 0123456789abcdef" ;
38
39
do {
39
- unsigned digit = value & ((1 << BASE_BITS) - 1 );
40
+ unsigned digit = v & ((1 << BASE_BITS) - 1 );
40
41
*--ptr =
41
42
(BASE_BITS < 4 ? static_cast <char >(' 0' + digit) : digits[digit]);
42
- } while ((value >>= BASE_BITS) != 0 );
43
+ } while ((v >>= BASE_BITS) != 0 );
43
44
return ptr;
44
45
}
45
46
template <unsigned BASE_BITS,
@@ -56,8 +57,8 @@ std::string ToString(const T& value) {
56
57
}
57
58
58
59
template <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);
61
62
}
62
63
63
64
inline std::string SPrintFImpl (const char * format) {
You can’t perform that action at this time.
0 commit comments