From 323e467e2375e535e10bda62faf2569e8f5c9b19 Mon Sep 17 00:00:00 2001 From: Renat Nurgaliyev Date: Thu, 15 Feb 2024 18:33:47 -0800 Subject: [PATCH] Fix check for C++20 std::ranges (#2144) Summary: This PR tries to address an issue I've described in https://github.com/facebook/folly/issues/2143 Pull Request resolved: https://github.com/facebook/folly/pull/2144 Reviewed By: Gownta Differential Revision: D53830508 Pulled By: Orvid fbshipit-source-id: a5fd37db447287f91761a9bfd0beab8feca50e77 --- folly/container/range_traits.h | 2 +- folly/container/tape.h | 4 ++-- folly/container/test/tape_test.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/folly/container/range_traits.h b/folly/container/range_traits.h index ad6275d5291..1498def895f 100644 --- a/folly/container/range_traits.h +++ b/folly/container/range_traits.h @@ -21,7 +21,7 @@ #include #include -#if __has_include() +#if defined(__cpp_lib_ranges) #include #endif diff --git a/folly/container/tape.h b/folly/container/tape.h index 317a1193ae0..80dc3539005 100644 --- a/folly/container/tape.h +++ b/folly/container/tape.h @@ -31,13 +31,13 @@ #include #include -#if __has_include() +#if defined(__cpp_lib_ranges) #include #endif namespace folly { -#if __has_include() +#if defined(__cpp_lib_ranges) #define FOLLY_TAPE_CONTAINER_REQUIRES std::ranges::random_access_range #else #define FOLLY_TAPE_CONTAINER_REQUIRES typename diff --git a/folly/container/test/tape_test.cpp b/folly/container/test/tape_test.cpp index e0abc7a0928..41c61d990b4 100644 --- a/folly/container/test/tape_test.cpp +++ b/folly/container/test/tape_test.cpp @@ -61,7 +61,7 @@ struct InputRange { iterator end() const { return iterator{c_.end()}; } }; -#if __has_include() +#if defined(__cpp_lib_ranges) static_assert(!std::forward_iterator>); static_assert(std::input_iterator>); #endif @@ -105,7 +105,7 @@ static_assert( folly::tape>::reference>, ""); -#if __has_include() +#if defined(__cpp_lib_ranges) static_assert(std::ranges::random_access_range); #endif