Overloading: The Bane of All Higher-Order Functions
summary
Explains why passing overloaded functions or function templates into higher‑order code fails and shows concrete workarounds and proposals: function templates compile for direct calls but cannot be passed to std::transform, templated call‑operator objects require construction, lambdas need tedious perfect forwarding plus explicit decltype and noexcept plumbing, macros can hide that, global function objects hit ODR unless C++17 inline variables are used. Demonstrates lifting overload set hacks, std::overload_set proposal, operator and member projection lifting, and the remaining standardization costs and tradeoffs.
AI-written summary · about
chapters (9)
- 0:00Introduction to overloading
- 1:04Problem with function templates
- 5:04Function objects and limitations
- 8:21Macros and lambdas as workarounds
- 9:46Global function objects and ODR
- 11:57Lifting overload sets proposal
- 14:28std::overload_set proposal
- 17:38Summary and call to action
- 18:00Q&A with Michal
related talks
01h 05mDon’t Get Overloaded by C++ Overload Sets
55mHow to "OO" in C++
01h 35mC++20 – My Favourite Code Examples
12mTraits Go Mainstream...
47mReducing Template Compilation Overhead, Using C++11, 14, 17, and 20.
01h 03mHigher order functions for ordinary C++ developers
54mGeneric Programming Without (Writing Your Own) Templates
41mC++ Overload Inspector - A Tool for Analyzing and Profiling Overloaded Function Calls
