add type trait to check type size in bits

master
Daniel Kolesa 2016-11-15 22:50:49 +01:00
parent e7c6032edb
commit c450600097
2 changed files with 11 additions and 5 deletions

View File

@ -84,19 +84,19 @@ namespace detail {
}
template<typename T>
static constexpr T NumericLimitMin = detail::NumericLimitsBase<T>::minv;
constexpr T NumericLimitMin = detail::NumericLimitsBase<T>::minv;
template<typename T>
static constexpr T NumericLimitMax = detail::NumericLimitsBase<T>::maxv;
constexpr T NumericLimitMax = detail::NumericLimitsBase<T>::maxv;
template<typename T>
static constexpr T NumericLimitLowest = detail::NumericLimitsBase<T>::lowv;
constexpr T NumericLimitLowest = detail::NumericLimitsBase<T>::lowv;
template<typename T>
static constexpr bool NumericLimitIsSigned = detail::NumericLimitsBase<T>::is_signed;
constexpr bool NumericLimitIsSigned = detail::NumericLimitsBase<T>::is_signed;
template<typename T>
static constexpr bool NumericLimitIsInteger = detail::NumericLimitsBase<T>::is_integer;
constexpr bool NumericLimitIsInteger = detail::NumericLimitsBase<T>::is_integer;
}

View File

@ -7,6 +7,7 @@
#ifndef OSTD_TYPE_TRAITS_HH
#define OSTD_TYPE_TRAITS_HH
#include <limits.h>
#include <stddef.h>
#include "ostd/types.hh"
@ -55,6 +56,11 @@ namespace detail {
AddRvalueReference<T> declval_in() noexcept;
}
/* size in bits */
template<typename T>
constexpr Size SizeInBits = sizeof(T) * CHAR_BIT;
/* integral constant */
template<typename T, T val>