Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
August 22, 2009 determining type a pointer points to. | ||||
---|---|---|---|---|
| ||||
Attachments: | Is there a function to do this? I Didn't find anything in traits or std.traits ty - -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk |
August 22, 2009 Re: determining type a pointer points to. | ||||
---|---|---|---|---|
| ||||
Posted in reply to div0 | On Sat, Aug 22, 2009 at 5:58 PM, div0<div0@users.sourceforge.net> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Is there a function to do this? > I Didn't find anything in traits or std.traits > > ty template PtrElemType(T : T*) { alias T PtrElemType; } template PtrElemType(T) { static assert(false, "YOU FAIL"); } |
August 22, 2009 Re: determining type a pointer points to. | ||||
---|---|---|---|---|
| ||||
Posted in reply to div0 | div0 wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Is there a function to do this?
> I Didn't find anything in traits or std.traits
<snip>
Not a function as such, but....
typeof(*p)
Stewart.
|
August 22, 2009 Re: determining type a pointer points to. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | On Sat, Aug 22, 2009 at 6:55 PM, Stewart Gordon<smjg_1998@yahoo.com> wrote:
> div0 wrote:
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Is there a function to do this?
>> I Didn't find anything in traits or std.traits
>
> <snip>
>
> Not a function as such, but....
>
> typeof(*p)
If p is int[], that gets you int instead of an error. I have no idea why.
|
August 23, 2009 Re: determining type a pointer points to. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley Attachments: | Jarrett Billingsley wrote: > On Sat, Aug 22, 2009 at 5:58 PM, div0<div0@users.sourceforge.net> wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Is there a function to do this? >> I Didn't find anything in traits or std.traits >> >> ty > > template PtrElemType(T : T*) { alias T PtrElemType; } > template PtrElemType(T) { static assert(false, "YOU FAIL"); } That's the one. ta. For some reason I was convinced it would be in phobos. doh. - -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk |
August 24, 2009 Re: determining type a pointer points to. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: > On Sat, Aug 22, 2009 at 6:55 PM, Stewart Gordon<smjg_1998@yahoo.com> wrote: <snip> >> typeof(*p) > > If p is int[], that gets you int instead of an error. I have no idea why. For everyone's benefit, the bug report is: http://d.puremagic.com/issues/show_bug.cgi?id=1381 Stewart. |
Copyright © 1999-2021 by the D Language Foundation