From 844fc88b9bbf1b80ee290c4dd1fcaea866a498e2 Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 13 Apr 2015 22:25:31 +0100 Subject: [PATCH] some core types, initial type traits --- README.md | 5 ---- octa/traits.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++ octa/type_traits.h | 12 --------- octa/types.h | 23 +++++++++++++++++ octa/vector.h | 4 +-- 5 files changed, 88 insertions(+), 19 deletions(-) create mode 100644 octa/traits.h delete mode 100644 octa/type_traits.h create mode 100644 octa/types.h diff --git a/README.md b/README.md index 698a5f6..5b332e5 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,3 @@ OctaSTD is a collection of C++ utilities to aid the upcoming OctaForge C++ API. It provides containers (dynamic arrays etc) as well as other utilities. - -Currently implemented: - -* new/delete operators -* vector \ No newline at end of file diff --git a/octa/traits.h b/octa/traits.h new file mode 100644 index 0000000..e1f5735 --- /dev/null +++ b/octa/traits.h @@ -0,0 +1,63 @@ +/* Type traits for OctaSTD. + * + * This file is part of OctaSTD. See COPYING.md for futher information. + */ + +#ifndef OCTA_TRAITS_H +#define OCTA_TRAITS_H + +#include "octa/types.h" + +namespace octa { + template + struct IntegralConstant { + static const T value = val; + + typedef T value_type; + typedef IntegralConstant type; + }; + + typedef IntegralConstant true_t; + typedef IntegralConstant false_t; + + template const T IntegralConstant::value; + + template struct IsInteger: false_t {}; + template struct IsFloat : false_t {}; + template struct IsPointer: false_t {}; + + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + template<> struct IsInteger: true_t {}; + + template<> struct IsFloat: true_t {}; + template<> struct IsFloat: true_t {}; + template<> struct IsFloat: true_t {}; + + template<> struct IsPointer: true_t {}; + + template struct IsPOD: IntegralConstant::value || IsFloat::value || IsPointer::value) + > {}; + + template + struct IsEqual { + static const bool value = false; + }; + + template + struct IsEqual { + static const bool value = true; + }; +} + +#endif \ No newline at end of file diff --git a/octa/type_traits.h b/octa/type_traits.h deleted file mode 100644 index b0b9521..0000000 --- a/octa/type_traits.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Type traits for OctaSTD. - * - * This file is part of OctaSTD. See COPYING.md for futher information. - */ - -#ifndef OCTA_TYPE_TRAITS_H -#define OCTA_TYPE_TRAITS_H - -namespace octa { -} - -#endif \ No newline at end of file diff --git a/octa/types.h b/octa/types.h new file mode 100644 index 0000000..f12acf9 --- /dev/null +++ b/octa/types.h @@ -0,0 +1,23 @@ +/* Core typedefs for OctaSTD. + * + * This file is part of OctaSTD. See COPYING.md for futher information. + */ + +#ifndef OCTA_TYPES_H +#define OCTA_TYPES_H + +#include + +namespace octa { + typedef signed char schar; + typedef unsigned char uchar; + typedef unsigned short ushort; + typedef unsigned int uint; + typedef unsigned long ulong; + typedef unsigned long long ullong; + typedef long long llong; + + typedef long double ldouble; +} + +#endif \ No newline at end of file diff --git a/octa/vector.h b/octa/vector.h index 38850ce..9188e79 100644 --- a/octa/vector.h +++ b/octa/vector.h @@ -6,8 +6,8 @@ #ifndef OCTA_VECTOR_H #define OCTA_VECTOR_H -#include -#include +#include "octa/new.h" +#include "octa/traits.h" namespace octa { template