Functional composition in cpp