From 85d75d649847c5a5bb476148551a91a37d1e1e29 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 9 Feb 2026 00:47:15 -0500 Subject: [PATCH 1/2] introduced vgkit_check_p0522r0 --- modules/CheckCXXFeatures.cmake | 54 +++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/modules/CheckCXXFeatures.cmake b/modules/CheckCXXFeatures.cmake index 0f58c2f..271b807 100644 --- a/modules/CheckCXXFeatures.cmake +++ b/modules/CheckCXXFeatures.cmake @@ -137,4 +137,56 @@ int main() { std::unordered_map m; m[\"k\"]=1; return 0; } unset(_clmm_modify_global) -endmacro(vgkit_check_libcxx_linker_mismatch) \ No newline at end of file +endmacro(vgkit_check_libcxx_linker_mismatch) + +# P0522R0 (relaxed matching of template template arguments) is required by +# code that passes class templates with defaulted parameters (e.g. +# small_vector) to template template parameters expecting fewer +# args (e.g. template class Container). +# +# - GCC has supported this since GCC 7 (default in all C++17 modes) +# - LLVM Clang enabled it by default in Clang 19; earlier versions need +# -frelaxed-template-template-args +# - AppleClang 17+ works; AppleClang 16 and earlier do not support it at all +# +# This macro tests whether P0522R0 works out of the box and, if not, tries +# adding -frelaxed-template-template-args. +# +# Sets VGKIT_P0522R0_COMPILE_FLAG in the caller's scope to the compile +# option needed (empty string if P0522R0 works natively). The caller +# decides how to apply it (e.g. target_compile_options on specific targets). +# On failure, emits FATAL_ERROR. +macro(vgkit_check_p0522r0) + + set(VGKIT_P0522R0_COMPILE_FLAG) + + cmake_push_check_state(RESET) + check_cxx_source_compiles(" +template struct SmallVec {}; +template