3#ifndef poplar_TypeTraits_hpp
4#define poplar_TypeTraits_hpp
30 template <
typename T>
static TypeTraits make();
35 template <
typename T>
static constexpr bool isSimpleType();
37 template <
typename T>
static constexpr bool requiresMetadata();
39 bool isSimpleType()
const {
return isIntegral || isFloat; }
42template <
typename T>
TypeTraits TypeTraits::make() {
45 t.align = std::alignment_of<T>::value;
46 t.isIntegral = std::is_integral<T>::value;
47 t.isFloat = std::is_floating_point<T>::value;
48 t.isSigned = std::is_signed<T>::value;
52template <>
inline TypeTraits TypeTraits::make<IeeeHalf>() {
54 t.size =
sizeof(uint16_t);
55 t.align = std::alignment_of<uint16_t>::value;
62template <>
inline TypeTraits TypeTraits::make<Quarter>() {
64 t.size =
sizeof(uint8_t);
65 t.align = std::alignment_of<uint8_t>::value;
73 return std::is_integral<T>::value || std::is_floating_point<T>::value;
76template <>
constexpr bool TypeTraits::isSimpleType<IeeeHalf>() {
return true; }
78template <>
constexpr bool TypeTraits::isSimpleType<Quarter>() {
return true; }
80template <
typename T>
constexpr bool TypeTraits::requiresMetadata() {
84template <>
constexpr bool TypeTraits::requiresMetadata<Quarter>() {
Poplar classes and functions.
Definition: ArrayRef.hpp:14
A structure to provide information about arithmetic (integer and floating point) types.
Definition: TypeTraits.hpp:22
static constexpr bool isSimpleType()
Test if argument is a basic numeric type.
Definition: TypeTraits.hpp:72