-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathhandle.h
More file actions
75 lines (59 loc) · 2.45 KB
/
Copy pathhandle.h
File metadata and controls
75 lines (59 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// IWYU pragma: private, include "base/handle.h"
#ifndef THIRD_PARTY_CEL_CPP_BASE_INTERNAL_HANDLE_PRE_H_
#define THIRD_PARTY_CEL_CPP_BASE_INTERNAL_HANDLE_PRE_H_
#include <type_traits>
#include "base/internal/data.h"
namespace cel::base_internal {
template <typename T, typename = void>
struct HandleTraits;
template <typename T>
struct HandleFactory;
// Non-virtual base class enforces type requirements via static_asserts for
// types used with handles.
template <typename T>
struct HandlePolicy {
static_assert(!std::is_reference_v<T>, "Handles do not support references");
static_assert(!std::is_pointer_v<T>, "Handles do not support pointers");
static_assert(std::is_class_v<T>, "Handles only support classes");
static_assert(!std::is_volatile_v<T>, "Handles do not support volatile");
static_assert(!std::is_const_v<T>, "Handles do not support const");
static_assert(IsDerivedDataV<T>, "Handles do not support this type");
};
// Tag type used to select the correct Handle constructor for constructing
// inline data.
template <typename F>
struct InPlaceStoredInline {
explicit InPlaceStoredInline() = default;
};
template <typename F>
inline constexpr InPlaceStoredInline<F> kInPlaceStoredInline =
InPlaceStoredInline<F>{};
// Tag type used to select the correct Handle constructor for constructing
// from reference counted data.
struct InPlaceReferenceCounted {
explicit InPlaceReferenceCounted() = default;
};
inline constexpr InPlaceReferenceCounted kInPlaceReferenceCounted =
InPlaceReferenceCounted{};
// Tag type used to select the correct Handle constructor for constructing
// from arena allocated data.
struct InPlaceArenaAllocated {
explicit InPlaceArenaAllocated() = default;
};
inline constexpr InPlaceArenaAllocated kInPlaceArenaAllocated =
InPlaceArenaAllocated{};
} // namespace cel::base_internal
#endif // THIRD_PARTY_CEL_CPP_BASE_INTERNAL_HANDLE_PRE_H_