1 //===-- is_class 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_CLASS_H 9 #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H 10 11 #include "src/__support/CPP/type_traits/bool_constant.h" 12 #include "src/__support/CPP/type_traits/false_type.h" 13 #include "src/__support/CPP/type_traits/is_union.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_class 21 namespace detail { 22 template <class T> cpp::bool_constant<!cpp::is_union_v<T>> test(int T::*); 23 template <class> cpp::false_type test(...); 24 } // namespace detail 25 template <class T> struct is_class : decltype(detail::test<T>(nullptr)) {}; 26 template <typename T> 27 LIBC_INLINE_VAR constexpr bool is_class_v = is_class<T>::value; 28 29 } // namespace cpp 30 } // namespace LIBC_NAMESPACE_DECL 31 32 #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H 33