Concepts like c++20 with specialized overload resolution.
Dom DiSc
dominikus at scherkl.de
Sun May 28 11:57:26 UTC 2023
On Saturday, 27 May 2023 at 19:16:18 UTC, vushu wrote:
> It depends. This example is quite small and a `static if` is
> sufficient, if you have a lot of cases it would make sense to
> split thing up into overloaded functions.
Even with a lot of cases you can simply call in each static if a
(private) subfunction. I would always prefer this over overloads
because it gets you a much cleaner API (I consider the constraint
to be part of the function signature, which therefore can get
very long and produces a lot of overloads that each only differ
in the constraints). Also it becomes more and more obfuscated for
which cases there is an overload and for which not.
A good (?!?) example of how bad this can get is the "to" template.
More information about the Digitalmars-d-learn
mailing list