tinyformat: force USE_VARIADIC_TEMPLATES#8000
Conversation
Now that we started using c++11, force use of variadic templates. The autodetection may be wonky on some compilers, see discussion [here](bitcoin#7982 (comment)) and is unnecessary for us anyhow.
|
ut ACK |
|
Looks like there is another tinyformat-related c++1 TODO here: https://github.com/bitcoin/bitcoin/blob/master/src/util.h#L83 |
|
utACK 9eaa0af |
|
utACK 9eaa0af |
|
utACK 9eaa0af |
|
Added a second commit that makes LogPrint and error into variadic templates. |
|
may as well use perfect forwarding here, since all args are universal references: template<typename T1, typename... Args>
bool error(const char* fmt, T1&& v1, Args&&... args)
{
LogPrintStr("ERROR: " + tfm::format(fmt, std::forward<T1>(v1), std::forward<Args>(args)...) + "\n");
... |
|
@cfields I use the same convention as the functions in tinyformat.h itself now: I'm not sure perfect forwarding would win anything unless it's done at all levels. |
|
blah, I assumed if it used variadics it also forwarded nicely. Indeed, no point in changing. ut ACK 08d7b56 |
Well I agree with changing it, but yea should probably do that at once throughout the entire thing, in a separate pull. |
Updates `tinyformat.h` to commit c42f/tinyformat@3a33bbf upstream. Makes sure that our local changes are kept: - bitcoin#3767 1b8fd35 Make tinyformat errors raise an exception instead of assert()ing - bitcoin#4735 9b6d4c5 Move strprintf define to tinyformat.h - bitcoin#4748 6e5fd00 include stdexcept (for std::exception) - bitcoin#8000 9eaa0af force USE_VARIADIC_TEMPLATES - Add `std::string format(const std::string &fmt...` added this at the time, as we want to be able to do `strprintf(_(...), ...)` Inspired by bitcoin#8264.
util: Update tinyformat Updates `tinyformat.h` to commit c42f/tinyformat@3a33bbf upstream. Makes sure that our local changes are kept: - bitcoin/bitcoin#3767 1b8fd35 Make tinyformat errors raise an exception instead of assert()ing - bitcoin/bitcoin#4735 9b6d4c5 Move strprintf define to tinyformat.h - bitcoin/bitcoin#4748 6e5fd00 include stdexcept (for std::exception) - bitcoin/bitcoin#8000 9eaa0af force USE_VARIADIC_TEMPLATES - Add `std::string format(const std::string &fmt...` added this at the time, as we want to be able to do `strprintf(_(...), ...)` Inspired by bitcoin/bitcoin#8264. For Zcash: ref #1349
Updates `tinyformat.h` to commit c42f/tinyformat@3a33bbf upstream. Makes sure that our local changes are kept: - bitcoin#3767 1b8fd35 Make tinyformat errors raise an exception instead of assert()ing - bitcoin#4735 9b6d4c5 Move strprintf define to tinyformat.h - bitcoin#4748 6e5fd00 include stdexcept (for std::exception) - bitcoin#8000 9eaa0af force USE_VARIADIC_TEMPLATES - Add `std::string format(const std::string &fmt...` added this at the time, as we want to be able to do `strprintf(_(...), ...)` Inspired by bitcoin#8264.
Updates `tinyformat.h` to commit c42f/tinyformat@3a33bbf upstream. Makes sure that our local changes are kept: - bitcoin#3767 1b8fd35 Make tinyformat errors raise an exception instead of assert()ing - bitcoin#4735 9b6d4c5 Move strprintf define to tinyformat.h - bitcoin#4748 6e5fd00 include stdexcept (for std::exception) - bitcoin#8000 9eaa0af force USE_VARIADIC_TEMPLATES - Add `std::string format(const std::string &fmt...` added this at the time, as we want to be able to do `strprintf(_(...), ...)` Inspired by bitcoin#8264.
9fb0a43 util: Throw tinyformat::format_error on formatting error (random-zebra) 67eb699 util: Properly handle errors during log message formatting (random-zebra) 66ec97b Do not evaluate hidden LogPrint arguments (random-zebra) 2713458 util: Remove zero-argument versions of LogPrint and error (random-zebra) 500dfee util: Update tinyformat (random-zebra) 6837887 util: switch LogPrint and error to variadic templates (random-zebra) 0fa578f tinyformat: force USE_VARIADIC_TEMPLATES (random-zebra) Pull request description: this backports the following pull requests from upstream bitcoin: - bitcoin#8000 (0fa578f, 6837887) > Now that we started using c++11, force use of variadic templates. The autodetection may be wonky on some compilers, see discussion here and is unnecessary for us anyhow. - bitcoin#8274 (500dfee, 2713458) > Updates tinyformat.h to commit c42f/tinyformat@3a33bbf upstream. - bitcoin#9417 (66ec97b) > There are a few cases where hashes are computed inside LogPrint arguments - where they usually go unused. As LogPrint statements should never have side effects besides printing something, we can avoid the evaluation in this case. Advantage: perhaps a small performance improvement; I haven't benchmarked. Disadvantage: if we would have statements with side-effects, this could make this a bit harder to debug. - bitcoin#9963 (67eb699, 9fb0a43) > Instead of having an exception propagate into the program (which at worst causes a crash) when an error happens while formatting a log message, just print a message to the log. This message clearly indicates what log message was formatted wrongly, and what error happened during formatting it. ACKs for top commit: Fuzzbawls: ACK 9fb0a43 furszy: cool, utACK 9fb0a43 . Tree-SHA512: 29a902bb712612ca093a8fe863e9eff1c17d40955bbc37a5ceb6f057068ac6150dfcffd6836a6b0bd6295aa9bffd0925eb69e50f82ccaa7d84215efc274a59a4
9fb0a43 util: Throw tinyformat::format_error on formatting error (random-zebra) 67eb699 util: Properly handle errors during log message formatting (random-zebra) 66ec97b Do not evaluate hidden LogPrint arguments (random-zebra) 2713458 util: Remove zero-argument versions of LogPrint and error (random-zebra) 500dfee util: Update tinyformat (random-zebra) 6837887 util: switch LogPrint and error to variadic templates (random-zebra) 0fa578f tinyformat: force USE_VARIADIC_TEMPLATES (random-zebra) Pull request description: this backports the following pull requests from upstream bitcoin: - bitcoin#8000 (0fa578f, 6837887) > Now that we started using c++11, force use of variadic templates. The autodetection may be wonky on some compilers, see discussion here and is unnecessary for us anyhow. - bitcoin#8274 (500dfee, 2713458) > Updates tinyformat.h to commit c42f/tinyformat@3a33bbf upstream. - bitcoin#9417 (66ec97b) > There are a few cases where hashes are computed inside LogPrint arguments - where they usually go unused. As LogPrint statements should never have side effects besides printing something, we can avoid the evaluation in this case. Advantage: perhaps a small performance improvement; I haven't benchmarked. Disadvantage: if we would have statements with side-effects, this could make this a bit harder to debug. - bitcoin#9963 (67eb699, 9fb0a43) > Instead of having an exception propagate into the program (which at worst causes a crash) when an error happens while formatting a log message, just print a message to the log. This message clearly indicates what log message was formatted wrongly, and what error happened during formatting it. ACKs for top commit: Fuzzbawls: ACK 9fb0a43 furszy: cool, utACK 9fb0a43 . Tree-SHA512: 29a902bb712612ca093a8fe863e9eff1c17d40955bbc37a5ceb6f057068ac6150dfcffd6836a6b0bd6295aa9bffd0925eb69e50f82ccaa7d84215efc274a59a4
Rebase tinyformat.
Now that we started using c++11, force use of variadic templates.
The autodetection may be wonky on some compilers, see discussion here and is unnecessary for us anyhow.