diff --git a/include/tins/internals.h b/include/tins/internals.h index 25debb9..e408f35 100644 --- a/include/tins/internals.h +++ b/include/tins/internals.h @@ -220,14 +220,19 @@ struct accepts_type()(std::declval

()) ), bool>::value >> : std::true_type { }; -// use enable_if to invoke the Packet& version of the sniff_loop handler if possible - otherwise fail to old behavior +// use enable_if to invoke the Packet&& version of the sniff_loop handler if possible - otherwise fail to old behavior template bool invoke_loop_cb(Functor& f, Packet& p, typename std::enable_if::value, bool>::type* = 0) { return f(std::move(p)); } template -bool invoke_loop_cb(Functor& f, Packet& p, typename std::enable_if::value, bool>::type* = 0) { +bool invoke_loop_cb(Functor& f, Packet& p, typename std::enable_if::value && accepts_type::value, bool>::type* = 0) { + return f(p); +} + +template +bool invoke_loop_cb(Functor& f, Packet& p, typename std::enable_if::value && !accepts_type::value, bool>::type* = 0) { return f(*p.pdu()); } #endif