Re: CT-String as a Symbol

2015-04-21 Thread Nordlöw
On Tuesday, 21 April 2015 at 20:30:00 UTC, Vlad Levenfeld wrote: Should work for any case I can think of (assuming integral indices). Thanks.

Re: CT-String as a Symbol

2015-04-21 Thread Vlad Levenfeld via Digitalmars-d-learn
template dimensionality (S) { template count_dim (uint i = 0) { static if (is (typeof(S.init.opSlice!i (0,0 enum count_dim = count_dim!(i+1); else static if (i == 0 && (isInputRange!S || is (typeof(S.init[0]))) enum count_dim = 1; else enum count_dim = i; } ali

Re: CT-String as a Symbol

2015-04-21 Thread Vlad Levenfeld via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 19:46:03 UTC, Nordlöw wrote: On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote: Then you throw in some more stuff to detect 1-dimensional cases. Could you please elaborate a bit? Well assuming the type is not multidimensional (does not define opSli

Re: CT-String as a Symbol

2015-04-21 Thread Nordlöw
On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote: Then you throw in some more stuff to detect 1-dimensional cases. Could you please elaborate a bit?

Re: CT-String as a Symbol

2015-04-21 Thread Vlad Levenfeld via Digitalmars-d-learn
As an aside, I've put a bit of work into the generic multidimensional containers problem lately and have an interface generating library as a result. https://github.com/evenex/autodata It's still in the nascent stages but contains a lot of tools for working with multidimensional structures.

Re: CT-String as a Symbol

2015-04-21 Thread Vlad Levenfeld via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 08:09:38 UTC, Per Nordlöw wrote: On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote: template dimensionality (S) { template count_dim (uint i = 0) { static if (is (typeof(S.init.opSlice!i (0,0 enum count_dim = count_dim!(i+1); else enum c

Re: CT-String as a Symbol

2015-04-21 Thread via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote: template dimensionality (S) { template count_dim (uint i = 0) { static if (is (typeof(S.init.opSlice!i (0,0 enum count_dim = count_dim!(i+1); else enum count_dim = i; } alias dimensionality = count_dim!(); }

Re: CT-String as a Symbol

2015-04-21 Thread Vlad Levenfeld via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 07:01:27 UTC, Per Nordlöw wrote: On Tuesday, 21 April 2015 at 06:56:33 UTC, Per Nordlöw wrote: On Monday, 20 April 2015 at 13:49:41 UTC, John Colvin wrote: On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote: Is there a way to CT-query the arity of all opIndex

Re: CT-String as a Symbol

2015-04-21 Thread via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 06:56:33 UTC, Per Nordlöw wrote: On Monday, 20 April 2015 at 13:49:41 UTC, John Colvin wrote: On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote: Is there a way to CT-query the arity of all opIndex and opSlice overloads? Further, this is slightly related to

Re: CT-String as a Symbol

2015-04-21 Thread via Digitalmars-d-learn
On Monday, 20 April 2015 at 13:49:41 UTC, John Colvin wrote: On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote: Is there a way to CT-query the arity of all opIndex and opSlice overloads? Ideally you don't want to have to do that. You'd have to consider alias this and inheritance. Ho

Re: CT-String as a Symbol

2015-04-20 Thread John Colvin via Digitalmars-d-learn
On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote: Is there a way to CT-query the arity of all opIndex and opSlice overloads? Ideally you don't want to have to do that. You'd have to consider alias this and inheritance.

Re: CT-String as a Symbol

2015-04-20 Thread ketmar via Digitalmars-d-learn
On Mon, 20 Apr 2015 13:31:03 +, Nordlöw wrote: > On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote: >> Is there a way to CT-query the arity of all opIndex and opSlice >> overloads? > > Ping. as long as they aren't templates, you can use any function traits on 'em. like `ParameterT

Re: CT-String as a Symbol

2015-04-20 Thread Nordlöw
On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote: Is there a way to CT-query the arity of all opIndex and opSlice overloads? Ping.

Re: CT-String as a Symbol

2015-04-16 Thread Nordlöw
On Thursday, 16 April 2015 at 10:46:25 UTC, John Colvin wrote: On Thursday, 16 April 2015 at 10:27:20 UTC, Per Nordlöw wrote: On Wednesday, 15 April 2015 at 16:21:59 UTC, Nordlöw wrote: Help please. I'm quite satisfied with the current state now. Is anybody interested in having this in typec

Re: CT-String as a Symbol

2015-04-16 Thread John Colvin via Digitalmars-d-learn
On Thursday, 16 April 2015 at 10:27:20 UTC, Per Nordlöw wrote: On Wednesday, 15 April 2015 at 16:21:59 UTC, Nordlöw wrote: Help please. I'm quite satisfied with the current state now. Is anybody interested in having this in typecons.d in Phobos? I would be, yes. Have you considered what ha

Re: CT-String as a Symbol

2015-04-16 Thread via Digitalmars-d-learn
On Thursday, 16 April 2015 at 10:24:05 UTC, Per Nordlöw wrote: How is this possible? Shouldn't it CT-evaluate to struct Index { ... } !? Ahh, in the case when I is "I". Ok I get it. That's the reason. Thx

Re: CT-String as a Symbol

2015-04-16 Thread via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 16:21:59 UTC, Nordlöw wrote: Help please. I'm quite satisfied with the current state now. Is anybody interested in having this in typecons.d in Phobos?

Re: CT-String as a Symbol

2015-04-16 Thread via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 23:02:32 UTC, Ali Çehreli wrote: struct I { alias T = size_t; this(T ix) { this._ix = ix; } T opCast(U : T)() const { return _ix; } private T _ix = 0; } How is this possible? Sh

Re: CT-String as a Symbol

2015-04-15 Thread Ali Çehreli via Digitalmars-d-learn
On 04/15/2015 03:42 PM, "Nordlöw" wrote: > On Wednesday, 15 April 2015 at 20:12:27 UTC, Ali Çehreli wrote: >> Ali > > I cracked it: > > Reason: I hade a failing unittest using it as > > auto xs = x.indexedBy!"I"; > > which I changed to > > auto xs = x.indexedBy!"Ix"; > > For some reason

Re: CT-String as a Symbol

2015-04-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/15/15 6:42 PM, "Nordlöw" wrote: On Wednesday, 15 April 2015 at 20:12:27 UTC, Ali Çehreli wrote: Ali I cracked it: Reason: I hade a failing unittest using it as auto xs = x.indexedBy!"I"; which I changed to auto xs = x.indexedBy!"Ix"; For some reason the mixin magic becomes

Re: CT-String as a Symbol

2015-04-15 Thread Nordlöw
On Wednesday, 15 April 2015 at 20:12:27 UTC, Ali Çehreli wrote: Ali I cracked it: Reason: I hade a failing unittest using it as auto xs = x.indexedBy!"I"; which I changed to auto xs = x.indexedBy!"Ix"; For some reason the mixin magic becomes confused when I equals "I". Do you ha

Re: CT-String as a Symbol

2015-04-15 Thread Ali Çehreli via Digitalmars-d-learn
On 04/15/2015 12:19 PM, "Nordlöw" wrote: I'm using DMD 2.067. Mee too. The following is the minimum amount of code I used, which compiles: import std.traits; import std.range; struct Index(T = size_t) if (isUnsigned!T) { this(T ix) { this._ix = ix; } T opCast(U : T)() const { return _

Re: CT-String as a Symbol

2015-04-15 Thread Nordlöw
I'm using DMD 2.067.

Re: CT-String as a Symbol

2015-04-15 Thread Nordlöw
On Wednesday, 15 April 2015 at 19:15:36 UTC, Nordlöw wrote: errors typecons_ex.d(135,5): Error: mixin typecons_ex.IndexedBy!(int[3], "I").IndexedBy.genOps!"I" does not match template declaration genOps(T) typecons_ex.d(152,12): Error: template instance typecons_ex.IndexedBy!(int[3], "I") erro

Re: CT-String as a Symbol

2015-04-15 Thread Nordlöw
On Wednesday, 15 April 2015 at 17:03:36 UTC, Ali Çehreli wrote: This seems to work: mixin genOps!(mixin(I)); I'm afraid not: mixin genOps!(mixin(I)); errors typecons_ex.d(135,5): Error: mixin typecons_ex.IndexedBy!(int[3], "I").IndexedBy.genOps!"I" does not match template declarati

Re: CT-String as a Symbol

2015-04-15 Thread Ali Çehreli via Digitalmars-d-learn
On 04/15/2015 09:21 AM, "Nordlöw" wrote: At https://github.com/nordlow/justd/blob/master/typecons_ex.d#L143 I can't figure out how to make the call to mixin genOps!I; expand to, for instance, mixin genOps!Index This seems to work: mixin genOps!(mixin(I)); in the case when