Skip to content

Commit

Permalink
adapt very old non LTS abseil-cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
oathdruid committed May 23, 2024
1 parent 7445b14 commit 5a3e6c8
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions src/babylon/absl_base_internal_invoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,52 @@
// clang-format off
#include BABYLON_EXTERNAL(absl/base/config.h)
#include BABYLON_EXTERNAL(absl/base/internal/invoke.h)
#include BABYLON_EXTERNAL(absl/meta/type_traits.h)
// clang-format on

// add some essential features for old LTS abseil-cpp
#ifdef ABSL_LTS_RELEASE_VERSION

#if ABSL_LTS_RELEASE_VERSION < 20220623L
#define BABYLON_TMP_NEED_INVOKE_RESULT_R 1
#endif // ABSL_LTS_RELEASE_VERSION < 20220623L

#if ABSL_LTS_RELEASE_VERSION < 20200923L
#define BABYLON_TMP_NEED_INVOKE_RESULT_T 1
#endif // ABSL_LTS_RELEASE_VERSION < 20200923L

#else // !ABSL_LTS_RELEASE_VERSION

// TODO(lijiang01): some inactive repo depend on old abseil-cpp head
// use header check trick to adapt them before they switch to
// use macro check trick to adapt them before they switch to
// some LTS

// clang-format off
#if defined(ABSL_LTS_RELEASE_VERSION) || \
!BABYLON_HAS_INCLUDE( \
BABYLON_EXTERNAL(absl/base/internal/dynamic_annotations.h))
#include BABYLON_EXTERNAL(absl/base/optimization.h)
// clang-format on

#ifndef ABSL_ASSUME
#define BABYLON_TMP_NEED_INVOKE_RESULT_R 1
#endif // ABSL_ASSUME

#ifndef ABSL_HAVE_FEATURE
#define BABYLON_TMP_NEED_INVOKE_RESULT_T 1
#endif // ABSL_HAVE_FEATURE

#endif // !ABSL_LTS_RELEASE_VERSION

#if BABYLON_TMP_NEED_INVOKE_RESULT_R || BABYLON_TMP_NEED_INVOKE_RESULT_T
// clang-format off
#include BABYLON_EXTERNAL(absl/meta/type_traits.h)
// clang-format on

// very old abseil-cpp dont have these macros
#ifndef ABSL_NAMESPACE_BEGIN
#define ABSL_NAMESPACE_BEGIN
#define ABSL_NAMESPACE_END
#endif // ABSL_NAMESPACE_BEGIN
#endif // BABYLON_TMP_NEED_INVOKE_RESULT_R || BABYLON_TMP_NEED_INVOKE_RESULT_T

// add invoke_result_t before 20200923
#if ABSL_LTS_RELEASE_VERSION < 20200923L
#if BABYLON_TMP_NEED_INVOKE_RESULT_T
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace base_internal {
Expand All @@ -34,10 +59,9 @@ using invoke_result_t = InvokeT<F, Args...>;
} // namespace base_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_LTS_RELEASE_VERSION < 20200923L
#endif // BABYLON_TMP_NEED_INVOKE_RESULT_T

// add invoke_result_r before 20200923
#if ABSL_LTS_RELEASE_VERSION < 20220623L
#if BABYLON_TMP_NEED_INVOKE_RESULT_R
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace base_internal {
Expand All @@ -64,7 +88,7 @@ using is_invocable_r = IsInvocableRImpl<void, R, F, Args...>;
} // namespace base_internal
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_LTS_RELEASE_VERSION < 20220623L
#endif // BABYLON_TMP_NEED_INVOKE_RESULT_R

#endif // defined(ABSL_LTS_RELEASE_VERSION) ||
// !BABYLON_HAS_INCLUDE(BABYLON_EXTERNAL(absl/base/internal/dynamic_annotations.h))
#undef BABYLON_TMP_NEED_INVOKE_RESULT_R
#undef BABYLON_TMP_NEED_INVOKE_RESULT_T

0 comments on commit 5a3e6c8

Please sign in to comment.