29 #ifndef _GLIBCXX_STDCKDINT_H 30 #define _GLIBCXX_STDCKDINT_H 32 #define __glibcxx_want_stdckdint_h 35 #ifdef __cpp_lib_stdckdint_h // C++ >= 26 37 #include <type_traits> 40 #define __STDC_VERSION_STDCKDINT_H__ 202311L 42 #ifndef _GLIBCXX_DOXYGEN 44 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
65 template<
typename _Tp1,
typename _Tp2,
typename _Tp3>
67 ckd_add(_Tp1* __result, _Tp2 __a, _Tp3 __b)
69 static_assert(std::__is_signed_or_unsigned_integer<_Tp1>::value);
70 static_assert(std::__is_signed_or_unsigned_integer<_Tp2>::value);
71 static_assert(std::__is_signed_or_unsigned_integer<_Tp3>::value);
72 return __builtin_add_overflow(__a, __b, __result);
75 template<
typename _Tp1,
typename _Tp2,
typename _Tp3>
77 ckd_sub(_Tp1* __result, _Tp2 __a, _Tp3 __b)
79 static_assert(std::__is_signed_or_unsigned_integer<_Tp1>::value);
80 static_assert(std::__is_signed_or_unsigned_integer<_Tp2>::value);
81 static_assert(std::__is_signed_or_unsigned_integer<_Tp3>::value);
82 return __builtin_sub_overflow(__a, __b, __result);
85 template<
typename _Tp1,
typename _Tp2,
typename _Tp3>
87 ckd_mul(_Tp1* __result, _Tp2 __a, _Tp3 __b)
89 static_assert(std::__is_signed_or_unsigned_integer<_Tp1>::value);
90 static_assert(std::__is_signed_or_unsigned_integer<_Tp2>::value);
91 static_assert(std::__is_signed_or_unsigned_integer<_Tp3>::value);
92 return __builtin_mul_overflow(__a, __b, __result);
95 #ifndef _GLIBCXX_DOXYGEN 98 using __gnu_cxx::ckd_add;
99 using __gnu_cxx::ckd_sub;
100 using __gnu_cxx::ckd_mul;
103 #endif // __cpp_lib_stdckdint_h 105 #endif // _GLIBCXX_STDCKDINT_H GNU extensions for public use.