This is part 4 in the series of Fun with Lambdas: C++14 Style . The previous posts are part 3 , part 2 , and part 1 . C++14 has a number of features that support functional-style design. By "functional-style" I mean heavy use of higher-order functions (functions that take other functions as arguments). Quite often arguments to the higher-order functions are lambdas (closures, to be precise). With automatic return type deduction for normal functions, writing higher-order function becomes very easy and seamless in C++14. This time, I have chosen a "text-book" example to show you the power of C++14: Composable Data Generators What is a Generator? A Generator<T> produces values of type T randomly. There is already a random number generator defined in the C library: random() . It produces long ints. We can use this basic generator to create higher-level generators, such as bool, character, floating point numbers, etc. Even random sequence and structure g
A blog on various topics in C++ programming including language features, standards, idioms, design patterns, functional, and OO programming.