1 //===-- Analogous to <utility> ----------------------------------*- C++ -*-===//
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
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
>;
24 template <typename T
, int N
> struct make_integer_sequence
{
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
;
40 LIBC_INLINE
constexpr T
&&forward(typename remove_reference
<T
>::type
&value
) {
41 return static_cast<T
&&>(value
);
45 LIBC_INLINE
constexpr T
&&forward(typename remove_reference
<T
>::type
&&value
) {
46 return static_cast<T
&&>(value
);
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