hpb: Move add_const_if_T_is_const to template_help.h and delete traits.h

PiperOrigin-RevId: 673906280
pull/18272/head
Hong Shin 6 months ago committed by Copybara-Service
parent e9e499f884
commit ada599128c
  1. 11
      hpb/BUILD
  2. 1
      hpb/internal/BUILD
  3. 4
      hpb/internal/template_help.h
  4. 3
      hpb/repeated_field.h
  5. 21
      hpb/traits.h

@ -63,8 +63,8 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":hpb",
":traits",
"//hpb/backend/upb:interop",
"//hpb/internal:template_help",
"//upb:base",
"//upb:mem",
"//upb:message",
@ -74,15 +74,6 @@ cc_library(
],
)
# Internally used type traits.
cc_library(
name = "traits",
hdrs = [
"traits.h",
],
copts = UPB_DEFAULT_CPPOPTS,
)
# Common support code for C++ generated code.
cc_library(
name = "generated_hpb_support",

@ -15,6 +15,7 @@ package(default_applicable_licenses = ["//:license"])
cc_library(
name = "template_help",
hdrs = ["template_help.h"],
copts = UPB_DEFAULT_CPPOPTS,
visibility = ["//hpb:__subpackages__"],
deps = [
"//hpb:ptr",

@ -43,6 +43,10 @@ using EnableIfHpbClass = std::enable_if_t<
template <typename T>
using EnableIfMutableProto = std::enable_if_t<!std::is_const<T>::value>;
template <typename T, typename T2>
using add_const_if_T_is_const =
std::conditional_t<std::is_const_v<T>, const T2, T2>;
} // namespace internal
} // namespace hpb

@ -16,9 +16,8 @@
#include "absl/strings/string_view.h"
#include "google/protobuf/hpb/backend/upb/interop.h"
#include "google/protobuf/hpb/hpb.h"
#include "google/protobuf/hpb/internal/template_help.h"
#include "google/protobuf/hpb/repeated_field_iterator.h"
#include "google/protobuf/hpb/traits.h"
#include "upb/base/string_view.h"
#include "upb/mem/arena.h"
#include "upb/message/array.h"

@ -1,21 +0,0 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PROTOBUF_HPB_TRAITS_H_
#define PROTOBUF_HPB_TRAITS_H_
#include <type_traits>
namespace hpb::internal {
template <typename T, typename T2>
using add_const_if_T_is_const =
std::conditional_t<std::is_const_v<T>, const T2, T2>;
} // namespace hpb::internal
#endif // PROTOBUF_HPB_TRAITS_H_
Loading…
Cancel
Save