Skip to content

Commit eebf8fa

Browse files
authored
[libc] Add is_member_pointer_v (#65631)
Implementation from https://en.cppreference.com/w/cpp/types/is_member_pointer
1 parent d60c474 commit eebf8fa

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

libc/src/__support/CPP/type_traits.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "src/__support/CPP/type_traits/is_function.h"
3131
#include "src/__support/CPP/type_traits/is_integral.h"
3232
#include "src/__support/CPP/type_traits/is_lvalue_reference.h"
33+
#include "src/__support/CPP/type_traits/is_member_pointer.h"
3334
#include "src/__support/CPP/type_traits/is_null_pointer.h"
3435
#include "src/__support/CPP/type_traits/is_pointer.h"
3536
#include "src/__support/CPP/type_traits/is_reference.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//===-- is_member_pointer 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_MEMBER_POINTER_H
9+
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H
10+
11+
#include "src/__support/CPP/type_traits/false_type.h"
12+
#include "src/__support/CPP/type_traits/remove_cv.h"
13+
#include "src/__support/CPP/type_traits/true_type.h"
14+
#include "src/__support/macros/attributes.h"
15+
16+
namespace __llvm_libc::cpp {
17+
18+
// is_member_pointer
19+
template <class T> struct is_member_pointer_helper : cpp::false_type {};
20+
template <class T, class U>
21+
struct is_member_pointer_helper<T U::*> : cpp::true_type {};
22+
template <class T>
23+
struct is_member_pointer : is_member_pointer_helper<cpp::remove_cv_t<T>> {};
24+
template <class T>
25+
LIBC_INLINE_VAR constexpr bool is_member_pointer_v =
26+
is_member_pointer<T>::value;
27+
28+
} // namespace __llvm_libc::cpp
29+
30+
#endif // LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H

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

+1
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ libc_support_library(
307307
"src/__support/CPP/type_traits/is_function.h",
308308
"src/__support/CPP/type_traits/is_integral.h",
309309
"src/__support/CPP/type_traits/is_lvalue_reference.h",
310+
"src/__support/CPP/type_traits/is_member_pointer.h",
310311
"src/__support/CPP/type_traits/is_null_pointer.h",
311312
"src/__support/CPP/type_traits/is_pointer.h",
312313
"src/__support/CPP/type_traits/is_reference.h",

0 commit comments

Comments
 (0)