//----
struct S
{
   int[] r;
   alias r this;
}

void main()
{
   S s;
   s.front(); //OK
   s.popFront(); //No Match
   static assert (isForwardRange!S); //Nope
}
//----

The problem, basically, is that front's signature is (basically):
@property ref T front(T)(T[] a)
    if (isDynamicArray!(T[]))

popFront's signature though is:
void popFront(A)(A a)
    if (isDynamicArray!A)

The problem is that the constraint "isDynamicArray" requires an exact match. This means in the case of front, S is converted via alias this to int[], and the constraints pass. In the case of popFront, however, S is taken directly as is, and the test isDynamicArray fails.

I tried changing the signature to popFront, and everything works fine all over phobos. (except for a twisted unittest that tested popFront specifying the template parameters, but doing that sounds like nonsense to me, and is just badly written test).

Does anybody know if there is a reason other than "historical" for this?

I find it stange that front and popFront have different behaviors, so I think one of either should be "fixed".

IMO, I think accepting the S type makes sense. Thoughts?

Reply via email to