Skip to content

Commit 367f2f7

Browse files
[oneDPL] Re-design the definition of _ONEDPL_CPP20_RANGES_PRESENT macro (#2529)
1 parent 20b6ef2 commit 367f2f7

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

include/oneapi/dpl/internal/version_impl.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,23 @@
1818
// The oneAPI Specification version this implementation is compliant with
1919
#define ONEDPL_SPEC_VERSION 104
2020

21+
// -- Check for C++ standard library feature macros --
2122
#if __has_include(<version>)
22-
# include <version> // The standard C++20 header
23+
# include <version>
2324
# define _ONEDPL_STD_FEATURE_MACROS_PRESENT 1
24-
// Clang 15 and older do not support range adaptors, see https://bugs.llvm.org/show_bug.cgi?id=44833
25-
# define _ONEDPL_CPP20_RANGES_PRESENT ((__cpp_lib_ranges >= 201911L) && !(__clang__ && __clang_major__ < 16))
25+
# define _ONEDPL_CPP20_CONCEPTS_PRESENT (__cpp_concepts >= 201907L && __cpp_lib_concepts >= 202002L)
2626
#else
2727
# define _ONEDPL_STD_FEATURE_MACROS_PRESENT 0
28+
# define _ONEDPL_CPP20_CONCEPTS_PRESENT 0
29+
#endif
30+
31+
// -- Check for C++20 Ranges support --
32+
#if _ONEDPL_CPP20_CONCEPTS_PRESENT
33+
// Ranges library is available if the standard library provides it and concepts are supported
34+
// Clang 15 and older do not support range adaptors, see https://bugs.llvm.org/show_bug.cgi?id=44833
35+
# define _ONEDPL_CPP20_RANGES_PRESENT \
36+
((__cpp_lib_ranges >= 201911L) && !(_LIBCPP_VERSION && _LIBCPP_VERSION < 16000))
37+
#else
2838
# define _ONEDPL_CPP20_RANGES_PRESENT 0
2939
#endif
3040

@@ -35,7 +45,7 @@
3545
# define _PSTL_VERSION_PATCH (_PSTL_VERSION % 10)
3646
#endif
3747

38-
// Feature macros
48+
// -- Define oneDPL feature macros --
3949
#define ONEDPL_HAS_RANDOM_NUMBERS 202409L
4050
#if _ONEDPL_CPP20_RANGES_PRESENT
4151
# define ONEDPL_HAS_RANGE_ALGORITHMS 202509L

include/oneapi/dpl/pstl/onedpl_config.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,11 @@
271271
(_ONEDPL___cplusplus >= 202002L && (_MSC_VER >= 1921 || _GLIBCXX_RELEASE >= 10))
272272
273273
#if _ONEDPL_STD_FEATURE_MACROS_PRESENT
274-
# define _ONEDPL_CPP20_CONCEPTS_PRESENT (__cpp_concepts >= 201907L && __cpp_lib_concepts >= 202002L)
275274
# define _ONEDPL_CPP23_TUPLE_LIKE_COMMON_REFERENCE_PRESENT \
276275
(_ONEDPL___cplusplus >= 202302L && __cpp_lib_tuple_like >= 202207L)
277276
# define _ONEDPL_CPP23_RANGES_ZIP_PRESENT (_ONEDPL___cplusplus >= 202302L && __cpp_lib_ranges_zip >= 202110L)
278277
# define _ONEDPL_CPP26_DEFAULT_VALUE_TYPE_PRESENT (__cpp_lib_algorithm_default_value_type >= 202403L)
279278
#else
280-
# define _ONEDPL_CPP20_CONCEPTS_PRESENT 0
281279
# define _ONEDPL_CPP23_TUPLE_LIKE_COMMON_REFERENCE_PRESENT 0
282280
# define _ONEDPL_CPP23_RANGES_ZIP_PRESENT 0
283281
# define _ONEDPL_CPP26_DEFAULT_VALUE_TYPE_PRESENT 0

0 commit comments

Comments
 (0)