ClickHouse/base/common/types.h
Ivan 571d0d541c
Improve CCTZ contrib (#9687)
* common/Types.h → common/types.h
  Also split Core/Defines.h and merge with common/likely.h
* Improve cctz contrib
* Fix ALWAYS_INLINE and unbundled build
* Update Dockerfile from master
* Fix test for unbundled library
2020-03-19 13:38:34 +03:00

59 lines
1.3 KiB
C++

#pragma once
#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <string>
#include <type_traits>
using Int8 = int8_t;
using Int16 = int16_t;
using Int32 = int32_t;
using Int64 = int64_t;
using UInt8 = char8_t;
using UInt16 = uint16_t;
using UInt32 = uint32_t;
using UInt64 = uint64_t;
using String = std::string;
/// The standard library type traits, such as std::is_arithmetic, with one exception
/// (std::common_type), are "set in stone". Attempting to specialize them causes undefined behavior.
/// So instead of using the std type_traits, we use our own version which allows extension.
template <typename T>
struct is_signed
{
static constexpr bool value = std::is_signed_v<T>;
};
template <typename T>
inline constexpr bool is_signed_v = is_signed<T>::value;
template <typename T>
struct is_unsigned
{
static constexpr bool value = std::is_unsigned_v<T>;
};
template <typename T>
inline constexpr bool is_unsigned_v = is_unsigned<T>::value;
template <typename T>
struct is_integral
{
static constexpr bool value = std::is_integral_v<T>;
};
template <typename T>
inline constexpr bool is_integral_v = is_integral<T>::value;
template <typename T>
struct is_arithmetic
{
static constexpr bool value = std::is_arithmetic_v<T>;
};
template <typename T>
inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;