Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On Friday, 16 December 2016 at 01:48:59 UTC, Ali Çehreli wrote: On 12/15/2016 05:30 PM, Stefan Koch wrote: On Thursday, 15 December 2016 at 19:30:08 UTC, Ali Çehreli wrote: Yeah, I think the compiler is confused because the function is called in a non-const context during the initialization
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On 12/15/2016 05:30 PM, Stefan Koch wrote: On Thursday, 15 December 2016 at 19:30:08 UTC, Ali Çehreli wrote: Yeah, I think the compiler is confused because the function is called in a non-const context during the initialization of an immutable object. I would open an issue:
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On Thursday, 15 December 2016 at 19:30:08 UTC, Ali Çehreli wrote: Yeah, I think the compiler is confused because the function is called in a non-const context during the initialization of an immutable object. I would open an issue: https://issues.dlang.org/enter_bug.cgi?product=D Ali
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On 12/14/2016 04:02 AM, Ali wrote: > On Tuesday, 13 December 2016 at 23:29:31 UTC, Ali Çehreli wrote: >> On 12/13/2016 01:36 PM, Ali wrote: >> >>> Now about that second part of my problem >> >> I'm not entirely sure whether this should work but I think the problem >> is with mutating the
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On Tuesday, 13 December 2016 at 23:29:31 UTC, Ali Çehreli wrote: On 12/13/2016 01:36 PM, Ali wrote: Now about that second part of my problem I'm not entirely sure whether this should work but I think the problem is with mutating the 'frequencies' member of an immutable element of
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On 12/13/2016 01:36 PM, Ali wrote: Now about that second part of my problem I'm not entirely sure whether this should work but I think the problem is with mutating the 'frequencies' member of an immutable element of 'rooms'. The error message means that those non-const expressions
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On Tuesday, 13 December 2016 at 21:33:11 UTC, Ali Çehreli wrote: On 12/13/2016 12:30 PM, Ali wrote: > foreach (i, room; rooms) { > data[i].room = That is the address of the local variable room. You need to use 'ref' there: foreach (i, ref room; rooms) { > - Ali Ahh
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On 12/13/2016 12:30 PM, Ali wrote: > foreach (i, room; rooms) { > data[i].room = That is the address of the local variable room. You need to use 'ref' there: foreach (i, ref room; rooms) { > - Ali Ali "the real one :o)"
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
2016-12-13
Thread
bauss (wtf happend to my name took some old cached title LOL??) via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 21:21:34 UTC, Ali wrote: On Tuesday, 13 December 2016 at 21:08:31 UTC, drug007 wrote: (*d.room).name Oh yeah, tried that too. That at least compiles but gives a runtime exception (bad address). Try (*cast(Room*)(d.room)).name
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On Tuesday, 13 December 2016 at 21:08:31 UTC, drug007 wrote: (*d.room).name Oh yeah, tried that too. That at least compiles but gives a runtime exception (bad address).
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On 13.12.2016 23:30, Ali wrote: Hi, Long time watcher and recently started playing with D a bit more. Ran in to a couple of snags that I'll combine in one post. It involves a data set that contains a list of strings. Each string represents a Room name. What I'm trying to do is pluck out the room
Accessing members through pointers to structs (also, CTFE associative arrays)
Hi, Long time watcher and recently started playing with D a bit more. Ran in to a couple of snags that I'll combine in one post. It involves a data set that contains a list of strings. Each string represents a Room name. What I'm trying to do is pluck out the room names and also calculate the