mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Move utils.h implementations to utils.cpp
This commit is contained in:
@@ -220,10 +220,10 @@ struct is_unsigned_integral<uint64_t> {
|
||||
#if TINS_IS_CXX11 && !defined(_MSC_VER)
|
||||
|
||||
// Template metaprogramming trait to determine if a functor can accept another parameter as an argument
|
||||
template <class T, class P, class=void>
|
||||
template <typename T, typename P, typename=void>
|
||||
struct accepts_type : std::false_type { };
|
||||
|
||||
template <class T, class P>
|
||||
template <typename T, typename P>
|
||||
struct accepts_type<T, P,
|
||||
typename std::enable_if<
|
||||
std::is_same< decltype( std::declval<T>()(std::declval<P>()) ), bool>::value
|
||||
@@ -231,17 +231,17 @@ struct accepts_type<T, P,
|
||||
> : std::true_type { };
|
||||
|
||||
// use enable_if to invoke the Packet&& version of the sniff_loop handler if possible - otherwise fail to old behavior
|
||||
template <class Functor, class Packet>
|
||||
template <typename Functor, typename Packet>
|
||||
bool invoke_loop_cb(Functor& f, Packet& p, typename std::enable_if<accepts_type<Functor, Packet>::value, bool>::type* = 0) {
|
||||
return f(std::move(p));
|
||||
}
|
||||
|
||||
template <class Functor, class Packet>
|
||||
template <typename Functor, typename Packet>
|
||||
bool invoke_loop_cb(Functor& f, Packet& p, typename std::enable_if<!accepts_type<Functor, Packet>::value && accepts_type<Functor, Packet&>::value, bool>::type* = 0) {
|
||||
return f(p);
|
||||
}
|
||||
|
||||
template <class Functor, class Packet>
|
||||
template <typename Functor, typename Packet>
|
||||
bool invoke_loop_cb(Functor& f, Packet& p, typename std::enable_if<!accepts_type<Functor, Packet>::value && !accepts_type<Functor, Packet&>::value, bool>::type* = 0) {
|
||||
return f(*p.pdu());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user