Skip to content

Commit 3ab6912

Browse files
committed
[libc] Add is_object
1 parent 7d7dcc1 commit 3ab6912

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

libc/src/__support/CPP/type_traits.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "src/__support/CPP/type_traits/is_lvalue_reference.h"
3333
#include "src/__support/CPP/type_traits/is_member_pointer.h"
3434
#include "src/__support/CPP/type_traits/is_null_pointer.h"
35+
#include "src/__support/CPP/type_traits/is_object.h"
3536
#include "src/__support/CPP/type_traits/is_pointer.h"
3637
#include "src/__support/CPP/type_traits/is_reference.h"
3738
#include "src/__support/CPP/type_traits/is_rvalue_reference.h"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//===-- is_object 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_OBJECT_H
9+
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H
10+
11+
#include "src/__support/CPP/type_traits/bool_constant.h"
12+
#include "src/__support/CPP/type_traits/is_array.h"
13+
#include "src/__support/CPP/type_traits/is_class.h"
14+
#include "src/__support/CPP/type_traits/is_scalar.h"
15+
#include "src/__support/CPP/type_traits/is_union.h"
16+
#include "src/__support/macros/attributes.h"
17+
18+
namespace __llvm_libc::cpp {
19+
20+
// is_object
21+
template <class T>
22+
struct is_object
23+
: cpp::bool_constant<cpp::is_scalar_v<T> || cpp::is_array_v<T> ||
24+
cpp::is_union_v<T> || cpp::is_class_v<T>> {};
25+
template <class T>
26+
LIBC_INLINE_VAR constexpr bool is_object_v = is_object<T>::value;
27+
28+
} // namespace __llvm_libc::cpp
29+
30+
#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ libc_support_library(
309309
"src/__support/CPP/type_traits/is_lvalue_reference.h",
310310
"src/__support/CPP/type_traits/is_member_pointer.h",
311311
"src/__support/CPP/type_traits/is_null_pointer.h",
312+
"src/__support/CPP/type_traits/is_object.h",
312313
"src/__support/CPP/type_traits/is_pointer.h",
313314
"src/__support/CPP/type_traits/is_reference.h",
314315
"src/__support/CPP/type_traits/is_rvalue_reference.h",

0 commit comments

Comments
 (0)