On Saturday, 28 April 2012 at 06:03:54 UTC, Mehrdad wrote:
You expected that to work?

Uhm, why not?

template<class T>
struct F
{
   F<F<T> > f() { return F<F<T> >(); }
};

int main()
{
   F<int>().f().f().f().f().f();  // etc.
   return 0;
}


dmd is not smart enough to avoid recursion by treating f as a
templated function. I am not sure whether it should, but the
following should certainly work:

struct F(T)
{
     auto f()() { return F!(F!T)(); }
}

void main()
{
     F!int().f().f().f();
}

Error: struct a.F(T) recursive template expansion for template
argument - why?

Reply via email to