Re: Template specialisation, "Generic type locking", offline stdlib docs and case-based template question

2017-11-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 01, 2017 03:39:12 helxi via Digitalmars-d-learn wrote: > 1. Template specialisation. > Why is this useful?: > T getResponse(T = int)(string question); And how does it differ > from > int getResponse(string question); ? > > Context: http://ddili.org/ders/d.en/templates.html : Sec

Re: Template specialisation, "Generic type locking", offline stdlib docs and case-based template question

2017-11-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 1 December 2017 at 03:39:12 UTC, helxi wrote: 1. Template specialisation. Why is this useful?: T getResponse(T = int)(string question); And how does it differ from int getResponse(string question); ? Because you can change the T at the call site. Let me give you a real world exam

Re: Template specialisation, "Generic type locking", offline stdlib docs and case-based template question

2017-11-30 Thread user1234 via Digitalmars-d-learn
On Friday, 1 December 2017 at 03:39:12 UTC, helxi wrote: 1. Template specialisation. Why is this useful?: T getResponse(T = int)(string question); And how does it differ from int getResponse(string question); ? Good Q. Without thinking more it looks like a pointless example. The only differe

Template specialisation, "Generic type locking", offline stdlib docs and case-based template question

2017-11-30 Thread helxi via Digitalmars-d-learn
1. Template specialisation. Why is this useful?: T getResponse(T = int)(string question); And how does it differ from int getResponse(string question); ? Context: http://ddili.org/ders/d.en/templates.html : Section: "Default template parameters" 2. "Generic locking". Is it possible to specia