multiple `alias this` suggestion
Carl Sturtivant via Digitalmars-d
digitalmars-d at puremagic.com
Wed Apr 26 11:34:48 PDT 2017
On Wednesday, 26 April 2017 at 15:00:30 UTC, Steven Schveighoffer
wrote:
> I think you can appreciate that this doesn't scale. Imagine a
> case which has 2 or 3 optional alias this items.
>
> -Steve
Agreed, not manually, as it is exponential in the number of
conditions. But I think some template machinery could mixin the
right stuff in one place avoiding that problem, implanting the
existing names in an `alias this`. So
AliasThis!(x,y,z)
which could detect if each name exists in an instantiation and
only use that name if so, and would be placed outside of any
`static if` to do the job.
I'm leaning toward the notion that a single AliasThis of the kind
I suggested with a suitable template library to help out with
matters such as the one you raised is enough.
(Some name management for shadowed names could be in that library
too --- different topic, will discuss elsewhere.)
More information about the Digitalmars-d
mailing list