mutable const

2004-09-17T02:16:00Z

At work we wanted to make a referenced counted object that didn’t do any heap allocations. We made a doubly linked list implementation. We got to write a declaration that looks something like this.

class Node {
   //…
   mutable const Node * next;
   mutable const Node * prev;
}

You gotta love const-correctness.

Tags

,

Russell O’Connor: contact me