mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
compat.h: Add new types, native_t and unative_t, functionally equivalent to our current bssize_t and bsize_t, respectively, but generated dependably using template metaprogramming when building with C++ >= 11.
git-svn-id: https://svn.eduke32.com/eduke32@6118 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
7a40df33b6
commit
73654c2079
1 changed files with 36 additions and 0 deletions
|
@ -650,6 +650,33 @@ template<bool B, class T, class F>
|
|||
using conditional_t = typename std::conditional<B, T, F>::type;
|
||||
# endif
|
||||
|
||||
template <size_t size>
|
||||
struct integers_of_size { };
|
||||
template <>
|
||||
struct integers_of_size<sizeof(int8_t)>
|
||||
{
|
||||
typedef int8_t i;
|
||||
typedef uint8_t u;
|
||||
};
|
||||
template <>
|
||||
struct integers_of_size<sizeof(int16_t)>
|
||||
{
|
||||
typedef int16_t i;
|
||||
typedef uint16_t u;
|
||||
};
|
||||
template <>
|
||||
struct integers_of_size<sizeof(int32_t)>
|
||||
{
|
||||
typedef int32_t i;
|
||||
typedef uint32_t u;
|
||||
};
|
||||
template <>
|
||||
struct integers_of_size<sizeof(int64_t)>
|
||||
{
|
||||
typedef int64_t i;
|
||||
typedef uint64_t u;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -666,6 +693,15 @@ private:
|
|||
};
|
||||
#endif
|
||||
|
||||
#if CXXSTD >= 2011
|
||||
using native_t = typename integers_of_size<sizeof(size_t)>::i;
|
||||
using unative_t = typename integers_of_size<sizeof(size_t)>::u;
|
||||
#else
|
||||
typedef ssize_t native_t;
|
||||
typedef size_t unative_t;
|
||||
#endif
|
||||
EDUKE32_STATIC_ASSERT(sizeof(native_t) == sizeof(unative_t));
|
||||
|
||||
typedef struct {
|
||||
int32_t x, y;
|
||||
} vec2_t;
|
||||
|
|
Loading…
Reference in a new issue