← Back to context

Comment by pkolaczk

7 years ago

A const reference to a mutable object doesn't guarantee that the object won't change contrary to an immutable object. Hence const is weaker than immutable.

You can have immutable objects in C++, but C++ offers almost nothing to make dealing with such objects fast and easy. Also the lack of GC makes designing persistent data structures an order of magnitude harder task than in most other languages.

That's only if you do not use a library and/or have no idea how shared_ptr is implemented.

  • The standard library doesn't come with persistent collections included. Just the fact that they are not standard like in some other languages, causes fragmentation.

    As for shared_ptr, they are a good idea when you don't care about performance. And they don't solve cycles, which may appear in some structures (e.g. graphs).