hpb: Disambiguate betwixt mutable and agnostic PtrOrRaw (mutable or const)

PiperOrigin-RevId: 704738982
pull/19569/head
Hong Shin 3 months ago committed by Copybara-Service
parent 874e03bd93
commit bc9da2b177
  1. 3
      hpb/backend/upb/upb.h
  2. 2
      hpb/hpb.h
  3. 3
      hpb/internal/template_help.h

@ -9,14 +9,13 @@
#define GOOGLE_PROTOBUF_HPB_BACKEND_UPB_UPB_H__ #define GOOGLE_PROTOBUF_HPB_BACKEND_UPB_UPB_H__
#include "google/protobuf/hpb/backend/upb/interop.h" #include "google/protobuf/hpb/backend/upb/interop.h"
#include "google/protobuf/hpb/internal/internal.h"
#include "google/protobuf/hpb/internal/template_help.h" #include "google/protobuf/hpb/internal/template_help.h"
#include "google/protobuf/hpb/ptr.h" #include "google/protobuf/hpb/ptr.h"
namespace hpb::internal::backend::upb { namespace hpb::internal::backend::upb {
template <typename T> template <typename T>
void ClearMessage(hpb::internal::PtrOrRaw<T> message) { void ClearMessage(hpb::internal::PtrOrRawMutable<T> message) {
auto ptr = Ptr(message); auto ptr = Ptr(message);
auto minitable = hpb::interop::upb::GetMiniTable(ptr); auto minitable = hpb::interop::upb::GetMiniTable(ptr);
upb_Message_Clear(hpb::interop::upb::GetMessage(ptr), minitable); upb_Message_Clear(hpb::interop::upb::GetMessage(ptr), minitable);

@ -79,7 +79,7 @@ void DeepCopy(const T* source_message, T* target_message) {
} }
template <typename T> template <typename T>
void ClearMessage(hpb::internal::PtrOrRaw<T> message) { void ClearMessage(hpb::internal::PtrOrRawMutable<T> message) {
backend::ClearMessage(message); backend::ClearMessage(message);
} }

@ -33,6 +33,9 @@ using RemovePtrT = typename RemovePtr<T>::type;
template <typename T, typename U = RemovePtrT<T>, template <typename T, typename U = RemovePtrT<T>,
typename = std::enable_if_t<!std::is_const_v<U>>> typename = std::enable_if_t<!std::is_const_v<U>>>
using PtrOrRawMutable = T;
template <typename T, typename U = RemovePtrT<T>>
using PtrOrRaw = T; using PtrOrRaw = T;
template <typename T, typename = void> template <typename T, typename = void>

Loading…
Cancel
Save