1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===---------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_BIT
11#define _LIBCPP_BIT
12
13/*
14 bit synopsis
15
16namespace std {
17 // [bit.cast], bit_cast
18 template<class To, class From>
19 constexpr To bit_cast(const From& from) noexcept; // C++20
20
21 // [bit.byteswap], byteswap
22 template<class T>
23 constexpr T byteswap(T value) noexcept; // C++23
24
25 // [bit.pow.two], integral powers of 2
26 template <class T>
27 constexpr bool has_single_bit(T x) noexcept; // C++20
28 template <class T>
29 constexpr T bit_ceil(T x); // C++20
30 template <class T>
31 constexpr T bit_floor(T x) noexcept; // C++20
32 template <class T>
33 constexpr int bit_width(T x) noexcept; // C++20
34
35 // [bit.shift], shifting
36 template<class T, class S>
37 constexpr T shl(T x, S s) noexcept; // C++29
38 template<class T, class S>
39 constexpr T shr(T x, S s) noexcept; // C++29
40
41 // [bit.rotate], rotating
42 template<class T>
43 constexpr T rotl(T x, int s) noexcept; // C++20
44 template<class T>
45 constexpr T rotr(T x, int s) noexcept; // C++20
46
47 // [bit.count], counting
48 template<class T>
49 constexpr int countl_zero(T x) noexcept; // C++20
50 template<class T>
51 constexpr int countl_one(T x) noexcept; // C++20
52 template<class T>
53 constexpr int countr_zero(T x) noexcept; // C++20
54 template<class T>
55 constexpr int countr_one(T x) noexcept; // C++20
56 template<class T>
57 constexpr int popcount(T x) noexcept; // C++20
58
59 // [bit.endian], endian
60 enum class endian {
61 little = see below, // C++20
62 big = see below, // C++20
63 native = see below // C++20
64 };
65
66} // namespace std
67
68*/
69
70#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
71# include <__cxx03/__config>
72#else
73# include <__config>
74
75# if _LIBCPP_STD_VER >= 20
76# include <__bit/bit_cast.h>
77# include <__bit/bit_ceil.h>
78# include <__bit/bit_floor.h>
79# include <__bit/bit_log2.h>
80# include <__bit/bit_width.h>
81# include <__bit/countl.h>
82# include <__bit/countr.h>
83# include <__bit/endian.h>
84# include <__bit/has_single_bit.h>
85# include <__bit/popcount.h>
86# include <__bit/rotate.h>
87# endif
88
89# if _LIBCPP_STD_VER >= 23
90# include <__bit/byteswap.h>
91# endif
92
93# if _LIBCPP_STD_VER >= 29
94# include <__bit/shift.h>
95# endif
96
97# include <version>
98
99# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
100# pragma GCC system_header
101# endif
102
103#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
104
105#endif // _LIBCPP_BIT
106