Problem with templated alias as delegate parameter type

cc cc at nevernet.com
Tue Jan 12 22:36:59 UTC 2021


On Tuesday, 12 January 2021 at 21:32:14 UTC, Ali Çehreli wrote:
> On 1/12/21 12:58 PM, cc wrote:
>
> >      void send(T query, void delegate(T.RESPONSE) callback) {
>
> That wants a delegate that takes a T.RESPONSE (PingResponse in 
> this case). However, the following lambda is in fact a template:
>
> >      send(PingQuery("helo"), (resp) {
>
> You specify the type there and it works:
>
>     send(PingQuery("helo"), (PingResponse resp) {
>
> Ali

That seems to work, thanks.  I ended up having to define a second 
template parameter:

template send(T,TR) if (is(TR == T.RESPONSE)) {
	void send(T query, void delegate(TR) callback) {
...




More information about the Digitalmars-d-learn mailing list