brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · d104c8e Raw
43 lines · c
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___BIT_POPCOUNT_H10#define _LIBCPP___BIT_POPCOUNT_H11 12#include <__config>13#include <__type_traits/integer_traits.h>14 15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#  pragma GCC system_header17#endif18 19_LIBCPP_PUSH_MACROS20#include <__undef_macros>21 22_LIBCPP_BEGIN_NAMESPACE_STD23 24template <class _Tp>25[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __popcount(_Tp __t) _NOEXCEPT {26  return __builtin_popcountg(__t);27}28 29#if _LIBCPP_STD_VER >= 2030 31template <__unsigned_integer _Tp>32[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {33  return std::__popcount(__t);34}35 36#endif37 38_LIBCPP_END_NAMESPACE_STD39 40_LIBCPP_POP_MACROS41 42#endif // _LIBCPP___BIT_POPCOUNT_H43