Alias this and std.traits.isArray
Philippe Sigaud
philippe.sigaud at gmail.com
Sun Jan 6 05:36:26 PST 2013
On Sun, Jan 6, 2013 at 1:36 PM, David <d at dav1d.de> wrote:
> Thanks for your answers, but:
>
> > Exactly. The std.traits traits are testing for exact types. If you want
> to
> > test for implicit conversion, then use the : operator. e.g.
> >
> > static assert(is(OhWhy!float : float[]));
>
> "OyWhy" is a templated struct for a reason, I have no idea which type of
> array is "alias this'ed" is there a way I can check if it's implicitly
> convertable to any array type with some `is` magic I am not aware of?
>
>
Like this?
struct MyType(Elem)
{
Elem[] inner;
alias inner this;
}
void main()
{
static assert(is(MyType!float _ : T[], T));
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130106/aeb7c249/attachment.html>
More information about the Digitalmars-d
mailing list