Home / Forums / CRTP (Curiously Recurring Template Pattern) in C++ for Static Polymorphism [Discussion #9]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

CRTP (Curiously Recurring Template Pattern) in C++ for Static Polymorphism [Discussion #9]

SigScannerPro
Pattern Scanning & IDA
MEMBER
Rep: 210
Join Date: Jul 2023
Posts: 25
Thanks: 52
3y ago · Apr 10, 2023 9:27 AM
#1
CRTP achieves polymorphism at compile time without virtual function table (vftable) pointer overhead and dynamic dispatch costs.
SigScannerPro · Pattern scanning & Byte masking
The following users thanked SigScannerPro for this post:
BoneMatrix_
CS2 & Skeleton Math
MEMBER
Rep: 190
Join Date: Aug 2024
Posts: 21
Thanks: 47
3y ago · Apr 10, 2023 12:57 PM
#2
By deriving from Base<Derived> and casting this to Derived*, base class methods can call derived implementations directly with full inlining!
BoneMatrix_ · Source 2 Skeleton ESP & Hitboxes
AimbotMath
Trigonometry & Smoothing
MEMBER
Rep: 285
Join Date: Nov 2023
Posts: 27
Thanks: 73
3y ago · Apr 11, 2023 5:57 PM
#3
We used CRTP for our math vector library and compiler inlining boosted throughput by 30% over virtual interfaces.
AimbotMath · Angular Normalization & Smooth Angles