where to find Implements!
Jonathan M Davis
jmdavisProg at gmx.com
Wed Sep 29 13:28:21 PDT 2010
On Wednesday, September 29, 2010 13:14:27 BLS wrote:
> On 29/09/2010 21:19, Jonathan M Davis wrote:
> > On Wednesday, September 29, 2010 11:58:01 BLS wrote:
> >> Hope is was not a pipe dream...
> >> I've no idea who has published it and where to find this snippet but in
> >> case that I am not completely wrong there should exist something like
> >> Implements!() for structures..
> >> ???
> >> Bjoern
> >
> > And what would the implement? I thought that structs didn't work with
> > interfaces. And if they did, you'd use is() with : to test that. So, what
> > are you really looking for here? What would Implements!() do if it
> > exists?
> >
> > - Jonathan M Davis
>
> Hi Jonathan,
> Just because structures don't work with interfaces I am still hoping for
> Implements!().
>
> What do I expect from Implements! A contract which ensures (at compile
> time) that a structure implements f.i. all functions required by a
> random access range.
>
> well, as said, I'm not even sure that Implements! exist at all.
> bjoern
There are specific eponymous templates for dealing with each range type. Look in
std.range for the whole list, but isRandomAccesRange() handles random access
ranges. Since there is no interface for ranges, you can't check generically
whether a particular type correctly implements a particular range type - e.g
is(mystruct : RandomAccessRange) or implements!(RandomAccessRange, mystrucT).
There has to be a function specific to that range type. In this case, that's
isRandomAccessRange().
- Jonathan M Davis
More information about the Digitalmars-d
mailing list