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_pointer.h>
18 
19 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20 #  pragma GCC system_header
21 #endif
22 
23 _LIBCPP_BEGIN_NAMESPACE_STD
24 
25 #if __has_keyword(__is_scalar)
26 
27 template<class _Tp>
28 struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { };
29 
30 #if _LIBCPP_STD_VER > 14
31 template <class _Tp>
32 inline constexpr bool is_scalar_v = __is_scalar(_Tp);
33 #endif
34 
35 #else // __has_keyword(__is_scalar)
36 
37 template <class _Tp> struct __is_block : false_type {};
38 #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
39 template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {};
40 #endif
41 
42 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar
43     : public integral_constant<bool, is_arithmetic<_Tp>::value     ||
44                                      is_member_pointer<_Tp>::value ||
45                                      is_pointer<_Tp>::value        ||
46                                      __is_nullptr_t<_Tp>::value    ||
47                                      __is_block<_Tp>::value        ||
48                                      is_enum<_Tp>::value           > {};
49 
50 template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
51 
52 #if _LIBCPP_STD_VER > 14
53 template <class _Tp>
54 inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
55 #endif
56 
57 #endif // __has_keyword(__is_scalar)
58 
59 _LIBCPP_END_NAMESPACE_STD
60 
61 #endif // _LIBCPP___TYPE_TRAITS_IS_SCALAR_H
62