diff --git a/api/include/opentelemetry/std/variant.h b/api/include/opentelemetry/std/variant.h index 58bc510c5f622..c665c7945f4f7 100644 --- a/api/include/opentelemetry/std/variant.h +++ b/api/include/opentelemetry/std/variant.h @@ -220,9 +220,13 @@ inline constexpr bool holds_alternative(const variant &v) noexcept return v.index() == I; } -template -inline constexpr bool holds_alternative(const variant &v) noexcept +template typename U, typename... Ts> +inline constexpr bool holds_alternative(const U &v) noexcept { + // Clang 18.1.7 on Ubuntu 24.04 does not disambiguate between this + // and std::holds_alternative if argument type is std::variant + static_assert(std::is_same_v, std::variant>, + "Unsupported argument type"); return std::holds_alternative(v); }