#ifndef COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_RESOURCE_ATTRIBUTION_TYPE_HELPERS_H_
#define COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_RESOURCE_ATTRIBUTION_TYPE_HELPERS_H_
#include <optional>
#include <type_traits>
#include "base/notreached.h"
#include "base/types/optional_ref.h"
#include "base/types/optional_util.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace resource_attribution {
namespace internal {
template <typename T, typename V, size_t I = absl::variant_size<V>::value>
struct IsVariantAlternative
: std::disjunction<
std::is_same<T, typename absl::variant_alternative<I - 1, V>::type>,
IsVariantAlternative<T, V, I - 1>> { … };
IsVariantAlternative<T, V, 0>;
EnableIfIsVariantAlternative;
template <typename T, typename V, EnableIfIsVariantAlternative<T, V> = true>
constexpr std::optional<T> GetAsOptional(const V& v) { … }
template <typename T, typename V, EnableIfIsVariantAlternative<T, V> = true>
constexpr bool VariantVectorContains(const std::vector<V>& vs) { … }
template <typename ConstT,
typename V,
std::enable_if_t<std::is_const_v<ConstT>, bool> = true,
EnableIfIsVariantAlternative<std::remove_const_t<ConstT>, V> = true>
constexpr bool VariantVectorContains(const std::vector<V>& vs) { … }
template <typename T, typename V, EnableIfIsVariantAlternative<T, V> = true>
constexpr base::optional_ref<T> GetFromVariantVector(std::vector<V>& vs) { … }
template <typename T, typename V, EnableIfIsVariantAlternative<T, V> = true>
constexpr base::optional_ref<const T> GetFromVariantVector(
const std::vector<V>& vs) { … }
template <typename ConstT,
typename V,
std::enable_if_t<std::is_const_v<ConstT>, bool> = true,
EnableIfIsVariantAlternative<std::remove_const_t<ConstT>, V> = true>
constexpr base::optional_ref<ConstT> GetFromVariantVector(
const std::vector<V>& vs) { … }
template <typename T, typename V, EnableIfIsVariantAlternative<T, V> = true>
constexpr bool operator==(const T& a, const V& b) { … }
template <typename T, typename V, EnableIfIsVariantAlternative<T, V> = true>
constexpr bool operator==(const V& a, const T& b) { … }
template <typename T, typename V, EnableIfIsVariantAlternative<T, V> = true>
constexpr bool operator!=(const T& a, const V& b) { … }
template <typename T, typename V, EnableIfIsVariantAlternative<T, V> = true>
constexpr bool operator!=(const V& a, const T& b) { … }
}
operator==;
operator!=;
}
#endif