On Tuesday, 17 August 2021 at 20:28:20 UTC, Alexandru Ermicioi
wrote:
On Tuesday, 17 August 2021 at 19:53:52 UTC, james.p.leblanc
wrote:
Wow! That is absolutely beautiful ... I had never seen (or
even
imagined) a recursive template! This expands my mind in a good
way ... and is going into my toolbox immediately.
Best Regards,
James
Just don't over rely on it. It can cause compilation slowdowns,
so avoid it if you can.
I've been happily trying to absorb all the helpful concepts
posted.
A final related question in the quest for simplicity and
robustness.
If I wanted to ensure that a function accepts only arguments of
byte, int, uint, long, etc. (i.e. integer-like types). Is the
accepted
way to do this like so?:
**auto foo( T : long )(T a, T b){ ... }**
I really wish I could find a good explanation of the ":" (colon)
used in templates. I am sure one exists ...but haven't come upon
it just yet.
(I thought "isIntegral" in traits module would be helpful...but
I failed in my experiments.)
Thanks for patience with this question!
Best Regards,
James