File tree Expand file tree Collapse file tree 4 files changed +50
-40
lines changed
compiler-rt/lib/scudo/standalone Expand file tree Collapse file tree 4 files changed +50
-40
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ set(SCUDO_HEADERS
9898 tsd_exclusive.h
9999 tsd_shared.h
100100 tsd.h
101+ type_traits.h
101102 vector.h
102103 wrappers_c_checks.h
103104 wrappers_c.h
Original file line number Diff line number Diff line change 1212#include " condition_variable.h"
1313#include " internal_defs.h"
1414#include " secondary.h"
15-
16- namespace {
17-
18- template <typename T> struct removeConst {
19- using type = T;
20- };
21- template <typename T> struct removeConst <const T> {
22- using type = T;
23- };
24-
25- // This is only used for SFINAE when detecting if a type is defined.
26- template <typename T> struct voidAdaptor {
27- using type = void ;
28- };
29-
30- // This is used for detecting the case that defines the flag with wrong type and
31- // it'll be viewed as undefined optional flag.
32- template <typename L, typename R> struct assertSameType {
33- template <typename , typename > struct isSame {
34- static constexpr bool value = false ;
35- };
36- template <typename T> struct isSame <T, T> {
37- static constexpr bool value = true ;
38- };
39- static_assert (isSame<L, R>::value, " Flag type mismatches" );
40- using type = R;
41- };
42-
43- } // namespace
15+ #include " type_traits.h"
4416
4517namespace scudo {
4618
Original file line number Diff line number Diff line change 1010#define SCUDO_LIST_H_
1111
1212#include " internal_defs.h"
13-
14- // TODO: Move the helpers to a header.
15- namespace {
16- template <typename T> struct isPointer {
17- static constexpr bool value = false ;
18- };
19-
20- template <typename T> struct isPointer <T *> {
21- static constexpr bool value = true ;
22- };
23- } // namespace
13+ #include " type_traits.h"
2414
2515namespace scudo {
2616
Original file line number Diff line number Diff line change 1+ // ===-- type_traits.h -------------------------------------------*- 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+
9+ #ifndef SCUDO_TYPE_TRAITS_H_
10+ #define SCUDO_TYPE_TRAITS_H_
11+
12+ namespace scudo {
13+
14+ template <typename T> struct removeConst {
15+ using type = T;
16+ };
17+ template <typename T> struct removeConst <const T> {
18+ using type = T;
19+ };
20+
21+ // This is only used for SFINAE when detecting if a type is defined.
22+ template <typename T> struct voidAdaptor {
23+ using type = void ;
24+ };
25+
26+ template <typename L, typename R> struct assertSameType {
27+ template <typename , typename > struct isSame {
28+ static constexpr bool value = false ;
29+ };
30+ template <typename T> struct isSame <T, T> {
31+ static constexpr bool value = true ;
32+ };
33+ static_assert (isSame<L, R>::value, " Type mismatches" );
34+ using type = R;
35+ };
36+
37+ template <typename T> struct isPointer {
38+ static constexpr bool value = false ;
39+ };
40+
41+ template <typename T> struct isPointer <T *> {
42+ static constexpr bool value = true ;
43+ };
44+
45+ } // namespace scudo
46+
47+ #endif // SCUDO_TYPE_TRAITS_H_
You can’t perform that action at this time.
0 commit comments