From a06a17c4d53ff8394eda0607fc6eb45526f2625d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= <mosra@centrum.cz>
Date: Mon, 3 Apr 2023 16:29:02 +0200
Subject: [PATCH] Utility: adapt std::tuple and std::array fwdecl for libc++
 16+.

Co-authored-by: Stanislaw Halik <sthalik@misaki.pl>
---
 doc/corrade-changelog.dox             | 2 ++
 src/Corrade/Utility/StlForwardArray.h | 8 +++++++-
 src/Corrade/Utility/StlForwardTuple.h | 8 +++++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/Corrade/Utility/StlForwardArray.h b/src/Corrade/Utility/StlForwardArray.h
index a2ace7ae7..28666ea96 100644
--- a/src/Corrade/Utility/StlForwardArray.h
+++ b/src/Corrade/Utility/StlForwardArray.h
@@ -55,8 +55,14 @@ possible or is unknown is equivalent to @cpp #include <array> @ce.
 #include "Corrade/configure.h"
 
 #ifdef CORRADE_TARGET_LIBCXX
-/* https://github.com/llvm-mirror/libcxx/blob/73d2eccc78ac83d5947243c4d26a53f668b4f432/include/__tuple#L223 */
+/* https://github.com/llvm-mirror/libcxx/blob/73d2eccc78ac83d5947243c4d26a53f668b4f432/include/__tuple#L223,
+   then it got granularized to smaller headers in Clang 16:
+   https://github.com/llvm/llvm-project/commit/2d52c6bfae801b016dd3627b8c0e7c4a99405549 */
+#if _LIBCPP_VERSION < 160000
 #include <__tuple>
+#else
+#include <__fwd/array.h>
+#endif
 #elif defined(CORRADE_TARGET_DINKUMWARE)
 /* MSVC has it defined next to std::pair */
 #include <utility>
diff --git a/src/Corrade/Utility/StlForwardTuple.h b/src/Corrade/Utility/StlForwardTuple.h
index 2071021f4..ca096a30d 100644
--- a/src/Corrade/Utility/StlForwardTuple.h
+++ b/src/Corrade/Utility/StlForwardTuple.h
@@ -55,8 +55,14 @@ is equivalent to @cpp #include <tuple> @ce.
 #include "Corrade/configure.h"
 
 #ifdef CORRADE_TARGET_LIBCXX
-/* https://github.com/llvm-mirror/libcxx/blob/73d2eccc78ac83d5947243c4d26a53f668b4f432/include/__tuple#L163 */
+/* https://github.com/llvm-mirror/libcxx/blob/73d2eccc78ac83d5947243c4d26a53f668b4f432/include/__tuple#L163,
+   then it got granularized to smaller headers in Clang 16:
+   https://github.com/llvm/llvm-project/commit/2d52c6bfae801b016dd3627b8c0e7c4a99405549 */
+#if _LIBCPP_VERSION < 160000
 #include <__tuple>
+#else
+#include <__fwd/tuple.h>
+#endif
 #elif defined(CORRADE_TARGET_LIBSTDCXX)
 #if _GLIBCXX_RELEASE >= 7 && _GLIBCXX_RELEASE < 12
 /* https://github.com/gcc-mirror/gcc/blob/releases/gcc-7.1.0/libstdc++-v3/include/std/type_traits#L2557-L2558
