News for hackers. Stuff that matters.
Re:Don’t blindly prefer emplace_back to push_back by umvi on Thursday March 04, 2021 @01:23PM (#26346091)
> C++ is really brutal for people who would rather learn by example than by carefully reading documentation

As if the documentation/compiler implementations are otherwise perfect. Quick, does `std::condition_variable::wait_for` use a monotonic clock under the hood?

Here's the docs: https://en.cppreference.com/w/cpp/thread/condition_variable/...

You might think so based on the part that says:

> Note that rel_time must be small enough not to overflow when added to std::chrono::steady_clock::now()."

But I happen to know from actually using it, that not all implementations use a monotonic clock: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41861

This led to a rather dramatic time bomb bug in our code that only flared up when GPS (and therefore system time) was being spoofed to replay a specific scenario in the past.

Re:Don’t blindly prefer emplace_back to push_back by bombela on Thursday March 04, 2021 @05:37PM (#26349472)
wouldn't that be an implementation bug? Because waiting for a specific amount of time is not the same as waiting for a specific wall clock time to come.
Re:Don’t blindly prefer emplace_back to push_back by umvi on Thursday March 04, 2021 @05:51PM (#26349635)
Yes, it is an implementation bug. My point being that C++ can be brutal even for people who carefully read the docs.