File indexing completed on 2026-05-03 08:13:08
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___ALGORITHM_HALF_POSITIVE_H
0010 #define _LIBCPP___ALGORITHM_HALF_POSITIVE_H
0011
0012 #include <__config>
0013 #include <__type_traits/enable_if.h>
0014 #include <__type_traits/is_integral.h>
0015 #include <__type_traits/make_unsigned.h>
0016
0017 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0018 # pragma GCC system_header
0019 #endif
0020
0021 _LIBCPP_BEGIN_NAMESPACE_STD
0022
0023
0024
0025 template <typename _Integral, __enable_if_t<is_integral<_Integral>::value, int> = 0>
0026 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Integral __half_positive(_Integral __value) {
0027 return static_cast<_Integral>(static_cast<__make_unsigned_t<_Integral> >(__value) / 2);
0028 }
0029
0030 template <typename _Tp, __enable_if_t<!is_integral<_Tp>::value, int> = 0>
0031 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp __half_positive(_Tp __value) {
0032 return __value / 2;
0033 }
0034
0035 _LIBCPP_END_NAMESPACE_STD
0036
0037 #endif