Take the 2-minute tour ×  I'm wondering how to implement
immutable data structures in C++ (or C). I'm searching for a
book or paper (or a relatively simple and documented
implementation) on the subject and I haven't managed to find one
for now so I decided to ask for hints. Thanks in advance for
your answers.  share|improve this question Maybe you're looking
for Persistent data structures
(en.wikipedia.org/wiki/Persistent_data_structure)? If so, you
can take a look at immutable collections in .net for some other
hints as well (blogs.msdn.com/b/bclteam/archive/2012/12/18/…) – 
Sergey Teplyakov May 12 '13 at 19:43  8 Answers 8  I think you
may take an idea from another languages. For example in Java and
C# immutability implemented following way. Instead of creating
"mutators" (functions that "mutate" objects' state), we create
functions that return new "changed" instance:  class Foo
Foo(int i)    : i_(i)     int GetI() const {return i_;}    Foo
SetI(int i) const {return Foo(i);}    const int i_;
share|improve