/**
 * Autogenerated by Thrift for /opt/local/var/macports/build/fbthrift-07c1dc61/work/fbthrift-2025.12.15.00/thrift/lib/thrift/type_rep.thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated @nocommit
 */
#pragma once

#include "thrift/lib/thrift/gen-cpp2/type_rep_metadata.h"
#include <thrift/lib/cpp2/visitation/visit_union.h>

namespace apache {
namespace thrift {
namespace detail {

template <>
struct VisitUnion<::apache::thrift::type::ProtocolUnion> {

  template <typename F, typename T>
  decltype(auto) operator()([[maybe_unused]] F&& f, T&& t) const {
    using Union = std::remove_reference_t<T>;
    switch (t.getType()) {
    case Union::Type::standard:
      return f(0, *static_cast<T&&>(t).standard_ref());
    case Union::Type::custom:
      return f(1, *static_cast<T&&>(t).custom_ref());
    case Union::Type::id:
      return f(2, *static_cast<T&&>(t).id_ref());
    case Union::Type::compressed:
      return f(3, *static_cast<T&&>(t).compressed_ref());
    case Union::Type::__EMPTY__:
      return decltype(f(0, *static_cast<T&&>(t).standard_ref()))();
    default:
      throw std::runtime_error{folly::to<std::string>(
          "Enum got invalid value ",
          static_cast<std::underlying_type_t<decltype(t.getType())>>(
              t.getType()))};
    }
  }
};
} // namespace detail
} // namespace thrift
} // namespace apache
