Skip to content
Snippets Groups Projects
Commit 2f62f33e authored by williamfgc's avatar williamfgc Committed by GitHub
Browse files

Merge pull request #57 from chuckatkins/place-stdint-in-namespace

Add fixed width types and type trait info to the adios namespace.
parents 884a63d6 44d00755
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
#ifndef ADIOS_TYPES_H_ #ifndef ADIOS_TYPES_H_
#define ADIOS_TYPES_H_ #define ADIOS_TYPES_H_
#include <complex>
#include <cstddef>
#include <cstdint>
#include <type_traits>
namespace adios namespace adios
{ {
...@@ -37,6 +42,96 @@ enum class IOMode ...@@ -37,6 +42,96 @@ enum class IOMode
COLLECTIVE = 1 COLLECTIVE = 1
}; };
} // end namespace // Alias the fixed sized typed into the adios namespace to make sure we're
// always using the right ones.
using std::size_t;
using std::int8_t;
using std::uint8_t;
using std::int16_t;
using std::uint16_t;
using std::int32_t;
using std::uint32_t;
using std::int64_t;
using std::uint64_t;
// Not sure if we're really use these ones but we'll round it out for
// completion
using real32_t = float;
using real64_t = double;
using complex32_t = std::complex<real32_t>;
using complex64_t = std::complex<real64_t>;
// Get a fixed width integer type from a size specification
template <size_t Bytes, bool Signed>
struct FixedWidthInt;
template <>
struct FixedWidthInt<1, true>
{
using Type = std::int8_t;
};
template <>
struct FixedWidthInt<2, true>
{
using Type = std::int16_t;
};
template <>
struct FixedWidthInt<4, true>
{
using Type = std::int32_t;
};
template <>
struct FixedWidthInt<8, true>
{
using Type = std::int64_t;
};
template <>
struct FixedWidthInt<1, false>
{
using Type = std::uint8_t;
};
template <>
struct FixedWidthInt<2, false>
{
using Type = std::uint16_t;
};
template <>
struct FixedWidthInt<4, false>
{
using Type = std::uint32_t;
};
template <>
struct FixedWidthInt<8, false>
{
using Type = std::uint64_t;
};
// Some core type information that may be useful at compile time
template <typename T, typename Enable = void>
struct TypeInfo;
template <typename T>
struct TypeInfo<T, typename std::enable_if<std::is_integral<T>::value>::type>
{
using IOType =
typename FixedWidthInt<sizeof(T), std::is_signed<T>::value>::Type;
};
template <typename T>
struct TypeInfo<T,
typename std::enable_if<std::is_floating_point<T>::value>::type>
{
using IOType = T;
};
template <typename T>
struct TypeInfo<T, typename std::enable_if<std::is_same<
T, std::complex<typename T::value_type>>::value>::type>
{
using IOType = T;
};
} // end namespace adios
#endif /* ADIOS_TYPES_H_ */ #endif /* ADIOS_TYPES_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment