102 lines · plain
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-exception7//8//===---------------------------------------------------------------------===//9 10#ifndef _LIBCPP_BIT11#define _LIBCPP_BIT12 13/*14 bit synopsis15 16namespace std {17 // [bit.cast], bit_cast18 template<class To, class From>19 constexpr To bit_cast(const From& from) noexcept; // C++2020 21 // [bit.byteswap], byteswap22 template<class T>23 constexpr T byteswap(T value) noexcept; // C++2324 25 // [bit.pow.two], integral powers of 226 template <class T>27 constexpr bool has_single_bit(T x) noexcept; // C++2028 template <class T>29 constexpr T bit_ceil(T x); // C++2030 template <class T>31 constexpr T bit_floor(T x) noexcept; // C++2032 template <class T>33 constexpr int bit_width(T x) noexcept; // C++2034 35 // [bit.rotate], rotating36 template<class T>37 constexpr T rotl(T x, int s) noexcept; // C++2038 template<class T>39 constexpr T rotr(T x, int s) noexcept; // C++2040 41 // [bit.count], counting42 template<class T>43 constexpr int countl_zero(T x) noexcept; // C++2044 template<class T>45 constexpr int countl_one(T x) noexcept; // C++2046 template<class T>47 constexpr int countr_zero(T x) noexcept; // C++2048 template<class T>49 constexpr int countr_one(T x) noexcept; // C++2050 template<class T>51 constexpr int popcount(T x) noexcept; // C++2052 53 // [bit.endian], endian54 enum class endian {55 little = see below, // C++2056 big = see below, // C++2057 native = see below // C++2058 };59 60} // namespace std61 62*/63 64#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)65# include <__cxx03/__config>66#else67# include <__config>68 69# if _LIBCPP_STD_VER >= 2070# include <__bit/bit_cast.h>71# include <__bit/bit_ceil.h>72# include <__bit/bit_floor.h>73# include <__bit/bit_log2.h>74# include <__bit/bit_width.h>75# include <__bit/countl.h>76# include <__bit/countr.h>77# include <__bit/endian.h>78# include <__bit/has_single_bit.h>79# include <__bit/popcount.h>80# include <__bit/rotate.h>81# endif82 83# if _LIBCPP_STD_VER >= 2384# include <__bit/byteswap.h>85# endif86 87# include <version>88 89# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)90# pragma GCC system_header91# endif92 93# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 2094# include <cstdlib>95# include <iosfwd>96# include <limits>97# include <type_traits>98# endif99#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)100 101#endif // _LIBCPP_BIT102