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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___TYPE_TRAITS_IS_SCALAR_H 10 #define _LIBCPP___TYPE_TRAITS_IS_SCALAR_H 11 12 #include <__config> 13 #include <__type_traits/integral_constant.h> 14 #include <__type_traits/is_arithmetic.h> 15 #include <__type_traits/is_enum.h> 16 #include <__type_traits/is_member_pointer.h> 17 #include <__type_traits/is_null_pointer.h> 18 #include <__type_traits/is_pointer.h> 19 20 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 21 # pragma GCC system_header 22 #endif 23 24 _LIBCPP_BEGIN_NAMESPACE_STD 25 26 #if __has_builtin(__is_scalar) 27 28 template <class _Tp> 29 struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> {}; 30 31 # if _LIBCPP_STD_VER >= 17 32 template <class _Tp> 33 inline constexpr bool is_scalar_v = __is_scalar(_Tp); 34 # endif 35 36 #else // __has_builtin(__is_scalar) 37 38 template <class _Tp> 39 struct __is_block : false_type {}; 40 # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) 41 template <class _Rp, class... _Args> 42 struct __is_block<_Rp (^)(_Args...)> : true_type {}; 43 # endif 44 45 // clang-format off 46 template <class _Tp> 47 struct _LIBCPP_TEMPLATE_VIS is_scalar 48 : public integral_constant< 49 bool, is_arithmetic<_Tp>::value || 50 is_member_pointer<_Tp>::value || 51 is_pointer<_Tp>::value || 52 __is_nullptr_t<_Tp>::value || 53 __is_block<_Tp>::value || 54 is_enum<_Tp>::value> {}; 55 // clang-format on 56 57 template <> 58 struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; 59 60 # if _LIBCPP_STD_VER >= 17 61 template <class _Tp> 62 inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; 63 # endif 64 65 #endif // __has_builtin(__is_scalar) 66 67 _LIBCPP_END_NAMESPACE_STD 68 69 #endif // _LIBCPP___TYPE_TRAITS_IS_SCALAR_H 70