3 ms·
Interestingly, top level cost does not guarantee immutability, but any const member reachable from that reference is in fact guaranteed to be immutable: ergo:
by gpderetta 7y ago
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