xref: /llvm-project/libc/src/__support/CPP/type_traits/is_function.h (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1 //===-- is_function type_traits ---------------------------------*- C++ -*-===//
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 #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H
9 #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H
10 
11 #include "src/__support/CPP/type_traits/bool_constant.h"
12 #include "src/__support/CPP/type_traits/is_const.h"
13 #include "src/__support/CPP/type_traits/is_reference.h"
14 #include "src/__support/macros/attributes.h"
15 #include "src/__support/macros/config.h"
16 
17 namespace LIBC_NAMESPACE_DECL {
18 namespace cpp {
19 
20 // is_function
21 #if __has_builtin(__is_function)
22 template <typename T>
23 struct is_function : integral_constant<bool, __is_function(T)> {};
24 #else
25 template <typename T>
26 struct is_function
27     : public bool_constant<!(is_reference_v<T> || is_const_v<const T>)> {};
28 #endif
29 template <class T>
30 LIBC_INLINE_VAR constexpr bool is_function_v = is_function<T>::value;
31 
32 } // namespace cpp
33 } // namespace LIBC_NAMESPACE_DECL
34 
35 #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H
36