From a30e8b8245724c85ab6423fd2c500025a00138dd Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Wed, 8 Feb 2023 17:58:32 +0200 Subject: [PATCH 1/2] Corrected detection of missing `std::identity` --- dev/functional/cxx_functional_polyfill.h | 4 ++-- include/sqlite_orm/sqlite_orm.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/functional/cxx_functional_polyfill.h b/dev/functional/cxx_functional_polyfill.h index da59dfe0c..412459ea0 100644 --- a/dev/functional/cxx_functional_polyfill.h +++ b/dev/functional/cxx_functional_polyfill.h @@ -14,9 +14,9 @@ namespace sqlite_orm { namespace internal { namespace polyfill { // C++20 or later (unfortunately there's no feature test macro). - // Stupidly, clang < 11 says C++20, but comes w/o std::identity. + // Stupidly, clang says C++20, but `std::identity` was only implemented in libc++ 13. // Another way of detection would be the constrained algorithms feature macro __cpp_lib_ranges -#if(__cplusplus >= 202002L) && (!__clang_major__ || __clang_major__ >= 11) +#if(__cplusplus >= 202002L) && (!_LIBCPP_VERSION || _LIBCPP_VERSION >= 13) using std::identity; #else struct identity { diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 65b5a6ad8..9fc8c2729 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -7932,9 +7932,9 @@ namespace sqlite_orm { namespace internal { namespace polyfill { // C++20 or later (unfortunately there's no feature test macro). - // Stupidly, clang < 11 says C++20, but comes w/o std::identity. + // Stupidly, clang says C++20, but `std::identity` was only implemented in libc++ 13. // Another way of detection would be the constrained algorithms feature macro __cpp_lib_ranges -#if(__cplusplus >= 202002L) && (!__clang_major__ || __clang_major__ >= 11) +#if(__cplusplus >= 202002L) && (!_LIBCPP_VERSION || _LIBCPP_VERSION >= 13) using std::identity; #else struct identity { From d9e206ec9777b5e94bc8e347e54217fb3d18eddf Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Wed, 8 Feb 2023 20:24:54 +0200 Subject: [PATCH 2/2] Corrected again detection of missing `std::identity` --- dev/functional/cxx_functional_polyfill.h | 9 +++++++-- include/sqlite_orm/sqlite_orm.h | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dev/functional/cxx_functional_polyfill.h b/dev/functional/cxx_functional_polyfill.h index 412459ea0..5380f2fcc 100644 --- a/dev/functional/cxx_functional_polyfill.h +++ b/dev/functional/cxx_functional_polyfill.h @@ -14,9 +14,14 @@ namespace sqlite_orm { namespace internal { namespace polyfill { // C++20 or later (unfortunately there's no feature test macro). - // Stupidly, clang says C++20, but `std::identity` was only implemented in libc++ 13. + // Stupidly, clang says C++20, but `std::identity` was only implemented in libc++ 13 and libstd++-v3 10 + // (the latter is used on Linux). + // gcc got it right and reports C++20 only starting with v10. + // The check here doesn't care and checks the library versions in use. + // // Another way of detection would be the constrained algorithms feature macro __cpp_lib_ranges -#if(__cplusplus >= 202002L) && (!_LIBCPP_VERSION || _LIBCPP_VERSION >= 13) +#if(__cplusplus >= 202002L) && \ + ((!_LIBCPP_VERSION || _LIBCPP_VERSION >= 13) && (!_GLIBCXX_RELEASE || _GLIBCXX_RELEASE >= 10)) using std::identity; #else struct identity { diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 9fc8c2729..97c3f0a08 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -7932,9 +7932,14 @@ namespace sqlite_orm { namespace internal { namespace polyfill { // C++20 or later (unfortunately there's no feature test macro). - // Stupidly, clang says C++20, but `std::identity` was only implemented in libc++ 13. + // Stupidly, clang says C++20, but `std::identity` was only implemented in libc++ 13 and libstd++-v3 10 + // (the latter is used on Linux). + // gcc got it right and reports C++20 only starting with v10. + // The check here doesn't care and checks the library versions in use. + // // Another way of detection would be the constrained algorithms feature macro __cpp_lib_ranges -#if(__cplusplus >= 202002L) && (!_LIBCPP_VERSION || _LIBCPP_VERSION >= 13) +#if(__cplusplus >= 202002L) && \ + ((!_LIBCPP_VERSION || _LIBCPP_VERSION >= 13) && (!_GLIBCXX_RELEASE || _GLIBCXX_RELEASE >= 10)) using std::identity; #else struct identity {