aboutsummaryrefslogtreecommitdiff
path: root/libc/src/__support/CPP/type_traits/remove_all_extents.h
blob: 54b36a4c2e5463b07e6652d3175e4fdf0d4339d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//===-- remove_all_extents type_traits --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H

#include "src/__support/CPP/type_traits/type_identity.h"
#include "src/__support/macros/config.h"

#include <stddef.h> // size_t

namespace __llvm_libc::cpp {

// remove_all_extents
#if LIBC_HAS_BUILTIN(__remove_all_extents)
template <typename T> using remove_all_extents_t = __remove_all_extents(T);
template <typename T>
struct remove_all_extents : cpp::type_identity<remove_all_extents_t<T>> {};
#else
template <typename T> struct remove_all_extents {
  using type = T;
};
template <typename T> struct remove_all_extents<T[]> {
  using type = typename remove_all_extents<T>::type;
};
template <typename T, size_t _Np> struct remove_all_extents<T[_Np]> {
  using type = typename remove_all_extents<T>::type;
};
template <typename T>
using remove_all_extents_t = typename remove_all_extents<T>::type;
#endif

} // namespace __llvm_libc::cpp

#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H