2 ms·
Indeed, and there's `std::function` (albeit not being a zero-cost abstraction; I believe `std::move_only_function` and `std::copyable_function` in C++23 and C++
by delta_p_delta_x 2y ago
Indeed, and there's `std::function` (albeit not being a zero-cost abstraction; I believe `std::move_only_function` and `std::copyable_function` in C++23 and C++26 respectively are replacements) and lambda statements. But C++ decided the bracket salad `[](){}` was the best way to write lambdas, and I'll never forgive the standard for it.
- kccqzy 2y agoAny sort of type erasure on functions will have a non-zero cost. That's why the only zero-cost abstraction is having a template parameter (such as remove_if), but these come with a code size cost instead.