Phi
is_array.hpp
1 #ifndef INCG_PHI_CORE_TYPE_TRAITS_IS_ARRAY_HPP
2 #define INCG_PHI_CORE_TYPE_TRAITS_IS_ARRAY_HPP
3 
4 #include "phi/phi_config.hpp"
5 
6 #if PHI_HAS_EXTENSION_PRAGMA_ONCE()
7 # pragma once
8 #endif
9 
10 #include "phi/compiler_support/constexpr.hpp"
11 #include "phi/compiler_support/inline_variables.hpp"
12 #include "phi/core/size_t.hpp"
13 #include "phi/type_traits/integral_constant.hpp"
14 
15 // NOTE: We're no longer implementing `is_array` using the intrinsic `PHI_IS_ARRAY` due to its inconsistent and unwanted behavior regard zero sized arrays. Keep in mind that zero sized arrays themselves are an extension and according to the standard are malformed.
16 // See this LLVM issue for some more info: https://github.com/llvm/llvm-project/issues/54705
17 
18 DETAIL_PHI_BEGIN_NAMESPACE()
19 
20 template <typename TypeT>
21 struct is_array : public false_type
22 {};
23 
24 template <typename TypeT>
25 struct is_array<TypeT[]> : public true_type
26 {};
27 
28 template <typename TypeT, size_t Size>
29 struct is_array<TypeT[Size]> : public true_type
30 {};
31 
32 template <typename TypeT>
33 struct is_not_array : public integral_constant<bool, !is_array<TypeT>::value>
34 {};
35 
36 #if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
37 
38 template <typename TypeT>
39 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_array_v = is_array<TypeT>::value;
40 
41 template <typename TypeT>
42 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_array_v = is_not_array<TypeT>::value;
43 
44 #endif
45 
46 DETAIL_PHI_END_NAMESPACE()
47 
48 #endif // INCG_PHI_CORE_TYPE_TRAITS_IS_ARRAY_HPP
Definition: integral_constant.hpp:19
Definition: is_array.hpp:21
Definition: is_array.hpp:33