jeudi 17 août 2017

Why aren't std::chrono::duration instances passed by value in the Standard Library?

According to cppreference.com:

The only data stored in a duration is a tick count of type Rep.

However, I've noticed that for example:

thread::sleep_for takes sleep_duration by const ref.

future::wait_for likewise takes duration by const ref.

etc.

(1) Any particular reason why they are not passed by value instead?

(1a) Does passing by const reference pessimize some possible constexpr optimizations?

Aucun commentaire:

Enregistrer un commentaire