Improve to_se conversion template

Add sizeof check instead of filtering out 1-byte types.
This commit is contained in:
Nekotekina 2019-09-27 22:04:48 +03:00
parent bd1a24b894
commit 21885264f7

View file

@ -360,7 +360,7 @@ struct to_se
template <typename T2> template <typename T2>
struct to_se_<T2, std::enable_if_t<std::is_arithmetic<T2>::value || std::is_enum<T2>::value>> struct to_se_<T2, std::enable_if_t<std::is_arithmetic<T2>::value || std::is_enum<T2>::value>>
{ {
using type = se_t<T2, Se>; using type = std::conditional_t<(sizeof(T2) > 1), se_t<T2, Se>, T2>;
}; };
// Convert arithmetic and enum types // Convert arithmetic and enum types
@ -385,30 +385,6 @@ struct to_se<s128, Se>
using type = se_t<s128, Se>; using type = se_t<s128, Se>;
}; };
template <bool Se>
struct to_se<bool, Se>
{
using type = bool;
};
template <bool Se>
struct to_se<char, Se>
{
using type = char;
};
template <bool Se>
struct to_se<u8, Se>
{
using type = u8;
};
template <bool Se>
struct to_se<s8, Se>
{
using type = s8;
};
template <typename T, bool Se> template <typename T, bool Se>
struct to_se<const T, Se, std::enable_if_t<!std::is_array<T>::value>> struct to_se<const T, Se, std::enable_if_t<!std::is_array<T>::value>>
{ {