On Sun, Dec 8, 2013 at 9:59 AM, seany <se...@uni-bonn.de> wrote: > O_O > > with that knowledge, would also be possible to define new types (not > aliases, but new encapsulated types) representing things such as Graph, > Ring, Topology, surreal number, etc?
Other posters already answered your questions concerning ranges. In short, you can define internal structs (or classes, or functions) inside a function, another struct, a class, and return them. They can be parameterized on the host type template parameters, if any. All the different types in std.algorithm and std.range have *nothing* in common (no common base class, nor are they part of a common datatype), *except* they all respect the range 'concept'. As long as something (class or struct) has the three basic range methods (empty / front / popFront), it can be used with other functions in std.algorithm and std.range. Returning to you question, now. You can do exactly with other types what was done with ranges in the standard library. As long as you define the basic properties of a Graph / Ring / Whatever, and associate it with a guard template (see std.range.isInputRange), any type can be used as a Graph. Maybe you could give us more details on what you want to realize exactly?