From cab2b86d908f7cfb154aecb942dc70681d6f3606 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Wed, 4 Dec 2024 06:06:14 -0800 Subject: [PATCH 1/9] update macros for codecvt and support C++26 support on clang19 --- .ci/azure-cmake-new.yml | 6 +++--- azure-pipelines.yml | 4 ++++ include/CLI/Macros.hpp | 21 ++++++++++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.ci/azure-cmake-new.yml b/.ci/azure-cmake-new.yml index 56a2fb4d9..a30f6c73e 100644 --- a/.ci/azure-cmake-new.yml +++ b/.ci/azure-cmake-new.yml @@ -1,8 +1,8 @@ steps: # Note that silkeh/clang does not include ca-certificates, so check the shasum for verification - bash: | - wget --no-check-certificate "https://cmake.org/files/v3.28/cmake-3.28.0-linux-x86_64.tar.gz" - echo "898f0b5ca6e2ea5286998e97bd33f030d7d09f18ca4b88be661fdfbad5dadd88 cmake-3.28.0-linux-x86_64.tar.gz" | shasum -sca 256 + wget --no-check-certificate "https://cmake.org/files/v3.31/cmake-3.31.1-linux-x86_64.tar.gz" + echo "c4fc2a9bd0cd5f899ccb2fb81ec422e175090bc0de5d90e906dd453b53065719 cmake-3.31.1-linux-x86_64.tar.gz" | shasum -sca 256 displayName: Download CMake - task: ExtractFiles@1 @@ -13,5 +13,5 @@ steps: - bash: echo - "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.28.0-linux-x86_64/bin" + "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.31.1-linux-x86_64/bin" displayName: Add CMake to PATH diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9ee72d11e..63c00a8e4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -177,6 +177,10 @@ jobs: containerImage: silkeh/clang:17 cli11.std: 23 cli11.options: -DCMAKE_CXX_FLAGS=-std=c++23 + clang19_23: + containerImage: silkeh/clang:19 + cli11.std: 26 + cli11.options: -DCMAKE_CXX_FLAGS=-std=c++2c container: $[ variables['containerImage'] ] steps: - template: .ci/azure-cmake-new.yml diff --git a/include/CLI/Macros.hpp b/include/CLI/Macros.hpp index 0d6d17671..f24705ef6 100644 --- a/include/CLI/Macros.hpp +++ b/include/CLI/Macros.hpp @@ -18,11 +18,17 @@ #define CLI11_CPP17 #if __cplusplus > 201703L #define CLI11_CPP20 +#if __cplusplus > 202002L +#define CLI11_CPP23 +#if __cplusplus > 202302L +#define CLI11_CPP26 +#endif +#endif #endif #endif #endif #elif defined(_MSC_VER) && __cplusplus == 199711L -// MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard is fully implemented) +// MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard was fully implemented) // Unless you use the /Zc:__cplusplus flag on Visual Studio 2017 15.7 Preview 3 or newer #if _MSVC_LANG >= 201402L #define CLI11_CPP14 @@ -30,6 +36,9 @@ #define CLI11_CPP17 #if _MSVC_LANG > 201703L && _MSC_VER >= 1910 #define CLI11_CPP20 +#if _MSVC_LANG > 202002L && _MSC_VER >= 1922 +#define CLI11_CPP23 +#endif #endif #endif #endif @@ -96,12 +105,22 @@ #endif /** availability */ +#if !defined(CLI11_CPP26) && !defined(CLI11_HAS_CODECVT) #if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && __GNUC__ < 5 #define CLI11_HAS_CODECVT 0 #else #define CLI11_HAS_CODECVT 1 #include #endif +#else +#if defined(CLI11_HAS_CODECVT) +#if CLI11_HAS_CODECVT>0 +#include +#endif +#else +#define CLI11_HAS_CODECVT 0 +#endif +#endif /** disable deprecations */ #if defined(__GNUC__) // GCC or clang From f743479de41616eda68b69c47255d91d2daddb8c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:15:13 +0000 Subject: [PATCH 2/9] style: pre-commit.ci fixes --- include/CLI/Macros.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/CLI/Macros.hpp b/include/CLI/Macros.hpp index f24705ef6..d62f06739 100644 --- a/include/CLI/Macros.hpp +++ b/include/CLI/Macros.hpp @@ -114,7 +114,7 @@ #endif #else #if defined(CLI11_HAS_CODECVT) -#if CLI11_HAS_CODECVT>0 +#if CLI11_HAS_CODECVT > 0 #include #endif #else From 464306bf4ddb855ccb940b1fd322d825adc50ef7 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Wed, 4 Dec 2024 06:42:49 -0800 Subject: [PATCH 3/9] use correct sha --- .ci/azure-cmake-new.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/azure-cmake-new.yml b/.ci/azure-cmake-new.yml index a30f6c73e..2d9cdee8c 100644 --- a/.ci/azure-cmake-new.yml +++ b/.ci/azure-cmake-new.yml @@ -2,7 +2,7 @@ steps: # Note that silkeh/clang does not include ca-certificates, so check the shasum for verification - bash: | wget --no-check-certificate "https://cmake.org/files/v3.31/cmake-3.31.1-linux-x86_64.tar.gz" - echo "c4fc2a9bd0cd5f899ccb2fb81ec422e175090bc0de5d90e906dd453b53065719 cmake-3.31.1-linux-x86_64.tar.gz" | shasum -sca 256 + echo "3b72fde0d40fa8be617667ea08d12c5ee47f6cf8950c2fbfcf2acfb5f83fb9de cmake-3.31.1-linux-x86_64.tar.gz" | shasum -sca 256 displayName: Download CMake - task: ExtractFiles@1 From bb4e207a0bcbfd76c25897984963ebf6f53b2703 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Wed, 4 Dec 2024 07:28:33 -0800 Subject: [PATCH 4/9] test without macro checks --- include/CLI/Macros.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/CLI/Macros.hpp b/include/CLI/Macros.hpp index d62f06739..e2fba32d8 100644 --- a/include/CLI/Macros.hpp +++ b/include/CLI/Macros.hpp @@ -105,22 +105,22 @@ #endif /** availability */ -#if !defined(CLI11_CPP26) && !defined(CLI11_HAS_CODECVT) +//#if !defined(CLI11_CPP26) && !defined(CLI11_HAS_CODECVT) #if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && __GNUC__ < 5 #define CLI11_HAS_CODECVT 0 #else #define CLI11_HAS_CODECVT 1 #include #endif -#else -#if defined(CLI11_HAS_CODECVT) -#if CLI11_HAS_CODECVT > 0 -#include -#endif -#else -#define CLI11_HAS_CODECVT 0 -#endif -#endif +//#else +//#if defined(CLI11_HAS_CODECVT) +//#if CLI11_HAS_CODECVT > 0 +//#include +//#endif +//#else +//#define CLI11_HAS_CODECVT 0 +//#endif +//#endif /** disable deprecations */ #if defined(__GNUC__) // GCC or clang From e5bbe4c96ac61218b9765a3af86c57a7d676bfb6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:28:57 +0000 Subject: [PATCH 5/9] style: pre-commit.ci fixes --- include/CLI/Macros.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/CLI/Macros.hpp b/include/CLI/Macros.hpp index e2fba32d8..92de18e38 100644 --- a/include/CLI/Macros.hpp +++ b/include/CLI/Macros.hpp @@ -105,22 +105,22 @@ #endif /** availability */ -//#if !defined(CLI11_CPP26) && !defined(CLI11_HAS_CODECVT) +// #if !defined(CLI11_CPP26) && !defined(CLI11_HAS_CODECVT) #if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && __GNUC__ < 5 #define CLI11_HAS_CODECVT 0 #else #define CLI11_HAS_CODECVT 1 #include #endif -//#else -//#if defined(CLI11_HAS_CODECVT) -//#if CLI11_HAS_CODECVT > 0 -//#include -//#endif -//#else -//#define CLI11_HAS_CODECVT 0 -//#endif -//#endif +// #else +// #if defined(CLI11_HAS_CODECVT) +// #if CLI11_HAS_CODECVT > 0 +// #include +// #endif +// #else +// #define CLI11_HAS_CODECVT 0 +// #endif +// #endif /** disable deprecations */ #if defined(__GNUC__) // GCC or clang From 32f46d93ada208db2e993bdd5d1dd7827ebe8c96 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Mon, 23 Dec 2024 04:43:04 -0800 Subject: [PATCH 6/9] rename the tests --- azure-pipelines.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 63c00a8e4..0f8a92c32 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -165,19 +165,19 @@ jobs: vmImage: "ubuntu-latest" strategy: matrix: - gcc13: + gcc13_17: containerImage: gcc:13 cli11.std: 17 cli11.options: -DCMAKE_CXX_FLAGS="-Wstrict-overflow=5" - gcc12: + gcc12_20: containerImage: gcc:12 cli11.std: 20 cli11.options: -DCMAKE_CXX_FLAGS="-Wredundant-decls -Wconversion" - clang17_20: + clang17_23: containerImage: silkeh/clang:17 cli11.std: 23 cli11.options: -DCMAKE_CXX_FLAGS=-std=c++23 - clang19_23: + clang19_26: containerImage: silkeh/clang:19 cli11.std: 26 cli11.options: -DCMAKE_CXX_FLAGS=-std=c++2c From 57e2f5f03f82ad8414ef55ceb19565003405aaa8 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Mon, 23 Dec 2024 11:10:12 -0800 Subject: [PATCH 7/9] latest macos with cpp26 --- azure-pipelines.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0f8a92c32..e234be144 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -49,9 +49,12 @@ jobs: Linux14PC: vmImage: "ubuntu-latest" cli11.precompile: ON - macOS-15_23: + macOS-15_26: vmImage: "macOS-15" cli11.std: 23 + macOS-15_23: + vmImage: "macOS-15" + cli11.std: 26 macOS-14_20: vmImage: "macOS-14" cli11.std: 20 From e43ff02c1142bf6c20ae3e3befb0e39ec2d1cdbc Mon Sep 17 00:00:00 2001 From: Philip Top Date: Wed, 1 Jan 2025 07:06:45 -0800 Subject: [PATCH 8/9] add commented out macro definitions back in. --- azure-pipelines.yml | 5 +---- include/CLI/Macros.hpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e234be144..0f8a92c32 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -49,12 +49,9 @@ jobs: Linux14PC: vmImage: "ubuntu-latest" cli11.precompile: ON - macOS-15_26: - vmImage: "macOS-15" - cli11.std: 23 macOS-15_23: vmImage: "macOS-15" - cli11.std: 26 + cli11.std: 23 macOS-14_20: vmImage: "macOS-14" cli11.std: 20 diff --git a/include/CLI/Macros.hpp b/include/CLI/Macros.hpp index 92de18e38..d62f06739 100644 --- a/include/CLI/Macros.hpp +++ b/include/CLI/Macros.hpp @@ -105,22 +105,22 @@ #endif /** availability */ -// #if !defined(CLI11_CPP26) && !defined(CLI11_HAS_CODECVT) +#if !defined(CLI11_CPP26) && !defined(CLI11_HAS_CODECVT) #if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && __GNUC__ < 5 #define CLI11_HAS_CODECVT 0 #else #define CLI11_HAS_CODECVT 1 #include #endif -// #else -// #if defined(CLI11_HAS_CODECVT) -// #if CLI11_HAS_CODECVT > 0 -// #include -// #endif -// #else -// #define CLI11_HAS_CODECVT 0 -// #endif -// #endif +#else +#if defined(CLI11_HAS_CODECVT) +#if CLI11_HAS_CODECVT > 0 +#include +#endif +#else +#define CLI11_HAS_CODECVT 0 +#endif +#endif /** disable deprecations */ #if defined(__GNUC__) // GCC or clang From 9a2884ad6ac0b00dfb329c45a8567cfef1b4a54e Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 6 Jan 2025 12:22:00 +0100 Subject: [PATCH 9/9] Don't treat std::complex as is_tuple_like for our purpose --- include/CLI/TypeTools.hpp | 3 ++- tests/HelpersTest.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/CLI/TypeTools.hpp b/include/CLI/TypeTools.hpp index cbae1631a..73d5abc86 100644 --- a/include/CLI/TypeTools.hpp +++ b/include/CLI/TypeTools.hpp @@ -295,8 +295,9 @@ template struct is_wrapper, void>> : public std::true_type {}; // Check for tuple like types, as in classes with a tuple_size type trait +// Even though in C++26 std::complex gains a std::tuple interface, for our purposes we treat is as NOT a tuple template class is_tuple_like { - template + template ::value, detail::enabler> = detail::dummy> // static auto test(int) // -> decltype(std::conditional<(std::tuple_size::value > 0), std::true_type, std::false_type>::type()); static auto test(int) -> decltype(std::tuple_size::type>::value, std::true_type{}); diff --git a/tests/HelpersTest.cpp b/tests/HelpersTest.cpp index 71dbee305..4d8af47f6 100644 --- a/tests/HelpersTest.cpp +++ b/tests/HelpersTest.cpp @@ -1520,6 +1520,7 @@ static_assert(CLI::detail::is_tuple_like>::value, "std::arra static_assert(!CLI::detail::is_tuple_like::value, "std::string should not be like a tuple"); static_assert(!CLI::detail::is_tuple_like::value, "double should not be like a tuple"); static_assert(CLI::detail::is_tuple_like>::value, "tuple should look like a tuple"); +static_assert(!CLI::detail::is_tuple_like>::value, "std::complex should not be like a tuple"); TEST_CASE("Types: LexicalConversionTuple2", "[helpers]") { CLI::results_t input = {"9.12", "19"};