util: Allow use of C++14 chrono literals #20602

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2012-chronoLiterals changing 4 files +7 −5
  1. MarcoFalke commented at 3:50 pm on December 8, 2020: member

    I think we should allow the use of chrono literals for new code to make it less verbose. Obviously old code can stay as-is.

    This patch pulls in the needed namespace and replaces some lines for illustrative purposes.

  2. util: Allow use of C++14 chrono literals fa11110bff
  3. MarcoFalke added the label Refactoring on Dec 8, 2020
  4. MarcoFalke added the label Utils/log/libs on Dec 8, 2020
  5. sipa commented at 4:51 pm on December 8, 2020: member
    Concept ACK
  6. vasild approved
  7. vasild commented at 5:22 am on December 9, 2020: member

    ACK fa11110bff6288f63e0c487e2e4b4079fb0f4569

    If std::atomic is not involved, then

    0std::chrono:milliseconds foo = std::chrono::milliseconds{100};
    

    can be replaced with:

    0auto foo = 100ms;
    
  8. jonasschnelli commented at 8:02 am on December 9, 2020: contributor
    Concept ACK. Would it also be possible to change the net_processing.cpp constexpr? (like static constexpr auto TXID_RELAY_DELAY = std::chrono::seconds{2};)
  9. MarcoFalke commented at 8:04 am on December 9, 2020: member

    can be replaced with:

    Would it also be possible to change the net_processing.cpp constexpr?

    Yes, it is possible to change existing code, but as this is a purely stylistic change, it might be better to do it when the code is touched for other reasons.

    The only goal of this pull is to pull in the namespace and show that it was pulled in by replacing a few lines.

  10. fanquake commented at 1:11 pm on December 9, 2020: member
    Concept ACK. I’ve put #20253 on top of this. Will make sure to remember ms vs us.
  11. in src/util/time.h:13 in fa11110bff
     5@@ -6,9 +6,11 @@
     6 #ifndef BITCOIN_UTIL_TIME_H
     7 #define BITCOIN_UTIL_TIME_H
     8 
     9+#include <chrono>
    10 #include <stdint.h>
    11 #include <string>
    12-#include <chrono>
    13+
    14+using namespace std::chrono_literals;
    


    jonatack commented at 4:07 pm on December 9, 2020:
    trivia, both this and using namespace std::literals::chrono_literals; appear to be valid
  12. jonatack commented at 4:09 pm on December 9, 2020: member
  13. MarcoFalke merged this on Dec 9, 2020
  14. MarcoFalke closed this on Dec 9, 2020

  15. MarcoFalke deleted the branch on Dec 9, 2020
  16. sidhujag referenced this in commit a605dc06fc on Dec 9, 2020
  17. Fabcien referenced this in commit 14edfe57f1 on Jan 26, 2022
  18. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 03:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me