A Static Alternative to Virtual Functions, Using Expression SFINAE
summary
A header-only, fully static replacement for virtual dispatch that uses Expression SFINAE and the void_t detection idiom to test whether the implementation type provides richer methods and to select either a direct call or a fallback implementation at compile time. The interface is a class template with a minimal basis API and optional extensions; implementations that supply optimized methods get inlined calls, the template instantiates only used paths, and there is no vtable overhead.
AI-written summary · about
chapters (9)
- 0:00Intro
- 0:15The familiar interface
- 0:30The idea
- 1:05The implementation
- 1:22Autocompletion engine
- 1:54Implementation options
- 2:34Expression pattern
- 2:55Upshot
- 3:42Conclusion
related talks
05mSFINAE: Substitution Failure Is Not An Error
55mCustom Overload Sets and Inline SFINAE for Truly Generic Interfaces
53mThe Detection Idiom - a simpler way to SFINAE
06mLightning Talk: How Hard Can it be to SFINAE in C++03?
57mIntroduction to C++ Template Metaprogramming
51mModern techniques for keeping your code dry
22mEffective replacement of dynamic polymorphism with std::variant
29mEffective replacement of dynamic polymorphism with std::variant
