If the foreach loop is replaced by:
foreach(ref node_ref; np)
Then it works like a charm!
On Friday, 22 August 2014 at 20:12:39 UTC, Wyatt wrote:
I poked it a bit and came out with this. I _think_ it's
working as expected:
...
auto ref opSlice(){return nodes[];};
...
-Wyatt
Assuming it's working as expected, that is exactly what I was
looking for!
But the following cod
Indeed the ref can be applied to the return type:
http://dlang.org/function.html#ref-functions
So, does the following code copy any data from "nodes"?
If that is the case this solution avoids the "class" storage,
avoids pointers and "nodes" is encapsulated as read-only, that's
great.
The progra
First of all thanks for your replies, they are useful.
@Philippe:
A pure function is ok for initializing "default_nodes" but not
for "nodes" because a pure function can't read a file.
The "static this" has the problem it needs know the initializer
at compile time but I wanted to choose the init
Hello,
I have some questions on how to do a few things in D.
Below is an example code on which the questions are based.
I need read access to a big and complex (i.e.: nested) data
structure of type "Node".
But first it needs to be initialized. That can be done with a
default initializer or from a