[NFC][Py Reformat] Added more commits to .git-blame-ignore-revs
[llvm-project.git] / libc / src / __support / CPP / utility.h
blob40455d5e61f87975523223687002f0c0de99605d
1 //===-- Analogous to <utility> ----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H
10 #define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H
12 #include "src/__support/CPP/type_traits.h"
13 #include "src/__support/macros/attributes.h"
15 namespace __llvm_libc::cpp {
17 template <typename T, T... Ints> struct integer_sequence {
18 static_assert(is_integral_v<T>);
19 template <T Next> using append = integer_sequence<T, Ints..., Next>;
22 namespace internal {
24 template <typename T, int N> struct make_integer_sequence {
25 using type =
26 typename make_integer_sequence<T, N - 1>::type::template append<N>;
29 template <typename T> struct make_integer_sequence<T, -1> {
30 using type = integer_sequence<T>;
33 } // namespace internal
35 template <typename T, int N>
36 using make_integer_sequence =
37 typename internal::make_integer_sequence<T, N - 1>::type;
39 template <typename T>
40 LIBC_INLINE constexpr T &&forward(typename remove_reference<T>::type &value) {
41 return static_cast<T &&>(value);
44 template <typename T>
45 LIBC_INLINE constexpr T &&forward(typename remove_reference<T>::type &&value) {
46 return static_cast<T &&>(value);
49 template <typename T>
50 LIBC_INLINE constexpr typename remove_reference<T>::type &&move(T &&value) {
51 return static_cast<typename remove_reference<T>::type &&>(value);
54 } // namespace __llvm_libc::cpp
56 #endif // LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H