Skip to content

Commit 10ac3e5

Browse files
jmarrecphlptppre-commit-ci[bot]
authored
update macros for codecvt and support C++26 support on clang19 (#1113)
* Modifies #1100 * That PR comes from https://github.com/phlptp/CLI11 and unfortunately I have no way of opening a PR to that repo, pointing to that branch... The commit you care about is 9a2884a @phlptp where I fix the build error on LLVM 19 with C++26 after rooting the actual template issue (see #1098 (comment)) It comes down to C++26 adding a tuple interface to std::complex https://en.cppreference.com/w/cpp/numeric/complex/tuple_size --------- Co-authored-by: Philip Top <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 7364157 commit 10ac3e5

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

.ci/azure-cmake-new.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
steps:
22
# Note that silkeh/clang does not include ca-certificates, so check the shasum for verification
33
- bash: |
4-
wget --no-check-certificate "https://cmake.org/files/v3.28/cmake-3.28.0-linux-x86_64.tar.gz"
5-
echo "898f0b5ca6e2ea5286998e97bd33f030d7d09f18ca4b88be661fdfbad5dadd88 cmake-3.28.0-linux-x86_64.tar.gz" | shasum -sca 256
4+
wget --no-check-certificate "https://cmake.org/files/v3.31/cmake-3.31.1-linux-x86_64.tar.gz"
5+
echo "3b72fde0d40fa8be617667ea08d12c5ee47f6cf8950c2fbfcf2acfb5f83fb9de cmake-3.31.1-linux-x86_64.tar.gz" | shasum -sca 256
66
displayName: Download CMake
77
88
- task: ExtractFiles@1
@@ -13,5 +13,5 @@ steps:
1313

1414
- bash:
1515
echo
16-
"##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.28.0-linux-x86_64/bin"
16+
"##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.31.1-linux-x86_64/bin"
1717
displayName: Add CMake to PATH

azure-pipelines.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,22 @@ jobs:
165165
vmImage: "ubuntu-latest"
166166
strategy:
167167
matrix:
168-
gcc13:
168+
gcc13_17:
169169
containerImage: gcc:13
170170
cli11.std: 17
171171
cli11.options: -DCMAKE_CXX_FLAGS="-Wstrict-overflow=5"
172-
gcc12:
172+
gcc12_20:
173173
containerImage: gcc:12
174174
cli11.std: 20
175175
cli11.options: -DCMAKE_CXX_FLAGS="-Wredundant-decls -Wconversion"
176-
clang17_20:
176+
clang17_23:
177177
containerImage: silkeh/clang:17
178178
cli11.std: 23
179179
cli11.options: -DCMAKE_CXX_FLAGS=-std=c++23
180+
clang19_26:
181+
containerImage: silkeh/clang:19
182+
cli11.std: 26
183+
cli11.options: -DCMAKE_CXX_FLAGS=-std=c++2c
180184
container: $[ variables['containerImage'] ]
181185
steps:
182186
- template: .ci/azure-cmake-new.yml

include/CLI/Macros.hpp

+20-1
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,27 @@
1818
#define CLI11_CPP17
1919
#if __cplusplus > 201703L
2020
#define CLI11_CPP20
21+
#if __cplusplus > 202002L
22+
#define CLI11_CPP23
23+
#if __cplusplus > 202302L
24+
#define CLI11_CPP26
25+
#endif
26+
#endif
2127
#endif
2228
#endif
2329
#endif
2430
#elif defined(_MSC_VER) && __cplusplus == 199711L
25-
// MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard is fully implemented)
31+
// MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard was fully implemented)
2632
// Unless you use the /Zc:__cplusplus flag on Visual Studio 2017 15.7 Preview 3 or newer
2733
#if _MSVC_LANG >= 201402L
2834
#define CLI11_CPP14
2935
#if _MSVC_LANG > 201402L && _MSC_VER >= 1910
3036
#define CLI11_CPP17
3137
#if _MSVC_LANG > 201703L && _MSC_VER >= 1910
3238
#define CLI11_CPP20
39+
#if _MSVC_LANG > 202002L && _MSC_VER >= 1922
40+
#define CLI11_CPP23
41+
#endif
3342
#endif
3443
#endif
3544
#endif
@@ -96,12 +105,22 @@
96105
#endif
97106

98107
/** <codecvt> availability */
108+
#if !defined(CLI11_CPP26) && !defined(CLI11_HAS_CODECVT)
99109
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && __GNUC__ < 5
100110
#define CLI11_HAS_CODECVT 0
101111
#else
102112
#define CLI11_HAS_CODECVT 1
103113
#include <codecvt>
104114
#endif
115+
#else
116+
#if defined(CLI11_HAS_CODECVT)
117+
#if CLI11_HAS_CODECVT > 0
118+
#include <codecvt>
119+
#endif
120+
#else
121+
#define CLI11_HAS_CODECVT 0
122+
#endif
123+
#endif
105124

106125
/** disable deprecations */
107126
#if defined(__GNUC__) // GCC or clang

include/CLI/TypeTools.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,9 @@ template <typename T>
295295
struct is_wrapper<T, conditional_t<false, void_t<typename T::value_type>, void>> : public std::true_type {};
296296

297297
// Check for tuple like types, as in classes with a tuple_size type trait
298+
// Even though in C++26 std::complex gains a std::tuple interface, for our purposes we treat is as NOT a tuple
298299
template <typename S> class is_tuple_like {
299-
template <typename SS>
300+
template <typename SS, enable_if_t<!is_complex<SS>::value, detail::enabler> = detail::dummy>
300301
// static auto test(int)
301302
// -> decltype(std::conditional<(std::tuple_size<SS>::value > 0), std::true_type, std::false_type>::type());
302303
static auto test(int) -> decltype(std::tuple_size<typename std::decay<SS>::type>::value, std::true_type{});

tests/HelpersTest.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,7 @@ static_assert(CLI::detail::is_tuple_like<std::array<int, 10>>::value, "std::arra
15201520
static_assert(!CLI::detail::is_tuple_like<std::string>::value, "std::string should not be like a tuple");
15211521
static_assert(!CLI::detail::is_tuple_like<double>::value, "double should not be like a tuple");
15221522
static_assert(CLI::detail::is_tuple_like<std::tuple<double, int, double>>::value, "tuple should look like a tuple");
1523+
static_assert(!CLI::detail::is_tuple_like<std::complex<double>>::value, "std::complex should not be like a tuple");
15231524

15241525
TEST_CASE("Types: LexicalConversionTuple2", "[helpers]") {
15251526
CLI::results_t input = {"9.12", "19"};

0 commit comments

Comments
 (0)