By Phil Nash
C++11 gave us lambdas in the language for the first time (if you ignore boost::lambda) - so it’s a functional language now, right? There’s a bit more to functional programming than having first class function objects. I’d even argue we still don’t quite have that. But does that mean we can’t do functional programming in C++? Yes. No. Maybe…
First we have to define what functional programming actually is - and it may not be quite what you think. Then we need to see what valuable ideas have come out of the functional approach to software design and which ones we can use in C++ to good effect.
In the end we’ll see that, while not strictly a functional programming language, we can get quite a long way with immutable data types, persistent data structures, atomic references, and - if you’re not watching carefully - we might even throw the M word in there!