Skip to content

Commit e88e8fe

Browse files
CEL Dev TeamTristonianJones
authored andcommitted
Replace internal/port.h with absl/meta/type_traits.h
PiperOrigin-RevId: 365817691
1 parent 958554e commit e88e8fe

11 files changed

Lines changed: 55 additions & 119 deletions

File tree

common/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ cc_test(
196196
"//internal:types",
197197
"//internal:value_internal",
198198
"//testutil:util",
199+
"@com_google_absl//absl/meta:type_traits",
199200
"@com_google_absl//absl/strings",
200201
"@com_google_googleapis//google/rpc:status_cc_proto",
201202
"@com_google_googleapis//google/type:money_cc_proto",
@@ -218,6 +219,7 @@ cc_library(
218219
"//internal:list_impl",
219220
"//internal:map_impl",
220221
"//internal:types",
222+
"@com_google_absl//absl/meta:type_traits",
221223
],
222224
)
223225

common/converters.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <memory>
77

8+
#include "absl/meta/type_traits.h"
89
#include "common/parent_ref.h"
910
#include "common/value.h"
1011
#include "internal/list_impl.h"
@@ -53,7 +54,7 @@ template <Value::Kind ValueKind, typename T>
5354
Value ValueFromList(T&& value) {
5455
static_assert(!std::is_pointer<T>::value, "use ValueForList");
5556
return Value::MakeList<
56-
internal::ListWrapper<ValueKind, internal::remove_cvref_t<T>>>(
57+
internal::ListWrapper<ValueKind, absl::remove_cvref_t<T>>>(
5758
std::forward<T>(value));
5859
}
5960

@@ -92,7 +93,7 @@ template <Value::Kind KeyKind, Value::Kind ValueKind, typename T>
9293
Value ValueFromMap(T&& value) {
9394
static_assert(!std::is_pointer<T>::value, "use ValueForList");
9495
return Value::MakeMap<
95-
internal::MapWrapper<KeyKind, ValueKind, internal::remove_cvref_t<T>>>(
96+
internal::MapWrapper<KeyKind, ValueKind, absl::remove_cvref_t<T>>>(
9697
std::forward<T>(value));
9798
}
9899

common/value_test.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "google/type/money.pb.h"
1111
#include "gmock/gmock.h"
1212
#include "gtest/gtest.h"
13+
#include "absl/meta/type_traits.h"
1314
#include "absl/strings/str_cat.h"
1415
#include "common/custom_object.h"
1516
#include "internal/status_util.h"
@@ -709,15 +710,15 @@ class ValueVisitTest : public ::testing::Test {
709710
710711
template <typename H>
711712
void TestGetPtrVisitor() {
712-
using T = remove_reference_t<decltype(*inst_of<H&>())>;
713+
using T = absl::remove_reference_t<decltype(*inst_of<H&>())>;
713714
ExpectSameType<const T*, GetPtrVisitorType<H, T>>();
714715
// Return by const ref.
715716
ExpectSameType<const T&, GetVisitorType<H, const T&, T>>();
716717
}
717718
718719
template <typename H, typename U>
719720
void TestGetVisitor() {
720-
using T = remove_reference_t<decltype(*inst_of<H&>())>;
721+
using T = absl::remove_reference_t<decltype(*inst_of<H&>())>;
721722
// Return by optional.
722723
ExpectSameType<absl::optional<U>,
723724
GetVisitorType<H, absl::optional<U>, T>>();
@@ -727,7 +728,7 @@ class ValueVisitTest : public ::testing::Test {
727728
728729
template <typename H>
729730
void TestValueAdapter() {
730-
using T = remove_reference_t<decltype(*inst_of<H&>())>;
731+
using T = absl::remove_reference_t<decltype(*inst_of<H&>())>;
731732
ExpectSameType<T&, ValueAdapterType<H&>>();
732733
ExpectSameType<const T&, ValueAdapterType<const H&>>();
733734
}

internal/BUILD

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ cc_library(
1616
deps = [
1717
":holder",
1818
":specialize",
19+
"@com_google_absl//absl/meta:type_traits",
1920
],
2021
)
2122

@@ -57,10 +58,10 @@ cc_library(
5758
"holder.h",
5859
],
5960
deps = [
60-
":port",
6161
":specialize",
6262
":types",
6363
":visitor_util",
64+
"@com_google_absl//absl/meta:type_traits",
6465
],
6566
)
6667

@@ -85,8 +86,8 @@ cc_library(
8586
"hash_util.h",
8687
],
8788
deps = [
88-
":port",
8989
":specialize",
90+
"@com_google_absl//absl/meta:type_traits",
9091
"@com_google_absl//absl/strings",
9192
"@com_google_absl//absl/time",
9293
"@com_google_googleapis//google/rpc:status_cc_proto",
@@ -129,7 +130,6 @@ cc_test(
129130
":visitor_util",
130131
"//testutil:util",
131132
"@com_google_absl//absl/memory",
132-
"@com_google_absl//absl/strings",
133133
"@com_google_googletest//:gtest_main",
134134
],
135135
)
@@ -236,11 +236,6 @@ cc_test(
236236
],
237237
)
238238

239-
cc_library(
240-
name = "port",
241-
hdrs = ["port.h"],
242-
)
243-
244239
cc_library(
245240
name = "specialize",
246241
hdrs = ["specialize.h"],
@@ -250,10 +245,10 @@ cc_library(
250245
name = "cast",
251246
hdrs = ["cast.h"],
252247
deps = [
253-
":port",
254248
":specialize",
255249
":types",
256250
"@com_google_absl//absl/memory",
251+
"@com_google_absl//absl/meta:type_traits",
257252
"@com_google_absl//absl/types:optional",
258253
],
259254
)
@@ -273,9 +268,9 @@ cc_library(
273268
"types.h",
274269
],
275270
deps = [
276-
":port",
277271
":specialize",
278272
"@com_google_absl//absl/memory",
273+
"@com_google_absl//absl/meta:type_traits",
279274
"@com_google_absl//absl/strings",
280275
],
281276
)

internal/cast.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include <memory>
66

77
#include "absl/memory/memory.h"
8+
#include "absl/meta/type_traits.h"
89
#include "absl/types/optional.h"
9-
#include "internal/port.h"
1010
#include "internal/specialize.h"
1111
#include "internal/types.h"
1212

@@ -63,7 +63,7 @@ struct StaticDownCastHelper<std::unique_ptr<T>> {
6363
template <typename T, typename U, typename = specialize>
6464
struct RepresentableAsHelper {
6565
static constexpr bool check(const U&) {
66-
return std::is_same<remove_cvref_t<T>, U>::value;
66+
return std::is_same<absl::remove_cvref_t<T>, U>::value;
6767
}
6868
};
6969

internal/hash_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
#include "google/protobuf/any.pb.h"
88
#include "google/rpc/status.pb.h"
9+
#include "absl/meta/type_traits.h"
910
#include "absl/strings/string_view.h"
1011
#include "absl/time/time.h"
11-
#include "internal/port.h"
1212
#include "internal/specialize.h"
1313

1414
namespace google {

internal/holder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <algorithm>
55
#include <memory>
66

7-
#include "internal/port.h"
7+
#include "absl/meta/type_traits.h"
88
#include "internal/specialize.h"
99
#include "internal/types.h"
1010
#include "internal/visitor_util.h"
@@ -69,7 +69,7 @@ struct Copy : BaseHolderPolicy {
6969
constexpr static const bool kOwnsValue = true;
7070

7171
template <typename T>
72-
using ValueType = remove_const_t<T>;
72+
using ValueType = absl::remove_const_t<T>;
7373

7474
template <typename T>
7575
static T& get(T& value) {

internal/port.h

Lines changed: 0 additions & 66 deletions
This file was deleted.

internal/ref_countable.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <memory>
77
#include <utility>
88

9+
#include "absl/meta/type_traits.h"
910
#include "internal/holder.h"
1011
#include "internal/specialize.h"
1112

@@ -240,8 +241,9 @@ using RefCopyHolder = Holder<T, Ref<Copy>>;
240241
// If the size of T is smaller than MAX, it is stored inline, otherwise
241242
// it is stored in a heap allocated, reference counted holder.
242243
template <typename T, std::size_t MAX = sizeof(void*)>
243-
using SizeLimitHolder = conditional_t<sizeof(T) <= MAX, Holder<const T, Copy>,
244-
Holder<const T, Ref<Copy>>>;
244+
using SizeLimitHolder =
245+
absl::conditional_t<sizeof(T) <= MAX, Holder<const T, Copy>,
246+
Holder<const T, Ref<Copy>>>;
245247

246248
template <typename T>
247249
void ReffedPtr<T>::reset() {

0 commit comments

Comments
 (0)