/proc/self/cwd/internal/manual.h
Line | Count | Source |
1 | | // Copyright 2025 Google LLC |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // https://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #ifndef THIRD_PARTY_CEL_CPP_INTERNAL_MANUAL_H_ |
16 | | #define THIRD_PARTY_CEL_CPP_INTERNAL_MANUAL_H_ |
17 | | |
18 | | #include <new> |
19 | | #include <type_traits> |
20 | | |
21 | | #include "absl/base/attributes.h" |
22 | | #include "absl/base/nullability.h" |
23 | | |
24 | | namespace cel::internal { |
25 | | |
26 | | template <typename T> |
27 | | class Manual final { |
28 | | public: |
29 | | static_assert(!std::is_reference_v<T>, "T must not be a reference"); |
30 | | static_assert(!std::is_array_v<T>, "T must not be an array"); |
31 | | static_assert(!std::is_const_v<T>, "T must not be const qualified"); |
32 | | static_assert(!std::is_volatile_v<T>, "T must not be volatile qualified"); |
33 | | |
34 | | using element_type = T; |
35 | | |
36 | | Manual() = default; |
37 | | |
38 | | Manual(const Manual&) = delete; |
39 | | Manual(Manual&&) = delete; |
40 | | |
41 | | ~Manual() = default; |
42 | | |
43 | | Manual& operator=(const Manual&) = delete; |
44 | | Manual& operator=(Manual&&) = delete; |
45 | | |
46 | 316k | constexpr T* absl_nonnull get() ABSL_ATTRIBUTE_LIFETIME_BOUND { |
47 | 316k | return std::launder(reinterpret_cast<T*>(&storage_[0])); |
48 | 316k | } cel::internal::Manual<std::__1::vector<cel::Value, cel::ArenaAllocator<cel::Value> > >::get() Line | Count | Source | 46 | 285k | constexpr T* absl_nonnull get() ABSL_ATTRIBUTE_LIFETIME_BOUND { | 47 | 285k | return std::launder(reinterpret_cast<T*>(&storage_[0])); | 48 | 285k | } |
value_builder.cc:cel::internal::Manual<absl::lts_20260107::flat_hash_map<cel::Value, cel::Value, cel::common_internal::(anonymous namespace)::ValueHasher, cel::common_internal::(anonymous namespace)::ValueEqualer, cel::ArenaAllocator<std::__1::pair<cel::Value const, cel::Value> > > >::get() Line | Count | Source | 46 | 30.9k | constexpr T* absl_nonnull get() ABSL_ATTRIBUTE_LIFETIME_BOUND { | 47 | 30.9k | return std::launder(reinterpret_cast<T*>(&storage_[0])); | 48 | 30.9k | } |
|
49 | | |
50 | 0 | constexpr const T* absl_nonnull get() const ABSL_ATTRIBUTE_LIFETIME_BOUND { |
51 | 0 | return std::launder(reinterpret_cast<const T*>(&storage_[0])); |
52 | 0 | } Unexecuted instantiation: cel::internal::Manual<std::__1::vector<cel::Value, cel::ArenaAllocator<cel::Value> > >::get() const Unexecuted instantiation: value_builder.cc:cel::internal::Manual<absl::lts_20260107::flat_hash_map<cel::Value, cel::Value, cel::common_internal::(anonymous namespace)::ValueHasher, cel::common_internal::(anonymous namespace)::ValueEqualer, cel::ArenaAllocator<std::__1::pair<cel::Value const, cel::Value> > > >::get() const |
53 | | |
54 | 11.4k | constexpr T& operator*() ABSL_ATTRIBUTE_LIFETIME_BOUND { return *get(); }cel::internal::Manual<std::__1::vector<cel::Value, cel::ArenaAllocator<cel::Value> > >::operator*() Line | Count | Source | 54 | 9.51k | constexpr T& operator*() ABSL_ATTRIBUTE_LIFETIME_BOUND { return *get(); } |
value_builder.cc:cel::internal::Manual<absl::lts_20260107::flat_hash_map<cel::Value, cel::Value, cel::common_internal::(anonymous namespace)::ValueHasher, cel::common_internal::(anonymous namespace)::ValueEqualer, cel::ArenaAllocator<std::__1::pair<cel::Value const, cel::Value> > > >::operator*() Line | Count | Source | 54 | 1.97k | constexpr T& operator*() ABSL_ATTRIBUTE_LIFETIME_BOUND { return *get(); } |
|
55 | | |
56 | | constexpr const T& operator*() const ABSL_ATTRIBUTE_LIFETIME_BOUND { |
57 | | return *get(); |
58 | | } |
59 | | |
60 | 305k | constexpr T* absl_nonnull operator->() ABSL_ATTRIBUTE_LIFETIME_BOUND { |
61 | 305k | return get(); |
62 | 305k | } cel::internal::Manual<std::__1::vector<cel::Value, cel::ArenaAllocator<cel::Value> > >::operator->() Line | Count | Source | 60 | 276k | constexpr T* absl_nonnull operator->() ABSL_ATTRIBUTE_LIFETIME_BOUND { | 61 | 276k | return get(); | 62 | 276k | } |
value_builder.cc:cel::internal::Manual<absl::lts_20260107::flat_hash_map<cel::Value, cel::Value, cel::common_internal::(anonymous namespace)::ValueHasher, cel::common_internal::(anonymous namespace)::ValueEqualer, cel::ArenaAllocator<std::__1::pair<cel::Value const, cel::Value> > > >::operator->() Line | Count | Source | 60 | 28.9k | constexpr T* absl_nonnull operator->() ABSL_ATTRIBUTE_LIFETIME_BOUND { | 61 | 28.9k | return get(); | 62 | 28.9k | } |
|
63 | | |
64 | | constexpr const T* absl_nonnull operator->() const |
65 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
66 | 0 | return get(); |
67 | 0 | } Unexecuted instantiation: cel::internal::Manual<std::__1::vector<cel::Value, cel::ArenaAllocator<cel::Value> > >::operator->() const Unexecuted instantiation: value_builder.cc:cel::internal::Manual<absl::lts_20260107::flat_hash_map<cel::Value, cel::Value, cel::common_internal::(anonymous namespace)::ValueHasher, cel::common_internal::(anonymous namespace)::ValueEqualer, cel::ArenaAllocator<std::__1::pair<cel::Value const, cel::Value> > > >::operator->() const |
68 | | |
69 | | template <typename... Args> |
70 | 19.5k | T* absl_nonnull Construct(Args&&... args) ABSL_ATTRIBUTE_LIFETIME_BOUND { |
71 | 19.5k | return ::new (static_cast<void*>(&storage_[0])) |
72 | 19.5k | T(std::forward<Args>(args)...); |
73 | 19.5k | } std::__1::vector<cel::Value, cel::ArenaAllocator<cel::Value> >* cel::internal::Manual<std::__1::vector<cel::Value, cel::ArenaAllocator<cel::Value> > >::Construct<google::protobuf::Arena*&>(google::protobuf::Arena*&) Line | Count | Source | 70 | 11.2k | T* absl_nonnull Construct(Args&&... args) ABSL_ATTRIBUTE_LIFETIME_BOUND { | 71 | 11.2k | return ::new (static_cast<void*>(&storage_[0])) | 72 | 11.2k | T(std::forward<Args>(args)...); | 73 | 11.2k | } |
value_builder.cc:absl::lts_20260107::flat_hash_map<cel::Value, cel::Value, cel::common_internal::(anonymous namespace)::ValueHasher, cel::common_internal::(anonymous namespace)::ValueEqualer, cel::ArenaAllocator<std::__1::pair<cel::Value const, cel::Value> > >* cel::internal::Manual<absl::lts_20260107::flat_hash_map<cel::Value, cel::Value, cel::common_internal::(anonymous namespace)::ValueHasher, cel::common_internal::(anonymous namespace)::ValueEqualer, cel::ArenaAllocator<std::__1::pair<cel::Value const, cel::Value> > > >::Construct<google::protobuf::Arena* const&>(google::protobuf::Arena* const&) Line | Count | Source | 70 | 8.29k | T* absl_nonnull Construct(Args&&... args) ABSL_ATTRIBUTE_LIFETIME_BOUND { | 71 | 8.29k | return ::new (static_cast<void*>(&storage_[0])) | 72 | 8.29k | T(std::forward<Args>(args)...); | 73 | 8.29k | } |
|
74 | | |
75 | | T* absl_nonnull DefaultConstruct() { |
76 | | return ::new (static_cast<void*>(&storage_[0])) T; |
77 | | } |
78 | | |
79 | | T* absl_nonnull ValueConstruct() { |
80 | | return ::new (static_cast<void*>(&storage_[0])) T(); |
81 | | } |
82 | | |
83 | 33 | void Destruct() { get()->~T(); }Unexecuted instantiation: cel::internal::Manual<std::__1::vector<cel::Value, cel::ArenaAllocator<cel::Value> > >::Destruct() value_builder.cc:cel::internal::Manual<absl::lts_20260107::flat_hash_map<cel::Value, cel::Value, cel::common_internal::(anonymous namespace)::ValueHasher, cel::common_internal::(anonymous namespace)::ValueEqualer, cel::ArenaAllocator<std::__1::pair<cel::Value const, cel::Value> > > >::Destruct() Line | Count | Source | 83 | 33 | void Destruct() { get()->~T(); } |
|
84 | | |
85 | | private: |
86 | | alignas(T) char storage_[sizeof(T)]; |
87 | | }; |
88 | | |
89 | | } // namespace cel::internal |
90 | | |
91 | | #endif // THIRD_PARTY_CEL_CPP_INTERNAL_MANUAL_H_ |