Immutable Data Structures in C++

By Alistair Fisher

Immutability remains one of the great dividing lines between procedural languages like C and C++, and functional languages like Haskell and Clojure. While many other traditionally functional features — such as higher order functions, lambda expressions, and lazy evaluation — have made their way into C++ over the past decade, mutability remains at the core of the language.

This talk aims to offer a fresh perspective. Immutable data structures offer a solution to a challenge many developers face every day — safety in a multithreaded environment. Unlike other data containers, they are thread safe by design and allow processes to be optimised through the sharing of data, with no risk to one another. They also make it easier to reason about and debug code, as the state of the program and its environment at each stage is persisted.

After discussing the unique value that these data structures can bring, we will turn to the traditional drawback of immutable data — performance. We will examine some of the modern data structures developed for other programming languages, such as Clojure’s persistent vectors, and learn how these challenges can be overcome, sometimes to the point where what once was a weakness becomes a strength.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.