From 5e4ea1ce097f3571e7d87af33b6b30d11b3a211e Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 23 Feb 2022 14:30:26 -0800 Subject: Export of internal Abseil changes -- 7473df9e4922c589f6b27cf546aad097381ae552 by Martijn Vels : Make ABSL_ASSUME publicly available PiperOrigin-RevId: 430540224 Change-Id: I760e2d86e3a0b676cd2a6d26e0225a77381e948f -- c83e38bc421f715b3c1e20150c2f1ffe8e633028 by Abseil Team : Alias absl::bind_front to std::bind_front if available This avoids ambiguity between the two when enabling C++20. PiperOrigin-RevId: 430486679 GitOrigin-RevId: 7473df9e4922c589f6b27cf546aad097381ae552 Change-Id: I1e9bba09a8946480ce10ddd28e86b6c86191d38c --- absl/functional/bind_front.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'absl/functional') diff --git a/absl/functional/bind_front.h b/absl/functional/bind_front.h index 5b47970e..f9075bd1 100644 --- a/absl/functional/bind_front.h +++ b/absl/functional/bind_front.h @@ -30,6 +30,10 @@ #ifndef ABSL_FUNCTIONAL_BIND_FRONT_H_ #define ABSL_FUNCTIONAL_BIND_FRONT_H_ +#if defined(__cpp_lib_bind_front) && __cpp_lib_bind_front >= 201907L +#include // For std::bind_front. +#endif // defined(__cpp_lib_bind_front) && __cpp_lib_bind_front >= 201907L + #include "absl/functional/internal/front_binder.h" #include "absl/utility/utility.h" @@ -46,7 +50,8 @@ ABSL_NAMESPACE_BEGIN // specified. More importantly, it provides more reliable correctness guarantees // than `std::bind()`; while `std::bind()` will silently ignore passing more // parameters than expected, for example, `absl::bind_front()` will report such -// mis-uses as errors. +// mis-uses as errors. In C++20, `absl::bind_front` is replaced by +// `std::bind_front`. // // absl::bind_front(a...) can be seen as storing the results of // std::make_tuple(a...). @@ -170,6 +175,9 @@ ABSL_NAMESPACE_BEGIN // // Doesn't copy "hi". // absl::bind_front(Print, absl::string_view(hi))("Chuk"); // +#if defined(__cpp_lib_bind_front) && __cpp_lib_bind_front >= 201907L +using std::bind_front; +#else // defined(__cpp_lib_bind_front) && __cpp_lib_bind_front >= 201907L template constexpr functional_internal::bind_front_t bind_front( F&& func, BoundArgs&&... args) { @@ -177,6 +185,7 @@ constexpr functional_internal::bind_front_t bind_front( absl::in_place, absl::forward(func), absl::forward(args)...); } +#endif // defined(__cpp_lib_bind_front) && __cpp_lib_bind_front >= 201907L ABSL_NAMESPACE_END } // namespace absl -- cgit v1.2.3