Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
TypeTraits.h
Go to the documentation of this file.
1#ifndef PROTEUS_FRONTEND_TYPETRAITS_H
2#define PROTEUS_FRONTEND_TYPETRAITS_H
3
4#include <type_traits>
5
6namespace proteus {
7
8// Type alias to remove cv-qualifiers and references (C++17 equivalent of
9// C++20's std::remove_cvref_t).
10template <typename T>
11using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
12
13// NOLINTBEGIN(readability-identifier-naming)
14
15// True if T (after removing references) is an arithmetic type.
16template <typename T>
17inline constexpr bool is_arithmetic_unref_v =
18 std::is_arithmetic_v<std::remove_reference_t<T>>;
19
20// True if T (after removing references) is a pointer type.
21template <typename T>
22inline constexpr bool is_pointer_unref_v =
23 std::is_pointer_v<std::remove_reference_t<T>>;
24
25// True if T is a scalar arithmetic type (not a pointer or array).
26// Used for the primary Var specialization for numeric types.
27template <typename T>
28inline constexpr bool is_scalar_arithmetic_v =
29 std::is_arithmetic_v<std::remove_reference_t<T>> &&
30 !std::is_pointer_v<std::remove_reference_t<T>> &&
31 !std::is_array_v<std::remove_reference_t<T>>;
32
33// True if T (after removing cv-qualifiers and references) is mutable.
34template <typename T>
35inline constexpr bool is_mutable_v =
36 !std::is_const_v<std::remove_reference_t<T>>;
37
38// NOLINTEND(readability-identifier-naming)
39
40} // namespace proteus
41
42#endif // PROTEUS_FRONTEND_TYPETRAITS_H
Definition MemoryCache.h:26
std::remove_cv_t< std::remove_reference_t< T > > remove_cvref_t
Definition TypeTraits.h:11
constexpr bool is_arithmetic_unref_v
Definition TypeTraits.h:17
constexpr bool is_scalar_arithmetic_v
Definition TypeTraits.h:28
constexpr bool is_pointer_unref_v
Definition TypeTraits.h:22
constexpr bool is_mutable_v
Definition TypeTraits.h:35