Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Have you read the post in question? Its a good introduction to C++ Concurrency / memory models.

Yes, I have. And yes, I am familiar with the C++ concurrency/memory models discussed here. And, to be clear, nothing in the article is doing anything that couldn't be done just as clearly with std::atomic<bool>& as with std::atomic<bool>*. Obviously, if you actually want to be able to assign to the pointer, then you need the pointer form.

> Indeed, one can argue that when using atomics, the more explicit "store" and "load" functions should be used instead.

Yes, this is the style I strongly prefer. Of course, here it doesn't matter between

  a = blah->load();
  blah->store(b);
or

  a = blah.load();
  blah.store(b);
and choosing to use the pointer form is often just introducing nullability where you don't need it.


> choosing to use the pointer form is often just introducing nullability where you don't need it.

_Nonnull int* whatever;

Tada! Nullability avoided. https://releases.llvm.org/3.8.0/tools/clang/docs/AttributeRe...




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: