Template specialization using traits?
Jonathan M Davis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 21 07:24:01 PST 2015
On Monday, December 21, 2015 19:54:53 Shriramana Sharma via Digitalmars-d-learn wrote:
> Thanks all for your replies. One question:
>
> Jonathan M Davis wrote:
> > Alternatively, you can use static if, though you're only dealing
> > with one template in that case. e.g.
>
> But if we wanted to deprecate one of the alternatives, then we necessary
> need to declare two templates with the same name and complementary
> constraints right?
Yes. Symbols get deprecated, not the internals of functions. So, you need
a separate function declaration to be able to deprecate one of them - though
tcak's example that separates the template from the function and uses a
static if within the template to declare two separate functions would allow
for the deprecation to be inside of the static if, since the static if is
outside of the function. Personally, I'd just use template constraints
though.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list