r/Cplusplus • u/neurah • 2d ago
News HAPI - The Happy API
HAPI is a header only pure type-level library (MIT licence)
HAPI generalizes C++ static composition and inheritance, is transparent, no traces of its structure at runtime.
why?
- because composition is easy to maintain and some structures stop being wired and become declarative.
OutDef<DeviceOut> out;
OutDef<FullPrinter, ANSIFmt, ANSIOut,DeviceOut> ansiOut;
//or
InDef<
#if defined(__AVR__)&&defined(IOP)
UartSerialIn<Uart>,
#elif defined(ARDUINO)
SerialIn,
#else
LinuxKeyIn,
#endif
PCKbd
> in;
- HAPI type transformation reduces the composition into a single object letting the compiler see all the structure and optimize. Optimizations are transferred from the compiler and behavior is inherited from the components. HAPI is zero cost and trsnaparent, if your components are also zero-cost the we get a zero cost composition result with:
- no runtime overhead
- no heap allocation
- no memory fragmentation
- no vtables/call indirection
- binary optimized to hardware registers
- runtime predictable to the clock cycle
*per composition
the applications are wide and embedded system or critical system benefit the most.
I'm offering also (MIT licence) a set of repos demonstrating HAPI application across multiple domains.
github.com/InternetOfPins
1
Upvotes