Commit 265df85d authored by jan.koester's avatar jan.koester
Browse files

cxx: iter_difference_t below C++20 again; <numbers>, <source_location> only in C++20

<format> (format_to_n) needs iter_difference_t in C++17 code too --
fresh, makeplus and ninja stopped compiling once it moved into the
C++20 iterator concepts. The new C++20-only headers are empty below
C++20, as in libstdc++.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 1800ead2
Loading
Loading
Loading
Loading
+17 −0
Changes for include/cxx/__iterator_concepts: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -43,6 +43,23 @@
#include <__iterator_base>
#include <__identity>

#if !(defined(__cpp_concepts) && __cpp_concepts >= 201907L)
/* Below C++20 only iter_difference_t, as <iterator> had it before
 * (<format>'s format_to_n uses it also in C++17 code -- fresh, makeplus,
 * ninja): the iterator's difference_type, ptrdiff_t when it has none or
 * void. */
namespace std __attribute__((__visibility__("default"))) {
namespace __itc {
    template<class It, class = void> struct _diff17 { typedef ptrdiff_t type; };
    template<class It> struct _diff17<It, void_t<typename iterator_traits<It>::difference_type>> {
        typedef typename iterator_traits<It>::difference_type _d;
        typedef conditional_t<is_void<_d>::value, ptrdiff_t, _d> type;
    };
}
template<class It> using iter_difference_t = typename __itc::_diff17<remove_cvref_t<It>>::type;
}
#endif

#if defined(__cpp_concepts) && __cpp_concepts >= 201907L

namespace std __attribute__((__visibility__("default"))) {
+4 −0
Changes for include/cxx/numbers: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@

#pragma once

#if __cplusplus > 201703L

/* C++20 <numbers>: the mathematical constants (real gap: Node.js'
 * histogram.cc std::numbers::pi), as variable templates over the
 * floating-point types plus the double shorthands. */
@@ -59,3 +61,5 @@ __SYSTEMPP_NUMBER(phi, 1.618033988749894848204586834365638118)

}
}

#endif
+4 −0
Changes for include/cxx/source_location: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@

#pragma once

#if __cplusplus > 201703L

/* C++20 std::source_location (real gap: V8's v8-source-location.h).
 * __builtin_source_location() returns a pointer to a compiler-made
 * object of type std::source_location::__impl, whose members clang
@@ -58,3 +60,5 @@ public:
};

}

#endif