# type\_traits

***

1. **Check if a type is signed:**

```cpp
#include <type_traits>

template <typename T>
struct is_signed : std::integral_constant<bool, std::is_signed<T>::value> {};

static_assert(is_signed<int>::value);
static_assert(!is_signed<unsigned int>::value);
```

2. **Check if a type is floating-point:**

```cpp
#include <type_traits>

template <typename T>
struct is_floating_point : std::integral_constant<bool, std::is_floating_point<T>::value> {};

static_assert(is_floating_point<float>::value);
static_assert(!is_floating_point<int>::value);
```

3. **Check if a type is a fundamental type:**

```cpp
#include <type_traits>

template <typename T>
struct is_fundamental : std::integral_constant<bool, std::is_fundamental<T>::value> {};

static_assert(is_fundamental<int>::value);
static_assert(!is_fundamental<std::string>::value);
```

4. **Check if a type is a pointer:**

```cpp
#include <type_traits>

template <typename T>
struct is_pointer : std::integral_constant<bool, std::is_pointer<T>::value> {};

static_assert(is_pointer<int*>::value);
static_assert(!is_pointer<int>::value);
```

5. **Check if a type is a reference:**

```cpp
#include <type_traits>

template <typename T>
struct is_reference : std::integral_constant<bool, std::is_reference<T>::value> {};

static_assert(is_reference<int&>::value);
static_assert(!is_reference<int>::value);
```

6. **Check if a type is an array:**

```cpp
#include <type_traits>

template <typename T>
struct is_array : std::integral_constant<bool, std::is_array<T>::value> {};

static_assert(is_array<int[10]>::value);
static_assert(!is_array<int>::value);
```

7. **Check if a type is a function:**

```cpp
#include <type_traits>

template <typename T>
struct is_function : std::integral_constant<bool, std::is_function<T>::value> {};

static_assert(is_function<int(int)>::value);
static_assert(!is_function<int>::value);
```

8. **Check if a type is a class:**

```cpp
#include <type_traits>

template <typename T>
struct is_class : std::integral_constant<bool, std::is_class<T>::value> {};

static_assert(is_class<std::string>::value);
static_assert(!is_class<int>::value);
```

9. **Check if a type is a structure:**

```cpp
#include <type_traits>

template <typename T>
struct is_struct : std::integral_constant<bool, std::is_struct<T>::value> {};

static_assert(is_struct<std::pair<int, int>>::value);
static_assert(!is_struct<int>::value);
```

10. **Check if a type is an enumeration:**

```cpp
#include <type_traits>

template <typename T>
struct is_enum : std::integral_constant<bool, std::is_enum<T>::value> {};

static_assert(is_enum<enum class Color { Red, Green, Blue }>::value);
static_assert(!is_enum<int>::value);
```

11. **Check if a type is a union:**

```cpp
#include <type_traits>

template <typename T>
struct is_union : std::integral_constant<bool, std::is_union<T>::value> {};

static_assert(is_union<union { int a; float b; }>::value);
static_assert(!is_union<int>::value);
```

12. **Get the size of a type in bytes:**

```cpp
#include <type_traits>

template <typename T>
struct type_size : std::integral_constant<size_t, sizeof(T)> {};

static_assert(type_size<int>::value == 4);
```

13. **Get the alignment of a type in bytes:**

```cpp
#include <type_traits>

template <typename T>
struct type_alignment : std::integral_constant<size_t, alignof(T)> {};

static_assert(type_alignment<int>::value == 4);
```

14. **Check if a type is a const-qualified type:**

```cpp
#include <type_traits>

template <typename T>
struct is_const : std::integral_constant<bool, std::is_const<T>::value> {};

static_assert(is_const<const int>::value);
static_assert(!is_const<int>::value);
```

15. **Check if a type is a volatile-qualified type:**

```cpp
#include <type_traits>

template <typename T>
struct is_volatile : std::integral_constant<bool, std::is_volatile<T>::value> {};

static_assert(is_volatile<volatile int>::value);
static_assert(!is_volatile<int>::value);
```

16. **Check if a type is a const-volatile-qualified type:**

```cpp
#include <type_traits>

template <typename T>
struct is_const_volatile : std::integral_constant<bool, std::is_const_volatile<T>::value> {};

static_assert(is_const_volatile<const volatile int>::value);
static_assert(!is_const_volatile<int>::value);
```

17. **Get the underlying type of a pointer or reference type:**

```cpp
#include <type_traits>

template <typename T>
struct underlying_type : std::remove_reference<std::remove

```
