2 //===----------------------------------------------------------------------===//
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
8 //===---------------------------------------------------------------------===//
17 // [bit.cast], bit_cast
18 template<class To, class From>
19 constexpr To bit_cast(const From& from) noexcept; // C++20
21 // [bit.byteswap], byteswap
23 constexpr T byteswap(T value) noexcept; // C++23
25 // [bit.pow.two], integral powers of 2
27 constexpr bool has_single_bit(T x) noexcept; // C++20
29 constexpr T bit_ceil(T x); // C++20
31 constexpr T bit_floor(T x) noexcept; // C++20
33 constexpr int bit_width(T x) noexcept; // C++20
35 // [bit.rotate], rotating
37 constexpr T rotl(T x, int s) noexcept; // C++20
39 constexpr T rotr(T x, int s) noexcept; // C++20
41 // [bit.count], counting
43 constexpr int countl_zero(T x) noexcept; // C++20
45 constexpr int countl_one(T x) noexcept; // C++20
47 constexpr int countr_zero(T x) noexcept; // C++20
49 constexpr int countr_one(T x) noexcept; // C++20
51 constexpr int popcount(T x) noexcept; // C++20
53 // [bit.endian], endian
55 little = see below, // C++20
56 big = see below, // C++20
57 native = see below // C++20
64 #include <__cxx03/__config>
66 #if _LIBCPP_STD_VER >= 20
67 # include <__cxx03/__bit/bit_cast.h>
68 # include <__cxx03/__bit/bit_ceil.h>
69 # include <__cxx03/__bit/bit_floor.h>
70 # include <__cxx03/__bit/bit_log2.h>
71 # include <__cxx03/__bit/bit_width.h>
72 # include <__cxx03/__bit/countl.h>
73 # include <__cxx03/__bit/countr.h>
74 # include <__cxx03/__bit/endian.h>
75 # include <__cxx03/__bit/has_single_bit.h>
76 # include <__cxx03/__bit/popcount.h>
77 # include <__cxx03/__bit/rotate.h>
80 #if _LIBCPP_STD_VER >= 23
81 # include <__cxx03/__bit/byteswap.h>
84 #include <__cxx03/version>
86 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
87 # pragma GCC system_header
90 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
91 # include <__cxx03/cstdint>
94 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
95 # include <__cxx03/cstdlib>
96 # include <__cxx03/iosfwd>
97 # include <__cxx03/limits>
98 # include <__cxx03/type_traits>
101 #endif // _LIBCPP_BIT