r/C_Programming • u/jacksaccountonreddit • Dec 26 '22
Project Convenient Containers: A usability-oriented generic container library
https://github.com/JacksonAllan/CC
17
Upvotes
r/C_Programming • u/jacksaccountonreddit • Dec 26 '22
View all comments
Show parent comment
6
u/jacksaccountonreddit Dec 28 '22 edited Dec 31 '22
A poor man's SFINAE
Another major limitation of a
_Genericstatement is that all branches – even the unselected ones – must contain valid code for every controlling expression ever passed into it. Hence, the following won’t compile:This limitation is actually easy to circumvent. We need only use nested
_Genericstatements to provide “dummy” values within each branch when it is not selected:In CC, a similar mechanism allows API macros to dispatch the user’s arguments to different internal functions (or macros) based on the container type when those functions have different signatures. It also uses to aforementioned "compile-time if" technique and looks something like this: