some core types, initial type traits
parent
6c6e7b69f7
commit
844fc88b9b
|
@ -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
|
|
@ -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<typename T, T val>
|
||||
struct IntegralConstant {
|
||||
static const T value = val;
|
||||
|
||||
typedef T value_type;
|
||||
typedef IntegralConstant<T, v> type;
|
||||
};
|
||||
|
||||
typedef IntegralConstant<bool, true> true_t;
|
||||
typedef IntegralConstant<bool, false> false_t;
|
||||
|
||||
template<typename T, T val> const T IntegralConstant<T, val>::value;
|
||||
|
||||
template<typename T> struct IsInteger: false_t {};
|
||||
template<typename T> struct IsFloat : false_t {};
|
||||
template<typename T> struct IsPointer: false_t {};
|
||||
|
||||
template<> struct IsInteger<bool >: true_t {};
|
||||
template<> struct IsInteger<char >: true_t {};
|
||||
template<> struct IsInteger<uchar >: true_t {};
|
||||
template<> struct IsInteger<schar >: true_t {};
|
||||
template<> struct IsInteger<short >: true_t {};
|
||||
template<> struct IsInteger<ushort>: true_t {};
|
||||
template<> struct IsInteger<int >: true_t {};
|
||||
template<> struct IsInteger<uint >: true_t {};
|
||||
template<> struct IsInteger<long >: true_t {};
|
||||
template<> struct IsInteger<ulong >: true_t {};
|
||||
template<> struct IsInteger<llong >: true_t {};
|
||||
template<> struct IsInteger<ullong>: true_t {};
|
||||
|
||||
template<> struct IsFloat<float>: true_t {};
|
||||
template<> struct IsFloat<double>: true_t {};
|
||||
template<> struct IsFloat<ldouble>: true_t {};
|
||||
|
||||
template<> struct IsPointer<T *>: true_t {};
|
||||
|
||||
template<typename T> struct IsPOD: IntegralConstant<bool,
|
||||
(IsInteger<T>::value || IsFloat<T>::value || IsPointer<T>::value)
|
||||
> {};
|
||||
|
||||
template<typename, typename>
|
||||
struct IsEqual {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct IsEqual<T, T> {
|
||||
static const bool value = true;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -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
|
|
@ -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 <stdint.h>
|
||||
|
||||
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
|
|
@ -6,8 +6,8 @@
|
|||
#ifndef OCTA_VECTOR_H
|
||||
#define OCTA_VECTOR_H
|
||||
|
||||
#include <octa/new.h>
|
||||
#include <octa/type_traits.h>
|
||||
#include "octa/new.h"
|
||||
#include "octa/traits.h"
|
||||
|
||||
namespace octa {
|
||||
template<typename T>
|
||||
|
|
Loading…
Reference in New Issue