Phi
decay.hpp
1 #ifndef INCG_PHI_CORE_TYPE_TRAITS_DECAY_HPP
2 #define INCG_PHI_CORE_TYPE_TRAITS_DECAY_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/intrinsics/decay.hpp"
11 
12 #if PHI_SUPPORTS_DECAY()
13 
14 DETAIL_PHI_BEGIN_NAMESPACE()
15 
16 template <typename TypeT>
17 struct decay
18 {
19  using type = PHI_DECAY(TypeT);
20 };
21 
22 template <typename TypeT>
23 using decay_t = PHI_DECAY(TypeT);
24 
25 #else
26 
27 # include "phi/type_traits/add_pointer.hpp"
28 # include "phi/type_traits/conditional.hpp"
29 # include "phi/type_traits/is_array.hpp"
30 # include "phi/type_traits/is_function.hpp"
31 # include "phi/type_traits/is_referenceable.hpp"
32 # include "phi/type_traits/remove_cv.hpp"
33 # include "phi/type_traits/remove_extent.hpp"
34 
35 DETAIL_PHI_BEGIN_NAMESPACE()
36 
37 namespace detail
38 {
39  template <typename TypeT, bool>
40  struct decay_impl
41  {
42  using type = remove_cv_t<TypeT>;
43  };
44 
45  template <typename TypeT>
46  struct decay_impl<TypeT, true>
47  {
48  public:
49  using type = conditional_t<
50  is_array<TypeT>::value, remove_extent_t<TypeT>*,
51  conditional_t<is_function<TypeT>::value, add_pointer_t<TypeT>, remove_cv_t<TypeT>>>;
52  };
53 } // namespace detail
54 
55 template <typename TypeT>
56 struct decay
57 {
58 private:
59  using NoRefT = typename remove_reference<TypeT>::type;
60 
61 public:
63 };
64 
65 template <typename TypeT>
66 using decay_t = typename decay<TypeT>::type;
67 
68 #endif
69 
70 DETAIL_PHI_END_NAMESPACE()
71 
72 #endif // INCG_PHI_CORE_TYPE_TRAITS_DECAY_HPP
Definition: is_array.hpp:21
Definition: decay.hpp:56
Definition: swap.hpp:23
Definition: decay.hpp:40