请问一下TimerQueue 构造函数里bind的问题

32 views
Skip to first unread message

clay Leven

unread,
Jan 27, 2021, 2:25:40 AM1/27/21
to Muduo network library
请问一下TimerQueue构造函数里的timerfdChannel_.setReadCallback(td::bind(&TimerQueue::handleRead, this));setReadCallback参数不是一个std::function<void(Timestamp)>嘛,为啥可以bind一个void void的函数啊

Shuo Chen

unread,
Jan 27, 2021, 1:42:11 PM1/27/21
to Muduo network library
Ref. docs:

1. https://www.boost.org/doc/libs/1_66_0/libs/bind/doc/html/bind.html#bind.purpose.using_bind_with_functions_and_fu
> Any extra arguments are silently ignored, just like the first and the second argument are ignored in the third example.

> If some of the arguments that are supplied in the call to g() are not matched by any placeholders stored in g, the unused arguments are evaluated and discarded.

Reply all
Reply to author
Forward
0 new messages