News for hackers. Stuff that matters.
Re:Why Const Doesn't Make C Code Faster by gpderetta on Tuesday August 20, 2019 @06:46AM (#20745436)
Interestingly, top level cost does not guarantee immutability, but any const member reachable from that reference is in fact guaranteed to be immutable: ergo:

  template<class T>
  struct deep_const { const T value; };

  template<class T>
  const deep_const& freeze(const T&) { /* magic */ }

  template<cass T>
  const T & thaw(deep_const<T> const&) { /* more magic */ }
magic and more magic left as an exercise for the reader.

edit: I do not think either GCC or clang take advantage of that though, so currently it is just a curiosity.

edit: missed actual const keywords /facepalm

There are no comments on this comment yet.