30#ifndef TINS_TYPE_TRAITS_H
31#define TINS_TYPE_TRAITS_H
34#include <tins/cxxstd.h>
36 #include <type_traits>
46template<
bool,
typename T =
void>
52struct enable_if<false, T> {
62struct is_unsigned_integral {
63 static const bool value =
false;
67struct is_unsigned_integral<uint8_t> {
68 static const bool value =
true;
72struct is_unsigned_integral<uint16_t> {
73 static const bool value =
true;
77struct is_unsigned_integral<uint32_t> {
78 static const bool value =
true;
82struct is_unsigned_integral<uint64_t> {
83 static const bool value =
true;
86#if TINS_IS_CXX11 && !defined(_MSC_VER)
89template <
typename T,
typename P,
typename=
void>
90struct accepts_type : std::false_type { };
92template <
typename T,
typename P>
93struct accepts_type<T, P,
94 typename std::enable_if<
95 std::is_same< decltype( std::declval<T>()(std::declval<P>()) ), bool>::value
97> : std::true_type { };
100template <
typename Functor,
typename Packet>
101bool invoke_loop_cb(Functor& f, Packet& p,
102 typename std::enable_if<accepts_type<Functor, Packet>::value,
bool>::type* = 0) {
103 return f(std::move(p));
106template <
typename Functor,
typename Packet>
107bool invoke_loop_cb(Functor& f, Packet& p,
108 typename std::enable_if<!accepts_type<Functor, Packet>::value && accepts_type<Functor, Packet&>::value,
bool>::type* = 0) {
112template <
typename Functor,
typename Packet>
113bool invoke_loop_cb(Functor& f, Packet& p,
114 typename std::enable_if<!accepts_type<Functor, Packet>::value && !accepts_type<Functor, Packet&>::value,
bool>::type* = 0) {
The Tins namespace.
Definition address_range.h:38