Re: How to avoid inout type constructor with Optional type wrapper undoing string type

2018-07-23 Thread aliak via Digitalmars-d-learn
On Monday, 23 July 2018 at 19:31:42 UTC, aliak wrote: Ok, now I'm totally confused. Defining an extra type constructor makes everything work. I.e add a const one to the inout one: auto defined(T)(const auto ref T value) { return W!T(value); } and everything works! Can anyone say why

Re: How to avoid inout type constructor with Optional type wrapper undoing string type

2018-07-23 Thread aliak via Digitalmars-d-learn
On Monday, 23 July 2018 at 19:02:02 UTC, Jacob Carlborg wrote: This [1] compiles the first example but not the second. [1] https://run.dlang.io/is/SJ02kP Aye it does, but it also sets T to always const which is unfortunately impractical for my use case :(

Re: How to avoid inout type constructor with Optional type wrapper undoing string type

2018-07-23 Thread aliak via Digitalmars-d-learn
On Monday, 23 July 2018 at 19:22:13 UTC, aliak wrote: On Monday, 23 July 2018 at 19:02:02 UTC, Jacob Carlborg wrote: This [1] compiles the first example but not the second. [1] https://run.dlang.io/is/SJ02kP Aye it does, but it also sets T to always const which is unfortunately impractical

How to avoid inout type constructor with Optional type wrapper undoing string type

2018-07-23 Thread aliak via Digitalmars-d-learn
Hi, I'm playing around with an Optional wrapper type. It stores a type T and a bool that defines whether a value is defined or not: struct Optional(T) { T value; bool defined = false; this(U : T)(auto ref inout(U) value) inout { this.value = value; this.defined = true; } } To

Re: How to avoid inout type constructor with Optional type wrapper undoing string type

2018-07-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-07-23 20:39, aliak wrote: Hi, I'm playing around with an Optional wrapper type. It stores a type T and a bool that defines whether a value is defined or not: struct Optional(T) {   T value;   bool defined = false;   this(U : T)(auto ref inout(U) value) inout {     this.value =

trait to get the body code of a function?

2018-07-23 Thread Guillaume Lathoud via Digitalmars-d-learn
Hello, __traits and std.traits already offer access to function information like input parameters, e.g. in std.traits: ParameterIdentifierTuple ParameterStorageClassTuple Even if that might sound strange, is there a compile time access to the body of the function, e.g. as a code string, or

Re: trait to get the body code of a function?

2018-07-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/07/2018 4:43 PM, Guillaume Lathoud wrote: Hello, __traits and std.traits already offer access to function information like input parameters, e.g. in std.traits: ParameterIdentifierTuple ParameterStorageClassTuple Even if that might sound strange, is there a compile time access to the

Re: merging a group result

2018-07-23 Thread Alex via Digitalmars-d-learn
On Monday, 23 July 2018 at 12:07:37 UTC, Seb wrote: You could use chunkBy: auto res = sarr.chunkBy!((a, b) => a.s == b.s).map!(a => tuple(a.front.s, a.map!(b => b.i).sum)); https://run.dlang.io/is/TJOEmf Ha... This helps! Thanks a lot! :)

Re: QWebView requesting QtE5WebEng32.so on windows

2018-07-23 Thread MGW via Digitalmars-d-learn
On Saturday, 21 July 2018 at 19:11:08 UTC, Dr.No wrote: So I went to try out QWebView on Windows from this wrapper: https://github.com/MGWL/QtE5 all the examples went fine until I tried QWebView: Prior to version Qt-5.5 WebKit was used, and for later versions of chromium-based WebEngine.

merging a group result

2018-07-23 Thread Alex via Digitalmars-d-learn
Hi all, I'm looking for a d-ish way to solve a basic "split-apply-combine" workflow. The idea is described (and solved) here: https://stackoverflow.com/questions/39922986/pandas-group-by-and-sum So, given a structure with some fields, say ´´´ struct S { string s; int i; }

Re: How to get an inout constructor working with a template wrapper

2018-07-23 Thread aliak via Digitalmars-d-learn
On Sunday, 22 July 2018 at 23:11:09 UTC, Ali Çehreli wrote: Without much confidence on my side, first, I think you need to make the constructor parameter inout(T) as well. Otherwise, you may be making a const(W!T) initialized with a non-const T. After that, I like the "type constructor"

Re: merging a group result

2018-07-23 Thread rikki cattermole via Digitalmars-d-learn
On 23/07/2018 11:49 PM, Alex wrote: At this moment, I assume, that I'm approaching the problem from the wrong end, and simply don't see something trivial... Anyway, does anybody has a hint for me? Map the range to the integer value, then sum it.

Re: How to get an inout constructor working with a template wrapper

2018-07-23 Thread aliak via Digitalmars-d-learn
On Monday, 23 July 2018 at 12:02:58 UTC, aliak wrote: https://run.dlang.io/is/gd5oxW Sorry wrong link! This one is correct -> https://run.dlang.io/is/azxmGN

Re: merging a group result

2018-07-23 Thread Seb via Digitalmars-d-learn
On Monday, 23 July 2018 at 11:49:58 UTC, Alex wrote: Hi all, I'm looking for a d-ish way to solve a basic "split-apply-combine" workflow. The idea is described (and solved) here: https://stackoverflow.com/questions/39922986/pandas-group-by-and-sum So, given a structure with some fields, say

Re: How to get an inout constructor working with a template wrapper

2018-07-23 Thread Timoses via Digitalmars-d-learn
On Monday, 23 July 2018 at 12:02:58 UTC, aliak wrote: Thank you Ali! That helped :) I've gotten most of it sorted out now, and the factory wrap is definitely the way to go, it also turned out that inout(T) and inout T (so inout without parens) was surprisingly different (maybe it's a bug? -