Thread overview
[phobos] phobos commit, revision 1687
Jun 23, 2010
dsource.org
June 23, 2010
phobos commit, revision 1687


user: kyllingstad

msg:
Fixed unlisted bug: std.range.cycle() doesn't work with infinite ranges.

It was attempted to use the eponymous template trick inside a templated struct, like this:

  struct Cycle(R)
  {
      static if (isInfinite!R) alias R Cycle;
      ...
  }

but of course that doesn't work.  I've written the isInfinite case as a separate template instead, and added a unittest for it.

http://www.dsource.org/projects/phobos/changeset/1687

June 23, 2010
That should work, what was the error?

Andrei

On 06/23/2010 03:53 AM, dsource.org wrote:
> phobos commit, revision 1687
>
>
> user: kyllingstad
>
> msg:
> Fixed unlisted bug: std.range.cycle() doesn't work with infinite ranges.
>
> It was attempted to use the eponymous template trick inside a templated struct, like this:
>
>    struct Cycle(R)
>    {
>        static if (isInfinite!R) alias R Cycle;
>        ...
>    }
>
> but of course that doesn't work.  I've written the isInfinite case as a separate template instead, and added a unittest for it.
>
> http://www.dsource.org/projects/phobos/changeset/1687
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
June 23, 2010
Something like a "more initializers than there are fields" error originating in the cycle(), because the resulting struct has no members. What you are doing is this:

        struct Foo(T)
        {
            alias T Foo;
        }

        static assert (!is (Foo!int == int));
        static assert (is (Foo!(int).Foo == int));
        static assert ((Foo!int).sizeof == 1);

-Lars



On Wed, 2010-06-23 at 07:11 -0500, Andrei Alexandrescu wrote:
> That should work, what was the error?
> 
> Andrei
> 
> On 06/23/2010 03:53 AM, dsource.org wrote:
> > phobos commit, revision 1687
> >
> >
> > user: kyllingstad
> >
> > msg:
> > Fixed unlisted bug: std.range.cycle() doesn't work with infinite ranges.
> >
> > It was attempted to use the eponymous template trick inside a templated struct, like this:
> >
> >    struct Cycle(R)
> >    {
> >        static if (isInfinite!R) alias R Cycle;
> >        ...
> >    }
> >
> > but of course that doesn't work.  I've written the isInfinite case as a separate template instead, and added a unittest for it.
> >
> > http://www.dsource.org/projects/phobos/changeset/1687
> >
> > _______________________________________________
> > phobos mailing list
> > phobos at puremagic.com
> > http://lists.puremagic.com/mailman/listinfo/phobos
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos