digitalmars.D.learn - Is there Typeof template ?
- Temtaime (6/6) Oct 28 2016 Hi !
- Adam D. Ruppe (2/3) Oct 28 2016 Why would you want that?
- Temtaime (3/6) Oct 28 2016 I have UDAs with values à la @(`str`, 123) uint k;
- =?UTF-8?Q?Ali_=c3=87ehreli?= (14/21) Oct 28 2016 How are you using those? typeof works with any value:
- Jonathan M Davis via Digitalmars-d-learn (6/28) Oct 28 2016 I don't know if Typeof is actually needed for what the OP is trying to d...
- =?UTF-8?Q?Ali_=c3=87ehreli?= (13/22) Oct 28 2016 std.meta.staticMap,
- Temtaime (2/25) Oct 28 2016 I wanna use it with staticMap.
- Jonathan M Davis via Digitalmars-d-learn (3/9) Oct 28 2016 If it were in Phobos, I'd expect it to be in std.meta, and it's not ther...
Hi ! Tried to find alias Typeof(alias A) = typeof(A); or something, but failed. Are there something or should I create a PR to phobos? Thanks
Oct 28 2016
On Friday, 28 October 2016 at 10:52:05 UTC, Temtaime wrote:Are there something or should I create a PR to phobos?Why would you want that?
Oct 28 2016
On Friday, 28 October 2016 at 12:44:20 UTC, Adam D. Ruppe wrote:On Friday, 28 October 2016 at 10:52:05 UTC, Temtaime wrote:I have UDAs with values à la (`str`, 123) uint k; And i want to know a type of a value.Are there something or should I create a PR to phobos?Why would you want that?
Oct 28 2016
On 10/28/2016 05:48 AM, Temtaime wrote:On Friday, 28 October 2016 at 12:44:20 UTC, Adam D. Ruppe wrote:How are you using those? typeof works with any value: void main() { (`str`, 123) uint k; foreach (a; __traits(getAttributes, k)) { pragma(msg, typeof(a)); } } Prints string int You can use indexes with the loop as well: foreach (i, a; /* ... */ AliOn Friday, 28 October 2016 at 10:52:05 UTC, Temtaime wrote:I have UDAs with values à la (`str`, 123) uint k; And i want to know a type of a value.Are there something or should I create a PR to phobos?Why would you want that?
Oct 28 2016
On Friday, October 28, 2016 11:19:46 Ali Çehreli via Digitalmars-d-learn wrote:On 10/28/2016 05:48 AM, Temtaime wrote:I don't know if Typeof is actually needed for what the OP is trying to do, but if you wanted to apply typeof using something like std.meta.staticMap, then you'd need something like Typeof. - Jonathan M DavisOn Friday, 28 October 2016 at 12:44:20 UTC, Adam D. Ruppe wrote:How are you using those? typeof works with any value: void main() { (`str`, 123) uint k; foreach (a; __traits(getAttributes, k)) { pragma(msg, typeof(a)); } } Prints string int You can use indexes with the loop as well: foreach (i, a; /* ... */On Friday, 28 October 2016 at 10:52:05 UTC, Temtaime wrote:I have UDAs with values à la (`str`, 123) uint k; And i want to know a type of a value.Are there something or should I create a PR to phobos?Why would you want that?
Oct 28 2016
On 10/28/2016 11:25 AM, Jonathan M Davis via Digitalmars-d-learn wrote:void main() { (`str`, 123) uint k; foreach (a; __traits(getAttributes, k)) { pragma(msg, typeof(a)); } }I don't know if Typeof is actually needed for what the OP is tryingto do,but if you wanted to apply typeof using something likestd.meta.staticMap,then you'd need something like Typeof.I see. Just to add something that I've just remembered, it is possible to apply typeof to __traits(getAttributes) as well: foreach (T; typeof(__traits(getAttributes, k))) { pragma(msg, T); } Now we get a list of types: string int Ali
Oct 28 2016
On Friday, 28 October 2016 at 18:39:36 UTC, Ali Çehreli wrote:On 10/28/2016 11:25 AM, Jonathan M Davis via Digitalmars-d-learn wrote:I wanna use it with staticMap.void main() { (`str`, 123) uint k; foreach (a; __traits(getAttributes, k)) { pragma(msg, typeof(a)); } }I don't know if Typeof is actually needed for what the OP istrying to do,but if you wanted to apply typeof using something likestd.meta.staticMap,then you'd need something like Typeof.I see. Just to add something that I've just remembered, it is possible to apply typeof to __traits(getAttributes) as well: foreach (T; typeof(__traits(getAttributes, k))) { pragma(msg, T); } Now we get a list of types: string int Ali
Oct 28 2016
On Friday, October 28, 2016 10:52:05 Temtaime via Digitalmars-d-learn wrote:Hi ! Tried to find alias Typeof(alias A) = typeof(A); or something, but failed. Are there something or should I create a PR to phobos? ThanksIf it were in Phobos, I'd expect it to be in std.meta, and it's not there. - Jonathan M Davis
Oct 28 2016