-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: enhance C++ sprintf utility #32385
Conversation
c58f428
to
1ee75ad
Compare
43287bc
to
658075e
Compare
ddba87b
to
f363ae5
Compare
template <unsigned BASE_BITS, typename T> | ||
std::string ToBaseString(T&& value, bool upper = false) { | ||
return ToStringHelper::BaseConvert<BASE_BITS>(std::forward<T>(value), upper); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think you need to do any templating for T
, any value that’s passed to a function like this will be convertible to unsigned long long
anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course ok, but we had code more template for other types if we do this.
btw, I inspired from this https://github.com/fmtlib/fmt/blob/5d32ccfc3130fdd122c344b37087ac7fd8c2b62e/include/fmt/format.h#L901-L913
f363ae5
to
24c4877
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, although it’s probably much simpler to go the %p
route and just let the system snprintf
do the work.
24c4877
to
bd84d89
Compare
Travis-ci fail because of timeout https://travis-ci.com/github/nodejs/node/jobs/300545913#L3154-L3159 |
@himself65 I restarted the Travis job. |
PR-URL: #32385 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Landed in dade90d. |
PR-URL: #32385 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: #32385 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
fix #32370
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes