NVIDIA DeepStream SDK API Reference

9.2 Release
includes/opentelemetry/nostd/internal/absl/types/bad_variant_access.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef OTABSL_TYPES_BAD_VARIANT_ACCESS_H_
19 #define OTABSL_TYPES_BAD_VARIANT_ACCESS_H_
20 
21 #include <stdexcept>
22 
23 #include "../base/config.h"
24 
25 #ifdef OTABSL_USES_STD_VARIANT
26 
27 #include <variant>
28 
29 namespace absl {
31 using std::bad_variant_access;
33 } // namespace absl
34 
35 #else // OTABSL_USES_STD_VARIANT
36 
37 namespace absl {
39 
40 // -----------------------------------------------------------------------------
41 // bad_variant_access
42 // -----------------------------------------------------------------------------
43 //
44 // An `absl::OTABSL_OPTION_NAMESPACE_NAME::bad_variant_access` type is an exception type that is thrown in
45 // the following cases:
46 //
47 // * Calling `absl::OTABSL_OPTION_NAMESPACE_NAME::get(absl::OTABSL_OPTION_NAMESPACE_NAME::variant) with an index or type that does not
48 // match the currently selected alternative type
49 // * Calling `absl::OTABSL_OPTION_NAMESPACE_NAME::visit on an `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` that is in the
50 // `variant::valueless_by_exception` state.
51 //
52 // Example:
53 //
54 // absl::OTABSL_OPTION_NAMESPACE_NAME::variant<int, std::string> v;
55 // v = 1;
56 // try {
57 // absl::OTABSL_OPTION_NAMESPACE_NAME::get<std::string>(v);
58 // } catch(const absl::OTABSL_OPTION_NAMESPACE_NAME::bad_variant_access& e) {
59 // std::cout << "Bad variant access: " << e.what() << '\n';
60 // }
61 class bad_variant_access : public std::exception {
62  public:
63  bad_variant_access() noexcept = default;
64  ~bad_variant_access() override;
65  const char* what() const noexcept override;
66 };
67 
68 namespace variant_internal {
69 #ifdef THROW_BAD_VARIANT_ACCESS
70 // Header-only implementation with static throw implementation.
71 // No need to link against Abseil library.
72 [[noreturn]] static inline void ThrowBadVariantAccess()
73 {
75 }
76 //[[noreturn]] static inline void Rethrow()
77 //{
78 // THROW_BAD_VARIANT_ACCESS; // Unused!
79 //};
80 #else
81 // Original implementation requires linking Abseil library!
82 [[noreturn]] void ThrowBadVariantAccess();
83 [[noreturn]] void Rethrow();
84 #endif
85 } // namespace variant_internal
87 } // namespace absl
88 
89 #endif // OTABSL_USES_STD_VARIANT
90 
91 #endif // OTABSL_TYPES_BAD_VARIANT_ACCESS_H_
absl::bad_variant_access
Definition: includes/opentelemetry/nostd/internal/absl/types/bad_variant_access.h:61
absl::variant_internal::Rethrow
void Rethrow()
OTABSL_NAMESPACE_BEGIN
#define OTABSL_NAMESPACE_BEGIN
Definition: includes/opentelemetry/nostd/internal/absl/base/config.h:91
THROW_BAD_VARIANT_ACCESS
#define THROW_BAD_VARIANT_ACCESS
Definition: includes/opentelemetry/nostd/variant.h:41
absl::bad_variant_access::bad_variant_access
bad_variant_access() noexcept=default
absl::variant_internal::ThrowBadVariantAccess
void ThrowBadVariantAccess()
absl
Definition: includes/opentelemetry/nostd/variant.h:54
OTABSL_NAMESPACE_END
#define OTABSL_NAMESPACE_END
Definition: includes/opentelemetry/nostd/internal/absl/base/config.h:92
absl::bad_variant_access::~bad_variant_access
~bad_variant_access() override
absl::bad_variant_access::what
const char * what() const noexcept override