Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Dec 8, 2020

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.

@sipa
Copy link
Member

sipa commented Dec 8, 2020

Concept ACK

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fa11110

If std::atomic is not involved, then

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

can be replaced with:

auto foo = 100ms;

@jonasschnelli
Copy link
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};)

@maflcko
Copy link
Member Author

maflcko commented Dec 9, 2020

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.

@fanquake
Copy link
Member

fanquake commented Dec 9, 2020

Concept ACK. I've put #20253 on top of this. Will make sure to remember ms vs us.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include <string>
#include <chrono>

using namespace std::chrono_literals;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivia, both this and using namespace std::literals::chrono_literals; appear to be valid

@maflcko maflcko merged commit 7212db4 into bitcoin:master Dec 9, 2020
@maflcko maflcko deleted the 2012-chronoLiterals branch December 9, 2020 16:18
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 9, 2020
fa11110 util: Allow use of C++14 chrono literals (MarcoFalke)

Pull request description:

  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.

ACKs for top commit:
  vasild:
    ACK fa11110
  jonatack:
    ACK fa11110

Tree-SHA512: ee2b72c8f28dee07b33b9a8ee8f7c87c0bc43b05c56a17b786cf9803ef204c7628e01b02de1af1a4eb01f5cdf6fc336f69c2833e17acd606ebda20ac6917e6bb
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 26, 2022
Summary:
```
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.
```

Backport of [[bitcoin/bitcoin#20602 | core#20602]].

Ref T1696.

Test Plan:
  ninja all check-all
Build for Windows.

Reviewers: #bitcoin_abc, tyler-smith

Reviewed By: #bitcoin_abc, tyler-smith

Subscribers: tyler-smith

Maniphest Tasks: T1696

Differential Revision: https://reviews.bitcoinabc.org/D10901
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants