From 1501251e87acf03e4246ad1884cba71ac7c2fab2 Mon Sep 17 00:00:00 2001 From: DockedFerret800 Date: Mon, 3 Aug 2026 14:59:34 +0100 Subject: [PATCH 1/2] Suppress C4996 on MSVC --- include/ut/ut.hpp | 3 +++ modules/ut.ixx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/include/ut/ut.hpp b/include/ut/ut.hpp index 10af7f9..4adedaa 100644 --- a/include/ut/ut.hpp +++ b/include/ut/ut.hpp @@ -231,6 +231,9 @@ namespace ut } } else { +#if defined(_MSC_VER) +#pragma warning(suppress : 4996) +#endif static const std::string_view filter = []() -> std::string_view { if (const char* env = std::getenv("UT_RUN")) return env; return {}; diff --git a/modules/ut.ixx b/modules/ut.ixx index 9b68004..6c8b89d 100644 --- a/modules/ut.ixx +++ b/modules/ut.ixx @@ -225,6 +225,9 @@ namespace ut } } else { +#if defined(_MSC_VER) +#pragma warning(suppress : 4996) +#endif static const std::string_view filter = []() -> std::string_view { if (const char* env = std::getenv("UT_RUN")) return env; return {}; From bc979c15ae8cb2ca4cb47f9630dd5bd9706d34e5 Mon Sep 17 00:00:00 2001 From: DockedFerret800 Date: Mon, 3 Aug 2026 15:28:38 +0100 Subject: [PATCH 2/2] Separate run_filter function --- include/ut/ut.hpp | 24 ++++++++++++++++-------- modules/ut.ixx | 22 ++++++++++++++-------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/include/ut/ut.hpp b/include/ut/ut.hpp index 4adedaa..07d4909 100644 --- a/include/ut/ut.hpp +++ b/include/ut/ut.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include namespace ut @@ -40,6 +41,20 @@ namespace ut { using type = T; }; + + [[nodiscard]] inline const std::string& run_filter() + { + static const std::string filter = [] { +#if defined(_MSC_VER) +#pragma warning(suppress : 4996) +#endif + const char* const env = std::getenv("UT_RUN"); + + return env != nullptr ? std::string{env} : std::string{}; + }(); + + return filter; + } } template @@ -231,14 +246,7 @@ namespace ut } } else { -#if defined(_MSC_VER) -#pragma warning(suppress : 4996) -#endif - static const std::string_view filter = []() -> std::string_view { - if (const char* env = std::getenv("UT_RUN")) return env; - return {}; - }(); - + const auto& filter = detail::run_filter(); auto matches_filter = [](std::string_view test_name, std::string_view f) { if (f.empty()) return true; diff --git a/modules/ut.ixx b/modules/ut.ixx index 6c8b89d..7890dd5 100644 --- a/modules/ut.ixx +++ b/modules/ut.ixx @@ -34,6 +34,19 @@ namespace ut { using type = T; }; + [[nodiscard]] inline const std::string& run_filter() + { + static const std::string filter = [] { +#if defined(_MSC_VER) +#pragma warning(suppress : 4996) +#endif + const char* const env = std::getenv("UT_RUN"); + + return env != nullptr ? std::string{env} : std::string{}; + }(); + + return filter; + } } export template @@ -225,14 +238,7 @@ namespace ut } } else { -#if defined(_MSC_VER) -#pragma warning(suppress : 4996) -#endif - static const std::string_view filter = []() -> std::string_view { - if (const char* env = std::getenv("UT_RUN")) return env; - return {}; - }(); - + const auto& filter = detail::run_filter(); auto matches_filter = [](std::string_view test_name, std::string_view f) { if (f.empty()) return true;