Coverage Report

Created: 2026-11-24 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/proc/self/cwd/common/values/map_value_variant.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_COMMON_VALUES_MAP_VALUE_VARIANT_H_
16
#define THIRD_PARTY_CEL_CPP_COMMON_VALUES_MAP_VALUE_VARIANT_H_
17
18
#include <cstddef>
19
#include <cstdint>
20
#include <type_traits>
21
22
#include "absl/base/attributes.h"
23
#include "absl/base/nullability.h"
24
#include "absl/log/absl_check.h"
25
#include "absl/meta/type_traits.h"
26
#include "absl/utility/utility.h"
27
#include "common/values/custom_map_value.h"
28
#include "common/values/legacy_map_value.h"
29
#include "common/values/parsed_json_map_value.h"
30
#include "common/values/parsed_map_field_value.h"
31
32
namespace cel::common_internal {
33
34
enum class MapValueIndex : uint16_t {
35
  kCustom = 0,
36
  kParsedField,
37
  kParsedJson,
38
  kLegacy,
39
};
40
41
template <typename T>
42
struct MapValueAlternative;
43
44
template <>
45
struct MapValueAlternative<CustomMapValue> {
46
  static constexpr MapValueIndex kIndex = MapValueIndex::kCustom;
47
};
48
49
template <>
50
struct MapValueAlternative<ParsedMapFieldValue> {
51
  static constexpr MapValueIndex kIndex = MapValueIndex::kParsedField;
52
};
53
54
template <>
55
struct MapValueAlternative<ParsedJsonMapValue> {
56
  static constexpr MapValueIndex kIndex = MapValueIndex::kParsedJson;
57
};
58
59
template <>
60
struct MapValueAlternative<LegacyMapValue> {
61
  static constexpr MapValueIndex kIndex = MapValueIndex::kLegacy;
62
};
63
64
template <typename T, typename = void>
65
struct IsMapValueAlternative : std::false_type {};
66
67
template <typename T>
68
struct IsMapValueAlternative<T, std::void_t<decltype(MapValueAlternative<T>{})>>
69
    : std::true_type {};
70
71
template <typename T>
72
inline constexpr bool IsMapValueAlternativeV = IsMapValueAlternative<T>::value;
73
74
inline constexpr size_t kMapValueVariantAlign = 8;
75
inline constexpr size_t kMapValueVariantSize = 24;
76
77
// MapValueVariant is a subset of alternatives from the main ValueVariant that
78
// is only maps. It is not stored directly in ValueVariant.
79
class alignas(kMapValueVariantAlign) MapValueVariant final {
80
 public:
81
354k
  MapValueVariant() : MapValueVariant(absl::in_place_type<CustomMapValue>) {}
82
83
  MapValueVariant(const MapValueVariant&) = default;
84
  MapValueVariant(MapValueVariant&&) = default;
85
  MapValueVariant& operator=(const MapValueVariant&) = default;
86
  MapValueVariant& operator=(MapValueVariant&&) = default;
87
88
  template <typename T, typename... Args>
89
  explicit MapValueVariant(absl::in_place_type_t<T>, Args&&... args)
90
1.26M
      : index_(MapValueAlternative<T>::kIndex) {
91
1.26M
    static_assert(alignof(T) <= kMapValueVariantAlign);
92
1.26M
    static_assert(sizeof(T) <= kMapValueVariantSize);
93
1.26M
    static_assert(std::is_trivially_copyable_v<T>);
94
95
1.26M
    ::new (static_cast<void*>(&raw_[0])) T(std::forward<Args>(args)...);
96
1.26M
  }
cel::common_internal::MapValueVariant::MapValueVariant<cel::CustomMapValue>(std::__1::in_place_type_t<cel::CustomMapValue>)
Line
Count
Source
90
354k
      : index_(MapValueAlternative<T>::kIndex) {
91
354k
    static_assert(alignof(T) <= kMapValueVariantAlign);
92
354k
    static_assert(sizeof(T) <= kMapValueVariantSize);
93
354k
    static_assert(std::is_trivially_copyable_v<T>);
94
95
354k
    ::new (static_cast<void*>(&raw_[0])) T(std::forward<Args>(args)...);
96
354k
  }
cel::common_internal::MapValueVariant::MapValueVariant<cel::CustomMapValue, cel::CustomMapValue const&>(std::__1::in_place_type_t<cel::CustomMapValue>, cel::CustomMapValue const&)
Line
Count
Source
90
526k
      : index_(MapValueAlternative<T>::kIndex) {
91
526k
    static_assert(alignof(T) <= kMapValueVariantAlign);
92
526k
    static_assert(sizeof(T) <= kMapValueVariantSize);
93
526k
    static_assert(std::is_trivially_copyable_v<T>);
94
95
526k
    ::new (static_cast<void*>(&raw_[0])) T(std::forward<Args>(args)...);
96
526k
  }
Unexecuted instantiation: cel::common_internal::MapValueVariant::MapValueVariant<cel::common_internal::LegacyMapValue, cel::common_internal::LegacyMapValue>(std::__1::in_place_type_t<cel::common_internal::LegacyMapValue>, cel::common_internal::LegacyMapValue&&)
cel::common_internal::MapValueVariant::MapValueVariant<cel::CustomMapValue, cel::CustomMapValue>(std::__1::in_place_type_t<cel::CustomMapValue>, cel::CustomMapValue&&)
Line
Count
Source
90
363k
      : index_(MapValueAlternative<T>::kIndex) {
91
363k
    static_assert(alignof(T) <= kMapValueVariantAlign);
92
363k
    static_assert(sizeof(T) <= kMapValueVariantSize);
93
363k
    static_assert(std::is_trivially_copyable_v<T>);
94
95
363k
    ::new (static_cast<void*>(&raw_[0])) T(std::forward<Args>(args)...);
96
363k
  }
Unexecuted instantiation: cel::common_internal::MapValueVariant::MapValueVariant<cel::common_internal::LegacyMapValue, cel::common_internal::LegacyMapValue const&>(std::__1::in_place_type_t<cel::common_internal::LegacyMapValue>, cel::common_internal::LegacyMapValue const&)
cel::common_internal::MapValueVariant::MapValueVariant<cel::ParsedJsonMapValue, cel::ParsedJsonMapValue const&>(std::__1::in_place_type_t<cel::ParsedJsonMapValue>, cel::ParsedJsonMapValue const&)
Line
Count
Source
90
18.7k
      : index_(MapValueAlternative<T>::kIndex) {
91
18.7k
    static_assert(alignof(T) <= kMapValueVariantAlign);
92
18.7k
    static_assert(sizeof(T) <= kMapValueVariantSize);
93
18.7k
    static_assert(std::is_trivially_copyable_v<T>);
94
95
18.7k
    ::new (static_cast<void*>(&raw_[0])) T(std::forward<Args>(args)...);
96
18.7k
  }
Unexecuted instantiation: cel::common_internal::MapValueVariant::MapValueVariant<cel::ParsedMapFieldValue, cel::ParsedMapFieldValue const&>(std::__1::in_place_type_t<cel::ParsedMapFieldValue>, cel::ParsedMapFieldValue const&)
Unexecuted instantiation: cel::common_internal::MapValueVariant::MapValueVariant<cel::ParsedJsonMapValue, cel::ParsedJsonMapValue>(std::__1::in_place_type_t<cel::ParsedJsonMapValue>, cel::ParsedJsonMapValue&&)
Unexecuted instantiation: cel::common_internal::MapValueVariant::MapValueVariant<cel::ParsedMapFieldValue, cel::ParsedMapFieldValue>(std::__1::in_place_type_t<cel::ParsedMapFieldValue>, cel::ParsedMapFieldValue&&)
97
98
  template <typename T, typename = std::enable_if_t<
99
                            IsMapValueAlternativeV<absl::remove_cvref_t<T>>>>
100
  explicit MapValueVariant(T&& value)
101
      : MapValueVariant(absl::in_place_type<absl::remove_cvref_t<T>>,
102
                        std::forward<T>(value)) {}
103
104
  template <typename T>
105
  void Assign(T&& value) {
106
    using U = absl::remove_cvref_t<T>;
107
108
    static_assert(alignof(U) <= kMapValueVariantAlign);
109
    static_assert(sizeof(U) <= kMapValueVariantSize);
110
    static_assert(std::is_trivially_copyable_v<U>);
111
112
    index_ = MapValueAlternative<U>::kIndex;
113
    ::new (static_cast<void*>(&raw_[0])) U(std::forward<T>(value));
114
  }
115
116
  template <typename T>
117
0
  bool Is() const {
118
0
    return index_ == MapValueAlternative<T>::kIndex;
119
0
  }
Unexecuted instantiation: bool cel::common_internal::MapValueVariant::Is<cel::CustomMapValue>() const
Unexecuted instantiation: bool cel::common_internal::MapValueVariant::Is<cel::ParsedMapFieldValue>() const
Unexecuted instantiation: bool cel::common_internal::MapValueVariant::Is<cel::ParsedJsonMapValue>() const
Unexecuted instantiation: bool cel::common_internal::MapValueVariant::Is<cel::common_internal::LegacyMapValue>() const
120
121
  template <typename T>
122
      T& Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND {
123
    ABSL_DCHECK(Is<T>());
124
125
    return *At<T>();
126
  }
127
128
  template <typename T>
129
1.62M
  const T& Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND {
130
1.62M
    ABSL_DCHECK(Is<T>());
131
132
1.62M
    return *At<T>();
133
1.62M
  }
Unexecuted instantiation: cel::ParsedMapFieldValue const& cel::common_internal::MapValueVariant::Get<cel::ParsedMapFieldValue>() const &
cel::ParsedJsonMapValue const& cel::common_internal::MapValueVariant::Get<cel::ParsedJsonMapValue>() const &
Line
Count
Source
129
27.2k
  const T& Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND {
130
27.2k
    ABSL_DCHECK(Is<T>());
131
132
27.2k
    return *At<T>();
133
27.2k
  }
Unexecuted instantiation: cel::common_internal::LegacyMapValue const& cel::common_internal::MapValueVariant::Get<cel::common_internal::LegacyMapValue>() const &
cel::CustomMapValue const& cel::common_internal::MapValueVariant::Get<cel::CustomMapValue>() const &
Line
Count
Source
129
1.59M
  const T& Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND {
130
1.59M
    ABSL_DCHECK(Is<T>());
131
132
1.59M
    return *At<T>();
133
1.59M
  }
134
135
  template <typename T>
136
0
      T&& Get() && ABSL_ATTRIBUTE_LIFETIME_BOUND {
137
0
    ABSL_DCHECK(Is<T>());
138
139
0
    return std::move(*At<T>());
140
0
  }
141
142
  template <typename T>
143
  const T&& Get() const&& ABSL_ATTRIBUTE_LIFETIME_BOUND {
144
    ABSL_DCHECK(Is<T>());
145
146
    return std::move(*At<T>());
147
  }
148
149
  template <typename T>
150
0
  T* absl_nullable As() ABSL_ATTRIBUTE_LIFETIME_BOUND {
151
0
    if (Is<T>()) {
152
0
      return At<T>();
153
0
    }
154
0
    return nullptr;
155
0
  }
156
157
  template <typename T>
158
0
  const T* absl_nullable As() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
159
0
    if (Is<T>()) {
160
0
      return At<T>();
161
0
    }
162
0
    return nullptr;
163
0
  }
164
165
  template <typename Visitor>
166
1.62M
  decltype(auto) Visit(Visitor&& visitor) const {
167
1.62M
    switch (index_) {
168
1.59M
      case MapValueIndex::kCustom:
169
1.59M
        return std::forward<Visitor>(visitor)(Get<CustomMapValue>());
170
0
      case MapValueIndex::kParsedField:
171
0
        return std::forward<Visitor>(visitor)(Get<ParsedMapFieldValue>());
172
27.2k
      case MapValueIndex::kParsedJson:
173
27.2k
        return std::forward<Visitor>(visitor)(Get<ParsedJsonMapValue>());
174
0
      case MapValueIndex::kLegacy:
175
0
        return std::forward<Visitor>(visitor)(Get<LegacyMapValue>());
176
1.62M
    }
177
1.62M
  }
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::GetTypeId() const::$_0>(cel::MapValue::GetTypeId() const::$_0&&) const
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::DebugString() const::$_0>(cel::MapValue::DebugString() const::$_0&&) const
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::SerializeTo(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::io::ZeroCopyOutputStream*) const::$_0>(cel::MapValue::SerializeTo(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::io::ZeroCopyOutputStream*) const::$_0&&) const
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::ConvertToJson(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0>(cel::MapValue::ConvertToJson(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0&&) const
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::ConvertToJsonObject(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0>(cel::MapValue::ConvertToJsonObject(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0&&) const
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0>(cel::MapValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0&&) const
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::IsZeroValue() const::$_0>(cel::MapValue::IsZeroValue() const::$_0&&) const
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::IsEmpty() const::$_0>(cel::MapValue::IsEmpty() const::$_0&&) const
map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::Size() const::$_0>(cel::MapValue::Size() const::$_0&&) const
Line
Count
Source
166
89.2k
  decltype(auto) Visit(Visitor&& visitor) const {
167
89.2k
    switch (index_) {
168
87.3k
      case MapValueIndex::kCustom:
169
87.3k
        return std::forward<Visitor>(visitor)(Get<CustomMapValue>());
170
0
      case MapValueIndex::kParsedField:
171
0
        return std::forward<Visitor>(visitor)(Get<ParsedMapFieldValue>());
172
1.93k
      case MapValueIndex::kParsedJson:
173
1.93k
        return std::forward<Visitor>(visitor)(Get<ParsedJsonMapValue>());
174
0
      case MapValueIndex::kLegacy:
175
0
        return std::forward<Visitor>(visitor)(Get<LegacyMapValue>());
176
89.2k
    }
177
89.2k
  }
map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::Get(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0>(cel::MapValue::Get(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0&&) const
Line
Count
Source
166
148k
  decltype(auto) Visit(Visitor&& visitor) const {
167
148k
    switch (index_) {
168
138k
      case MapValueIndex::kCustom:
169
138k
        return std::forward<Visitor>(visitor)(Get<CustomMapValue>());
170
0
      case MapValueIndex::kParsedField:
171
0
        return std::forward<Visitor>(visitor)(Get<ParsedMapFieldValue>());
172
9.68k
      case MapValueIndex::kParsedJson:
173
9.68k
        return std::forward<Visitor>(visitor)(Get<ParsedJsonMapValue>());
174
0
      case MapValueIndex::kLegacy:
175
0
        return std::forward<Visitor>(visitor)(Get<LegacyMapValue>());
176
148k
    }
177
148k
  }
map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::Find(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0>(cel::MapValue::Find(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0&&) const
Line
Count
Source
166
613k
  decltype(auto) Visit(Visitor&& visitor) const {
167
613k
    switch (index_) {
168
602k
      case MapValueIndex::kCustom:
169
602k
        return std::forward<Visitor>(visitor)(Get<CustomMapValue>());
170
0
      case MapValueIndex::kParsedField:
171
0
        return std::forward<Visitor>(visitor)(Get<ParsedMapFieldValue>());
172
10.4k
      case MapValueIndex::kParsedJson:
173
10.4k
        return std::forward<Visitor>(visitor)(Get<ParsedJsonMapValue>());
174
0
      case MapValueIndex::kLegacy:
175
0
        return std::forward<Visitor>(visitor)(Get<LegacyMapValue>());
176
613k
    }
177
613k
  }
map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::Has(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0>(cel::MapValue::Has(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0&&) const
Line
Count
Source
166
8.46k
  decltype(auto) Visit(Visitor&& visitor) const {
167
8.46k
    switch (index_) {
168
7.37k
      case MapValueIndex::kCustom:
169
7.37k
        return std::forward<Visitor>(visitor)(Get<CustomMapValue>());
170
0
      case MapValueIndex::kParsedField:
171
0
        return std::forward<Visitor>(visitor)(Get<ParsedMapFieldValue>());
172
1.08k
      case MapValueIndex::kParsedJson:
173
1.08k
        return std::forward<Visitor>(visitor)(Get<ParsedJsonMapValue>());
174
0
      case MapValueIndex::kLegacy:
175
0
        return std::forward<Visitor>(visitor)(Get<LegacyMapValue>());
176
8.46k
    }
177
8.46k
  }
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::ListKeys(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::ListValue*) const::$_0>(cel::MapValue::ListKeys(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::ListValue*) const::$_0&&) const
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::ForEach(absl::lts_20260526::FunctionRef<absl::lts_20260526::StatusOr<bool> (cel::Value const&, cel::Value const&)>, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*) const::$_0>(cel::MapValue::ForEach(absl::lts_20260526::FunctionRef<absl::lts_20260526::StatusOr<bool> (cel::Value const&, cel::Value const&)>, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*) const::$_0&&) const
map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::NewIterator() const::$_0>(cel::MapValue::NewIterator() const::$_0&&) const
Line
Count
Source
166
44.4k
  decltype(auto) Visit(Visitor&& visitor) const {
167
44.4k
    switch (index_) {
168
40.2k
      case MapValueIndex::kCustom:
169
40.2k
        return std::forward<Visitor>(visitor)(Get<CustomMapValue>());
170
0
      case MapValueIndex::kParsedField:
171
0
        return std::forward<Visitor>(visitor)(Get<ParsedMapFieldValue>());
172
4.14k
      case MapValueIndex::kParsedJson:
173
4.14k
        return std::forward<Visitor>(visitor)(Get<ParsedJsonMapValue>());
174
0
      case MapValueIndex::kLegacy:
175
0
        return std::forward<Visitor>(visitor)(Get<LegacyMapValue>());
176
44.4k
    }
177
44.4k
  }
map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::ToValueVariant() const &::$_0>(cel::MapValue::ToValueVariant() const &::$_0&&) const
Line
Count
Source
166
717k
  decltype(auto) Visit(Visitor&& visitor) const {
167
717k
    switch (index_) {
168
717k
      case MapValueIndex::kCustom:
169
717k
        return std::forward<Visitor>(visitor)(Get<CustomMapValue>());
170
0
      case MapValueIndex::kParsedField:
171
0
        return std::forward<Visitor>(visitor)(Get<ParsedMapFieldValue>());
172
0
      case MapValueIndex::kParsedJson:
173
0
        return std::forward<Visitor>(visitor)(Get<ParsedJsonMapValue>());
174
0
      case MapValueIndex::kLegacy:
175
0
        return std::forward<Visitor>(visitor)(Get<LegacyMapValue>());
176
717k
    }
177
717k
  }
Unexecuted instantiation: map_value.cc:decltype(auto) cel::common_internal::MapValueVariant::Visit<cel::MapValue::ToValueVariant() &&::$_0>(cel::MapValue::ToValueVariant() &&::$_0&&) const
178
179
0
  friend void swap(MapValueVariant& lhs, MapValueVariant& rhs) noexcept {
180
0
    using std::swap;
181
0
    swap(lhs.index_, rhs.index_);
182
0
    swap(lhs.raw_, rhs.raw_);
183
0
  }
184
185
 private:
186
  template <typename T>
187
  ABSL_ATTRIBUTE_ALWAYS_INLINE T* absl_nonnull At()
188
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
189
0
    static_assert(alignof(T) <= kMapValueVariantAlign);
190
0
    static_assert(sizeof(T) <= kMapValueVariantSize);
191
0
    static_assert(std::is_trivially_copyable_v<T>);
192
193
0
    return std::launder(reinterpret_cast<T*>(&raw_[0]));
194
0
  }
195
196
  template <typename T>
197
  ABSL_ATTRIBUTE_ALWAYS_INLINE const T* absl_nonnull At() const
198
1.62M
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
199
1.62M
    static_assert(alignof(T) <= kMapValueVariantAlign);
200
1.62M
    static_assert(sizeof(T) <= kMapValueVariantSize);
201
1.62M
    static_assert(std::is_trivially_copyable_v<T>);
202
203
1.62M
    return std::launder(reinterpret_cast<const T*>(&raw_[0]));
204
1.62M
  }
Unexecuted instantiation: cel::ParsedMapFieldValue const* cel::common_internal::MapValueVariant::At<cel::ParsedMapFieldValue>() const
cel::ParsedJsonMapValue const* cel::common_internal::MapValueVariant::At<cel::ParsedJsonMapValue>() const
Line
Count
Source
198
27.2k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
199
27.2k
    static_assert(alignof(T) <= kMapValueVariantAlign);
200
27.2k
    static_assert(sizeof(T) <= kMapValueVariantSize);
201
27.2k
    static_assert(std::is_trivially_copyable_v<T>);
202
203
27.2k
    return std::launder(reinterpret_cast<const T*>(&raw_[0]));
204
27.2k
  }
Unexecuted instantiation: cel::common_internal::LegacyMapValue const* cel::common_internal::MapValueVariant::At<cel::common_internal::LegacyMapValue>() const
cel::CustomMapValue const* cel::common_internal::MapValueVariant::At<cel::CustomMapValue>() const
Line
Count
Source
198
1.59M
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
199
1.59M
    static_assert(alignof(T) <= kMapValueVariantAlign);
200
1.59M
    static_assert(sizeof(T) <= kMapValueVariantSize);
201
1.59M
    static_assert(std::is_trivially_copyable_v<T>);
202
203
1.59M
    return std::launder(reinterpret_cast<const T*>(&raw_[0]));
204
1.59M
  }
205
206
  MapValueIndex index_ = MapValueIndex::kCustom;
207
  alignas(8) std::byte raw_[kMapValueVariantSize];
208
};
209
210
}  // namespace cel::common_internal
211
212
#endif  // THIRD_PARTY_CEL_CPP_COMMON_VALUES_MAP_VALUE_VARIANT_H_