Re: opApply and attributes

2020-07-16 Thread solidstate1991 via Digitalmars-d-learn
On Tuesday, 14 July 2020 at 00:17:14 UTC, solidstate1991 wrote: Something like that, but with @safe, pure, etc. attributes. I've tried to "bruteforce" it by generating functions with combinations of attributes, and it kinda works, but is a very janky solution. I'll brainstorm some DIP to

Re: opApply and attributes

2020-07-13 Thread solidstate1991 via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 20:53:05 UTC, Ali Çehreli wrote: I am not sure whether I understand it correctly but there has been a request for opApply() to gain the attributes of the delegate (or the range?). In other words, "transfer the attributes to opApply". This is needed beca

Re: opApply and attributes

2020-07-07 Thread Ali Çehreli via Digitalmars-d-learn
there has been a request for opApply() to gain the attributes of the delegate (or the range?). In other words, "transfer the attributes to opApply". This is needed because I want opApply() to work with any foreach body, attributes of which opApply() cannot know. I am sure I created an issu

Re: opApply and attributes

2020-07-07 Thread solidstate1991 via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 13:33:41 UTC, Paul Backus wrote: You can make opApply a template: int opApply(Dg)(Dg dg) if (is(Dg : scope int delegate(ref E))) { // etc. } Because `scope int delegate(ref E) @safe` implicitly converts to `scope int delegate(ref E)`,

Re: opApply and attributes

2020-07-07 Thread Stanislav Blinov via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 13:33:41 UTC, Paul Backus wrote: You can make opApply a template: int opApply(Dg)(Dg dg) if (is(Dg : scope int delegate(ref E))) { // etc. } Because `scope int delegate(ref E) @safe` implicitly converts to `scope int delegate(ref E)`,

Re: opApply and attributes

2020-07-07 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 00:20:40 UTC, solidstate1991 wrote: See implementation of data structure here: https://github.com/ZILtoid1991/collections-d/blob/master/source/collections/treemap.d#L565 If I try to compile this code, it'll fail, limiting it's usecase: @safe pure unittest {

opApply and attributes

2020-07-06 Thread solidstate1991 via Digitalmars-d-learn
See implementation of data structure here: https://github.com/ZILtoid1991/collections-d/blob/master/source/collections/treemap.d#L565 If I try to compile this code, it'll fail, limiting it's usecase: @safe pure unittest { alias IntMap = TreeMap!(int, int, false); IntMap test;

Re: Using opApply and Attributes

2016-11-20 Thread ketmar via Digitalmars-d-learn
On Sunday, 20 November 2016 at 16:36:18 UTC, Q. Schroll wrote: How can I have relative-@attrib functions without unnecessary manual overloading? import std.traits; auto f1(DG) (DG dg) if (isCallable!DG && Parameters!DG.length == 1 && is(Parameters!DG[0] == int)) { // check other things here

Using opApply and Attributes

2016-11-20 Thread Q. Schroll via Digitalmars-d-learn
When using functions with delegate (or function ptr) parameters which should comply with some attributes, I cannot call the delegate in the function what makes it pretty useless (I haven't done research, but I claim that generally most functions taking delegate parameters call them). void