1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Move type traits into a separate file

This commit is contained in:
Matias Fontanini
2017-04-30 09:36:50 -07:00
parent f88cf9b025
commit a3e863942b
5 changed files with 88 additions and 36 deletions

View File

@@ -39,6 +39,7 @@
#include "pdu.h"
#include "hw_address.h"
#include "macros.h"
#include "detail/type_traits.h"
/**
* \cond
@@ -109,16 +110,6 @@ void skip_line(std::istream& input);
bool from_hex(const std::string& str, uint32_t& result);
bool from_hex(const std::string& str, std::string& result);
template<bool, typename T = void>
struct enable_if {
typedef T type;
};
template<typename T>
struct enable_if<false, T> {
};
PDU* pdu_from_flag(Constants::Ethernet::e flag, const uint8_t* buffer,
uint32_t size, bool rawpdu_on_no_match = true);
PDU* pdu_from_flag(Constants::IP::e flag, const uint8_t* buffer,
@@ -199,31 +190,6 @@ inline bool is_dot3(const uint8_t* ptr, size_t sz) {
return (sz >= 13 && ptr[12] < 8);
}
template<typename T>
struct is_unsigned_integral {
static const bool value = false;
};
template<>
struct is_unsigned_integral<uint8_t> {
static const bool value = true;
};
template<>
struct is_unsigned_integral<uint16_t> {
static const bool value = true;
};
template<>
struct is_unsigned_integral<uint32_t> {
static const bool value = true;
};
template<>
struct is_unsigned_integral<uint64_t> {
static const bool value = true;
};
#if TINS_IS_CXX11 && !defined(_MSC_VER)
// Template metaprogramming trait to determine if a functor can accept another parameter as an argument