summaryrefslogtreecommitdiff
path: root/absl/base
diff options
context:
space:
mode:
authorGravatar Lawrence Wolf-Sonkin <lawrencews@google.com>2023-12-28 14:26:18 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2023-12-28 14:27:14 -0800
commit6a19ff47352a2112e953f4ab813d820e0ecfe1e3 (patch)
treed0b376cb1109364175b38d300069bafb618e5cdd /absl/base
parent1ac355bbb7e1e3c7916d812976127cf15c411bd3 (diff)
[absl] Rename `absl::internal::identity` to `absl::internal::type_identity`
* Also does this for `absl::internal::identity_t` which is now `absl::internal::type_identity_t` * This is clearer naming as this is a backfill of `std::type_identity` (the identity type), and not `std::identity` (the identity function) PiperOrigin-RevId: 594316002 Change-Id: I5fb8cf7e3d07c1bc736cbecd202e7d556b6ea33e
Diffstat (limited to 'absl/base')
-rw-r--r--absl/base/casts.h2
-rw-r--r--absl/base/internal/identity.h6
-rw-r--r--absl/base/internal/inline_variable.h37
3 files changed, 24 insertions, 21 deletions
diff --git a/absl/base/casts.h b/absl/base/casts.h
index d1958885..e0b11bbe 100644
--- a/absl/base/casts.h
+++ b/absl/base/casts.h
@@ -90,7 +90,7 @@ ABSL_NAMESPACE_BEGIN
//
// Such implicit cast chaining may be useful within template logic.
template <typename To>
-constexpr To implicit_cast(typename absl::internal::identity_t<To> to) {
+constexpr To implicit_cast(typename absl::internal::type_identity_t<To> to) {
return to;
}
diff --git a/absl/base/internal/identity.h b/absl/base/internal/identity.h
index a3154ed7..365207b7 100644
--- a/absl/base/internal/identity.h
+++ b/absl/base/internal/identity.h
@@ -22,13 +22,15 @@ namespace absl {
ABSL_NAMESPACE_BEGIN
namespace internal {
+// This is a back-fill of C++20's `std::type_identity`.
template <typename T>
-struct identity {
+struct type_identity {
typedef T type;
};
+// This is a back-fill of C++20's `std::type_identity_t`.
template <typename T>
-using identity_t = typename identity<T>::type;
+using type_identity_t = typename type_identity<T>::type;
} // namespace internal
ABSL_NAMESPACE_END
diff --git a/absl/base/internal/inline_variable.h b/absl/base/internal/inline_variable.h
index df933faf..09daf0f5 100644
--- a/absl/base/internal/inline_variable.h
+++ b/absl/base/internal/inline_variable.h
@@ -63,12 +63,12 @@
// Bug: https://bugs.llvm.org/show_bug.cgi?id=35862
//
// Note:
-// identity_t is used here so that the const and name are in the
+// type_identity_t is used here so that the const and name are in the
// appropriate place for pointer types, reference types, function pointer
// types, etc..
#if defined(__clang__)
#define ABSL_INTERNAL_EXTERN_DECL(type, name) \
- extern const ::absl::internal::identity_t<type> name;
+ extern const ::absl::internal::type_identity_t<type> name;
#else // Otherwise, just define the macro to do nothing.
#define ABSL_INTERNAL_EXTERN_DECL(type, name)
#endif // defined(__clang__)
@@ -76,30 +76,31 @@
// See above comment at top of file for details.
#define ABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \
ABSL_INTERNAL_EXTERN_DECL(type, name) \
- inline constexpr ::absl::internal::identity_t<type> name = init
+ inline constexpr ::absl::internal::type_identity_t<type> name = init
#else
// See above comment at top of file for details.
//
// Note:
-// identity_t is used here so that the const and name are in the
+// type_identity_t is used here so that the const and name are in the
// appropriate place for pointer types, reference types, function pointer
// types, etc..
-#define ABSL_INTERNAL_INLINE_CONSTEXPR(var_type, name, init) \
- template <class /*AbslInternalDummy*/ = void> \
- struct AbslInternalInlineVariableHolder##name { \
- static constexpr ::absl::internal::identity_t<var_type> kInstance = init; \
- }; \
- \
- template <class AbslInternalDummy> \
- constexpr ::absl::internal::identity_t<var_type> \
- AbslInternalInlineVariableHolder##name<AbslInternalDummy>::kInstance; \
- \
- static constexpr const ::absl::internal::identity_t<var_type>& \
- name = /* NOLINT */ \
- AbslInternalInlineVariableHolder##name<>::kInstance; \
- static_assert(sizeof(void (*)(decltype(name))) != 0, \
+#define ABSL_INTERNAL_INLINE_CONSTEXPR(var_type, name, init) \
+ template <class /*AbslInternalDummy*/ = void> \
+ struct AbslInternalInlineVariableHolder##name { \
+ static constexpr ::absl::internal::type_identity_t<var_type> kInstance = \
+ init; \
+ }; \
+ \
+ template <class AbslInternalDummy> \
+ constexpr ::absl::internal::type_identity_t<var_type> \
+ AbslInternalInlineVariableHolder##name<AbslInternalDummy>::kInstance; \
+ \
+ static constexpr const ::absl::internal::type_identity_t<var_type>& \
+ name = /* NOLINT */ \
+ AbslInternalInlineVariableHolder##name<>::kInstance; \
+ static_assert(sizeof(void (*)(decltype(name))) != 0, \
"Silence unused variable warnings.")
#endif // __cpp_inline_variables