From a2650ad43b9c8496de7c0f8e16bf85d5b753e71b Mon Sep 17 00:00:00 2001 From: Mingxin Wang Date: Sun, 10 May 2026 22:07:07 +0800 Subject: [PATCH 1/3] Refactor format skill --- CMakeLists.txt | 8 ++ benchmarks/CMakeLists.txt | 7 +- docs/CMakeLists.txt | 6 +- include/proxy/v4/proxy.h | 156 ++++++++++++---------- include/proxy/v4/proxy_fmt.h | 59 ++------ tests/CMakeLists.txt | 11 +- tests/proxy_fmt_format_no_wchar_tests.cpp | 35 +++++ tests/proxy_fmt_format_tests.cpp | 2 + 8 files changed, 144 insertions(+), 140 deletions(-) create mode 100644 tests/proxy_fmt_format_no_wchar_tests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 60e796c..29ce63b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,14 @@ if (BUILD_TESTING) ) FetchContent_MakeAvailable(fmt) + if(MSVC) + set(PROXY_WARNING_FLAGS /W4) + set(PROXY_STRICT_WARNING_FLAGS ${PROXY_WARNING_FLAGS}) + else() + set(PROXY_WARNING_FLAGS -Wall -Wextra -Wpedantic $<$:-Wno-c++2b-extensions>) + set(PROXY_STRICT_WARNING_FLAGS ${PROXY_WARNING_FLAGS}) + endif() + add_subdirectory(tests) add_subdirectory(benchmarks) add_subdirectory(docs) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 061f7e9..f8060e2 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -16,9 +16,4 @@ add_executable(msft_proxy_benchmarks ) target_include_directories(msft_proxy_benchmarks PRIVATE .) target_link_libraries(msft_proxy_benchmarks PRIVATE msft_proxy4::proxy benchmark::benchmark benchmark::benchmark_main) - -if (MSVC) - target_compile_options(msft_proxy_benchmarks PRIVATE /W4) -else() - target_compile_options(msft_proxy_benchmarks PRIVATE -Wall -Wextra -Wpedantic $<$:-Wno-c++2b-extensions>) -endif() +target_compile_options(msft_proxy_benchmarks PRIVATE ${PROXY_STRICT_WARNING_FLAGS}) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index ff9dc5b..b149a12 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -18,11 +18,7 @@ foreach(SOURCE ${EXAMPLE_SOURCES}) get_filename_component(EXECUTABLE_NAME ${SOURCE} NAME_WE) add_executable(${EXECUTABLE_NAME} ${SOURCE}) target_link_libraries(${EXECUTABLE_NAME} PRIVATE msft_proxy4::proxy) - if (MSVC) - target_compile_options(${EXECUTABLE_NAME} PRIVATE /W4) - else() - target_compile_options(${EXECUTABLE_NAME} PRIVATE -Wall -Wextra -Wpedantic $<$:-Wno-c++2b-extensions>) - endif() + target_compile_options(${EXECUTABLE_NAME} PRIVATE ${PROXY_WARNING_FLAGS}) endforeach() target_link_libraries(example_spec_skills_fmt_format PRIVATE fmt::fmt) diff --git a/include/proxy/v4/proxy.h b/include/proxy/v4/proxy.h index 89ea028..2b26da3 100644 --- a/include/proxy/v4/proxy.h +++ b/include/proxy/v4/proxy.h @@ -18,14 +18,14 @@ #include #include #include +#include #if __STDC_HOSTED__ #include -#if __has_include() + +// LLVM libc++ 17 has usable despite lacking __cpp_lib_format until 19. +#if __cpp_lib_format >= 201907L || _LIBCPP_VERSION >= 170000 #include -#endif // __has_include() -#if __cpp_lib_format >= 201907L || \ - (defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 170000) #define PRO4D_HAS_FORMAT #endif // __cpp_lib_format || _LIBCPP_VERSION >= 170000 #endif // __STDC_HOSTED__ @@ -714,9 +714,6 @@ struct facade_conv_traits_impl { template static constexpr bool conv_applicable_ptr = (conv_traits::template applicable_ptr

&& ...); - template - static constexpr bool is_invocable = - std::is_base_of_v, conv_meta>; }; template struct facade_refl_traits_impl { @@ -2148,6 +2145,11 @@ class bad_proxy_cast : public std::bad_cast { namespace details { +template