dr_strangetemplate
dr_strangetemplate copied to clipboard
First example no good?
The internet at large has suggested that the first example doesn't really improve using a C API. While I don't think those criticisms are without merit, I've decided to keep it up for now because it serves my main goal of introducing concepts like SFINAE.
As for whether it is actually a detriment to wrap a C-style API in the way I've suggested, in my opinion it's neither clearly a detriment nor a great improvement. The argument seems to be that it makes the code needlessly more complex. I consider that a matter of opinion.
But please feel free to comment here if you feel strongly about it!
This is a fantastic guide. Thank you for taking the time to write it.
Could you elaborate on why you go from
void api_exec(int func(Args...), Args... args) { ... }
to
void api_exec(Function func, Args... args) { ... )
It seems the make the function overly generic in a way that causes you next problem with
api_exec(epsilon)
That you then need to fix with extra tricks. If you were to keep the original, more constrained,version, wouldn't it then check the return type in a more intuitive fashion?
I think you are right, it is overly generic for my given example. I guess what I was thinking originally is that I find function types like int func(Args...)
hard to parse, whereas a type like Function
telegraphs intent to me much better.