the Result Type
Philippe Sigaud
philippe.sigaud at gmail.com
Sun Dec 8 08:50:30 PST 2013
On Sun, Dec 8, 2013 at 9:59 AM, seany <seany at 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?
More information about the Digitalmars-d-learn
mailing list