Higher order functions for ordinary C++ developers
summary
Advocates using use auto return type to return lambdas to build composable predicates (compose, select, address_matches) and shows fold-expression AND to combine many predicates; demonstrates TL::optional with TL::optional continuations (and_then / or_else) and an expected<T,E> idea for error info. Benchmarks show generated code has essentially no runtime overhead (one byte extra for optional state), warns std::function adds ABI overhead, and publishes a tiny header-only library on GitHub.
AI-written summary · about
chapters (35)
- 0:00Introduction
- 3:55Examples
- 12:25Compiler Explorer
- 20:30Expand
- 20:40IP address
- 22:44IP interface
- 23:38IP matress predicate
- 24:05IP matress composition
- 25:25IP interface composition
- 26:42Insanity
- 27:27Folds
- 29:50SelectState
- 30:27IfThen
- 30:53Action
- 31:15SetState
- 34:56OptionalT
- 37:36Lookup function
- 38:59Lookup use case
- 46:16Overloads
- 46:41Address
- 46:59Transform
- 47:30clang
- 48:33why bother
- 48:51arrange your code
- 49:20throw a lambda
- 49:56read a lambda
- 50:06to be solution
- 50:17macro lift
- 51:37compilation error
- 54:00function categories
- 54:56cons
- 56:08boost
- 57:15takeaway message
- 58:22composition names
- 58:36expected
related talks
57mAnd Then() Some(T) Functional Adventures With C++23 std::optional and std::expected
51mModern techniques for keeping your code dry
01h 47mFunctional C++
20mAnd Then() Some(T): C++ Combinators - Higher-Order Functions in Cpp
01h 03mFunctional C++ for Fun & Profit
01h 04mFunctional C++ For Fun And Profit
01h 31mFunctional Programming in Modern C++: The Imperatives Must Go!
04mGeneralized fold expressions
