From ce7241c759907f056d5a9dc8e6776970a7f0e83c Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 11 Aug 2025 07:35:33 -0400 Subject: [PATCH 01/13] Remove traceableException feature and downgrade support of c++20 to c++17 --- CMakeLists.txt | 9 ++- cmake/ystdlib-helpers.cmake | 10 +-- src/ystdlib/error_handling/CMakeLists.txt | 2 - .../error_handling/TraceableException.hpp | 78 ------------------- .../test/test_TraceableException.cpp | 67 ---------------- 5 files changed, 10 insertions(+), 156 deletions(-) delete mode 100644 src/ystdlib/error_handling/TraceableException.hpp delete mode 100644 src/ystdlib/error_handling/test/test_TraceableException.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f368bfe5..d74fd5ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,12 @@ include(ystdlib-helpers) option(BUILD_SHARED_LIBS "Build using shared libraries." OFF) option(ystdlib_BUILD_TESTING "Build the testing tree for ystdlib." ON) -# Require compiler versions that support the C++20 features necessary for compiling ystdlib +# Require compiler versions that support the C++17 features necessary for compiling ystdlib +# See also: https://en.cppreference.com/w/cpp/compiler_support/17 if("AppleClang" STREQUAL "${CMAKE_CXX_COMPILER_ID}") - set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "16") + set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "15") elseif("Clang" STREQUAL "${CMAKE_CXX_COMPILER_ID}") - set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "16") + set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "15") elseif("GNU" STREQUAL "${CMAKE_CXX_COMPILER_ID}") set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "11") else() @@ -74,7 +75,7 @@ if(ystdlib_ENABLE_TESTS) set(UNIFIED_UNIT_TEST_TARGET "unit-test-all") add_executable(${UNIFIED_UNIT_TEST_TARGET}) target_link_libraries(${UNIFIED_UNIT_TEST_TARGET} PRIVATE Catch2::Catch2WithMain) - target_compile_features(${UNIFIED_UNIT_TEST_TARGET} PRIVATE cxx_std_20) + target_compile_features(${UNIFIED_UNIT_TEST_TARGET} PRIVATE cxx_std_17) set_property( TARGET ${UNIFIED_UNIT_TEST_TARGET} diff --git a/cmake/ystdlib-helpers.cmake b/cmake/ystdlib-helpers.cmake index 67e7c538..dc222e29 100644 --- a/cmake/ystdlib-helpers.cmake +++ b/cmake/ystdlib-helpers.cmake @@ -31,7 +31,7 @@ function(check_if_header_only SOURCE_LIST IS_HEADER_ONLY NON_HEADER_FILE) set(${NON_HEADER_FILE} "" PARENT_SCOPE) endfunction() -# Adds a C++20 library in the subdirectory NAME with the target NAME and alias NAMESPACE::NAME. +# Adds a C++17 library in the subdirectory NAME with the target NAME and alias NAMESPACE::NAME. # Libraries with multiple levels of namespace nesting are currently not supported. # # @param {string} NAME @@ -87,7 +87,7 @@ function(add_cpp_library) add_library(${ARG_NAME} INTERFACE) target_link_libraries(${ARG_NAME} INTERFACE ${ARG_PUBLIC_LINK_LIBRARIES}) - target_compile_features(${ARG_NAME} INTERFACE cxx_std_20) + target_compile_features(${ARG_NAME} INTERFACE cxx_std_17) else() add_library(${ARG_NAME}) target_sources(${ARG_NAME} PRIVATE ${ARG_PRIVATE_SOURCES}) @@ -98,7 +98,7 @@ function(add_cpp_library) PRIVATE ${ARG_PRIVATE_LINK_LIBRARIES} ) - target_compile_features(${ARG_NAME} PUBLIC cxx_std_20) + target_compile_features(${ARG_NAME} PUBLIC cxx_std_17) endif() add_library(${ALIAS_TARGET_NAME} ALIAS ${ARG_NAME}) @@ -114,7 +114,7 @@ function(add_cpp_library) ) endfunction() -# Adds a C++ 20 test executable named `unit-test-NAME` that will be built with `SOURCES` and linked +# Adds a C++ 17 test executable named `unit-test-NAME` that will be built with `SOURCES` and linked # with `LINK_LIBRARIES`, in addition to Catch2. # # @param {string} NAME @@ -153,7 +153,7 @@ function(add_catch2_tests) ${ARG_LINK_LIBRARIES} Catch2::Catch2WithMain ) - target_compile_features(${UNIT_TEST_TARGET} PRIVATE cxx_std_20) + target_compile_features(${UNIT_TEST_TARGET} PRIVATE cxx_std_17) set_property( TARGET ${UNIT_TEST_TARGET} diff --git a/src/ystdlib/error_handling/CMakeLists.txt b/src/ystdlib/error_handling/CMakeLists.txt index d60f0bfc..932e1512 100644 --- a/src/ystdlib/error_handling/CMakeLists.txt +++ b/src/ystdlib/error_handling/CMakeLists.txt @@ -16,7 +16,6 @@ add_cpp_library( NAMESPACE ystdlib PUBLIC_HEADERS ErrorCode.hpp - TraceableException.hpp Result.hpp utils.hpp PUBLIC_LINK_LIBRARIES @@ -30,7 +29,6 @@ if(ystdlib_ENABLE_TESTS) SOURCES test/test_ErrorCode.cpp test/test_Result.cpp - test/test_TraceableException.cpp test/types.cpp UNIFIED_TEST_TARGET "${UNIFIED_UNIT_TEST_TARGET}" ) diff --git a/src/ystdlib/error_handling/TraceableException.hpp b/src/ystdlib/error_handling/TraceableException.hpp deleted file mode 100644 index 43a34d70..00000000 --- a/src/ystdlib/error_handling/TraceableException.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef YSTDLIB_ERROR_HANDLING_TRACEABLEEXCEPTION_HPP -#define YSTDLIB_ERROR_HANDLING_TRACEABLEEXCEPTION_HPP - -#include -#include -#include -#include -#include -#include - -#include "utils.hpp" - -namespace ystdlib::error_handling { -/** - * An exception class that is thrown with an `std::error_code`. - * - * This class extends `std::exception` and can be thrown with an `std::error_code` argument. It also - * provides additional information to aid in debugging by storing details in `std::source_location`, - * including the function name, file name, and line number of the throwing location. - * - * @see std::source_location::file_name() - * @see std::source_location::function_name() - * @see std::source_location::line() - */ -class TraceableException : public std::exception { -public: - // Constructors - explicit TraceableException( - std::error_code error_code, - std::source_location const& where = std::source_location::current() - ) - : m_error_code{error_code}, - m_where{where} { - std::ostringstream oss; - oss << where; - m_what = oss.str(); - } - - explicit TraceableException( - std::error_code error_code, - std::string message, - std::source_location const& where = std::source_location::current() - ) - : m_error_code{error_code}, - m_what{std::move(message)}, - m_where{where} {} - - // Methods implementing std::exception - [[nodiscard]] auto what() const noexcept -> char const* override { return m_what.c_str(); } - - // Methods - [[nodiscard]] auto error_code() const -> std::error_code { return m_error_code; } - - [[nodiscard]] auto what() -> std::string& { return m_what; } - - [[nodiscard]] auto where() const noexcept -> std::source_location const& { return m_where; } - -private: - // Variables - std::error_code m_error_code; - std::string m_what; - std::source_location m_where; -}; -} // namespace ystdlib::error_handling - -// NOLINTBEGIN(bugprone-macro-parentheses, cppcoreguidelines-macro-usage) -/** - * Defines a derived `TraceableException` class with the given class name. - * - * @param T The class' name. - */ -#define YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION(T) \ - class T : public ystdlib::error_handling::TraceableException { \ - using ystdlib::error_handling::TraceableException::TraceableException; \ - } -// NOLINTEND(bugprone-macro-parentheses, cppcoreguidelines-macro-usage) - -#endif // YSTDLIB_ERROR_HANDLING_TRACEABLEEXCEPTION_HPP diff --git a/src/ystdlib/error_handling/test/test_TraceableException.cpp b/src/ystdlib/error_handling/test/test_TraceableException.cpp deleted file mode 100644 index 0fec7953..00000000 --- a/src/ystdlib/error_handling/test/test_TraceableException.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include -#include - -#include - -#include - -#include "types.hpp" - -using ystdlib::error_handling::TraceableException; - -namespace { -constexpr auto cCustomFailureDescription{"This operation failed due to invalid args."}; -constexpr auto cCurrentFileName{"src/ystdlib/error_handling/test/test_TraceableException.cpp"}; -constexpr auto cSuccessFuncName{ - "static void ystdlib::error_handling::test::Worker::execute_with_success()" -}; -constexpr auto cFailureFuncName{ - "static void ystdlib::error_handling::test::Worker::execute_with_failure()" -}; -} // namespace - -namespace ystdlib::error_handling::test { -class Worker { -public: - YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION(OperationFailed); - - static auto execute_with_success() -> void { - throw OperationFailed(BinaryErrorCode{BinaryErrorCodeEnum::Success}); - } - - static auto execute_with_failure() -> void { - throw OperationFailed( - BinaryErrorCode{BinaryErrorCodeEnum::Failure}, - cCustomFailureDescription - ); - } -}; -} // namespace ystdlib::error_handling::test - -namespace { -template -[[nodiscard]] auto capture_exception(Callable&& f) -> TraceableException; - -template -auto capture_exception(Callable&& f) -> TraceableException { - try { - std::forward(f)(); - } catch (TraceableException& e) { - return e; - } - assert(false && "The function is expected to throw."); -} -} // namespace - -namespace ystdlib::error_handling::test { -TEST_CASE("test_traceable_exception", "[error_handling][TraceableException]") { - auto const ex_success{capture_exception(Worker::execute_with_success)}; - REQUIRE(std::string{ex_success.where().file_name()}.ends_with(cCurrentFileName)); - REQUIRE((0 == std::strcmp(ex_success.where().function_name(), cSuccessFuncName))); - - auto const ex_failure{capture_exception(Worker::execute_with_failure)}; - REQUIRE((0 == std::strcmp(ex_failure.what(), cCustomFailureDescription))); - REQUIRE(std::string{ex_failure.where().file_name()}.ends_with(cCurrentFileName)); - REQUIRE((0 == std::strcmp(ex_failure.where().function_name(), cFailureFuncName))); -} -} // namespace ystdlib::error_handling::test From 178446768ac7d1668b975e27a9319806a68a7bc2 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Tue, 12 Aug 2025 03:54:13 -0400 Subject: [PATCH 02/13] Change compile definitions back to c++20 --- CMakeLists.txt | 2 +- cmake/ystdlib-helpers.cmake | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d74fd5ee..3a4f91a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,7 @@ if(ystdlib_ENABLE_TESTS) set(UNIFIED_UNIT_TEST_TARGET "unit-test-all") add_executable(${UNIFIED_UNIT_TEST_TARGET}) target_link_libraries(${UNIFIED_UNIT_TEST_TARGET} PRIVATE Catch2::Catch2WithMain) - target_compile_features(${UNIFIED_UNIT_TEST_TARGET} PRIVATE cxx_std_17) + target_compile_features(${UNIFIED_UNIT_TEST_TARGET} PRIVATE cxx_std_20) set_property( TARGET ${UNIFIED_UNIT_TEST_TARGET} diff --git a/cmake/ystdlib-helpers.cmake b/cmake/ystdlib-helpers.cmake index dc222e29..2c76d408 100644 --- a/cmake/ystdlib-helpers.cmake +++ b/cmake/ystdlib-helpers.cmake @@ -31,7 +31,7 @@ function(check_if_header_only SOURCE_LIST IS_HEADER_ONLY NON_HEADER_FILE) set(${NON_HEADER_FILE} "" PARENT_SCOPE) endfunction() -# Adds a C++17 library in the subdirectory NAME with the target NAME and alias NAMESPACE::NAME. +# Adds a C++20 library in the subdirectory NAME with the target NAME and alias NAMESPACE::NAME. # Libraries with multiple levels of namespace nesting are currently not supported. # # @param {string} NAME @@ -87,7 +87,7 @@ function(add_cpp_library) add_library(${ARG_NAME} INTERFACE) target_link_libraries(${ARG_NAME} INTERFACE ${ARG_PUBLIC_LINK_LIBRARIES}) - target_compile_features(${ARG_NAME} INTERFACE cxx_std_17) + target_compile_features(${ARG_NAME} INTERFACE cxx_std_20) else() add_library(${ARG_NAME}) target_sources(${ARG_NAME} PRIVATE ${ARG_PRIVATE_SOURCES}) @@ -98,7 +98,7 @@ function(add_cpp_library) PRIVATE ${ARG_PRIVATE_LINK_LIBRARIES} ) - target_compile_features(${ARG_NAME} PUBLIC cxx_std_17) + target_compile_features(${ARG_NAME} PUBLIC cxx_std_20) endif() add_library(${ALIAS_TARGET_NAME} ALIAS ${ARG_NAME}) @@ -114,7 +114,7 @@ function(add_cpp_library) ) endfunction() -# Adds a C++ 17 test executable named `unit-test-NAME` that will be built with `SOURCES` and linked +# Adds a C++20 test executable named `unit-test-NAME` that will be built with `SOURCES` and linked # with `LINK_LIBRARIES`, in addition to Catch2. # # @param {string} NAME @@ -153,7 +153,7 @@ function(add_catch2_tests) ${ARG_LINK_LIBRARIES} Catch2::Catch2WithMain ) - target_compile_features(${UNIT_TEST_TARGET} PRIVATE cxx_std_17) + target_compile_features(${UNIT_TEST_TARGET} PRIVATE cxx_std_20) set_property( TARGET ${UNIT_TEST_TARGET} From 292e6de4c438d36135fe3a861080dc2fc93e9170 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Tue, 12 Aug 2025 04:10:42 -0400 Subject: [PATCH 03/13] Setup and validate compiler versions --- CMakeLists.txt | 29 +++-------- .../Toolchains/llvm-clang-15-toolchain.cmake | 21 ++++++++ cmake/Toolchains/utils.cmake | 49 +++++++++++++++++++ 3 files changed, 77 insertions(+), 22 deletions(-) create mode 100644 cmake/Toolchains/llvm-clang-15-toolchain.cmake create mode 100644 cmake/Toolchains/utils.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a4f91a3..ce486a6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,14 @@ cmake_minimum_required(VERSION 3.23) +# Toolchain setup must come before the first project() call in the entire CMake buildsystem. +# If ystdlib is not the top-level project, the following setup has no effect. +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/utils.cmake") +setup_toolchains() + project(ystdlib VERSION "0.1.0" LANGUAGES CXX) +validate_compiler_versions() + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include(CMakePackageConfigHelpers) include(GNUInstallDirs) @@ -10,28 +17,6 @@ include(ystdlib-helpers) option(BUILD_SHARED_LIBS "Build using shared libraries." OFF) option(ystdlib_BUILD_TESTING "Build the testing tree for ystdlib." ON) -# Require compiler versions that support the C++17 features necessary for compiling ystdlib -# See also: https://en.cppreference.com/w/cpp/compiler_support/17 -if("AppleClang" STREQUAL "${CMAKE_CXX_COMPILER_ID}") - set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "15") -elseif("Clang" STREQUAL "${CMAKE_CXX_COMPILER_ID}") - set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "15") -elseif("GNU" STREQUAL "${CMAKE_CXX_COMPILER_ID}") - set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "11") -else() - message( - FATAL_ERROR - "Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}. Please use AppleClang, Clang, or GNU." - ) -endif() -if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "${ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION}") - message( - FATAL_ERROR - "${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at \ - least ${ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION}." - ) -endif() - set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL diff --git a/cmake/Toolchains/llvm-clang-15-toolchain.cmake b/cmake/Toolchains/llvm-clang-15-toolchain.cmake new file mode 100644 index 00000000..9a13cc3b --- /dev/null +++ b/cmake/Toolchains/llvm-clang-15-toolchain.cmake @@ -0,0 +1,21 @@ +message(STATUS "Setting up LLVM v15 toolchain...") + +execute_process( + COMMAND + "brew" "--prefix" "llvm@15" + RESULT_VARIABLE BREW_RESULT + OUTPUT_VARIABLE LLVM_TOOLCHAIN_PREFIX + OUTPUT_STRIP_TRAILING_WHITESPACE +) +if(NOT 0 EQUAL BREW_RESULT) + message( + FATAL_ERROR + "Failed to locate LLVM v15 using Homebrew. Please ensure llvm@15 is installed: 'brew \ + install llvm@15'" + ) +endif() + +set(CMAKE_C_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang") +set(CMAKE_CXX_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang++") +set(CMAKE_AR "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ar") +set(CMAKE_RANLIB "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ranlib") diff --git a/cmake/Toolchains/utils.cmake b/cmake/Toolchains/utils.cmake new file mode 100644 index 00000000..b918b71a --- /dev/null +++ b/cmake/Toolchains/utils.cmake @@ -0,0 +1,49 @@ +# This file contains utility functions for setting up toolchains and validating toolchain versions +# to ensure compatibility with the C++20 features required by the project. + +# Sets up the appropriate toolchain file based on the host system. +function(setup_toolchains) + # For macOS versions below 15, use the LLVM 15 Clang toolchain. + if("Darwin" STREQUAL "${CMAKE_HOST_SYSTEM_NAME}") + execute_process( + COMMAND + "sw_vers" "--productVersion" + OUTPUT_VARIABLE MACOS_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if("${MACOS_VERSION}" VERSION_LESS "15") + set(CMAKE_TOOLCHAIN_FILE + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/llvm-clang-15-toolchain.cmake" + CACHE STRING + "Toolchain file" + ) + endif() + endif() +endfunction() + +# Checks if the compiler ID and version meet the minimum requirements to support C++20 features +# required by the project: +# - AppleClang: version 15+ +# - Clang: version 15+ +# - GNU: version 11+ +function(validate_compiler_versions) + if("AppleClang" STREQUAL "${CMAKE_CXX_COMPILER_ID}") + set(CXX_COMPILER_MIN_VERSION "15") + elseif("Clang" STREQUAL "${CMAKE_CXX_COMPILER_ID}") + set(CXX_COMPILER_MIN_VERSION "15") + elseif("GNU" STREQUAL "${CMAKE_CXX_COMPILER_ID}") + set(CXX_COMPILER_MIN_VERSION "11") + else() + message( + FATAL_ERROR + "Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}. Please use AppleClang, Clang, or GNU." + ) + endif() + if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "${CXX_COMPILER_MIN_VERSION}") + message( + FATAL_ERROR + "${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at \ + least ${CXX_COMPILER_MIN_VERSION}." + ) + endif() +endfunction() From 5070e2625f2c7b5ddb2449a335a13e0f8e37fdaa Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Tue, 12 Aug 2025 13:51:37 -0400 Subject: [PATCH 04/13] Transform all usages of std::ranges and std::views --- src/ystdlib/containers/Array.hpp | 2 +- src/ystdlib/containers/test/test_Array.cpp | 39 ++++++++++++------- .../error_handling/test/test_ErrorCode.cpp | 19 ++++++--- src/ystdlib/error_handling/test/types.cpp | 2 +- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/src/ystdlib/containers/Array.hpp b/src/ystdlib/containers/Array.hpp index c46b49c9..f175aef5 100644 --- a/src/ystdlib/containers/Array.hpp +++ b/src/ystdlib/containers/Array.hpp @@ -37,7 +37,7 @@ class Array { // NOLINTNEXTLINE(*-avoid-c-arrays) : m_data{std::make_unique(list.size())}, m_size{list.size()} { - std::ranges::copy(list, m_data.get()); + std::copy(list.begin(), list.end(), m_data.get()); } // Disable copy constructor and assignment operator diff --git a/src/ystdlib/containers/test/test_Array.cpp b/src/ystdlib/containers/test/test_Array.cpp index 2d423a9c..966eb638 100644 --- a/src/ystdlib/containers/test/test_Array.cpp +++ b/src/ystdlib/containers/test/test_Array.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -66,9 +65,12 @@ void test_list_initialization_in_function_call( ystdlib::containers::Array const& arr, std::vector const& data ) { - REQUIRE(std::ranges::equal( - arr | std::views::transform([](auto const& obj) { return obj.get_value(); }), - data + REQUIRE(std::equal( + arr.begin(), + arr.end(), + data.begin(), + data.end(), + [](auto const& obj, size_t v) { return obj.get_value() == v; } )); } } // namespace @@ -88,7 +90,7 @@ TEST_CASE("test_array_reference", "[containers][Array]") { arr.at(idx) = idx; } auto const& arr_const_ref = arr; - REQUIRE(std::ranges::equal(arr, arr_const_ref)); + REQUIRE(std::equal(arr.begin(), arr.end(), arr_const_ref.begin(), arr_const_ref.end())); } TEST_CASE("test_array_ranged_copy", "[containers][Array]") { @@ -97,8 +99,8 @@ TEST_CASE("test_array_ranged_copy", "[containers][Array]") { vec.push_back(idx); } Array arr(cBufferSize); - std::ranges::copy(vec, arr.begin()); - REQUIRE(std::ranges::equal(vec, arr)); + std::copy(vec.begin(), vec.end(), arr.begin()); + REQUIRE(std::equal(vec.cbegin(), vec.cend(), arr.begin(), arr.end())); } TEST_CASE("test_array_movable", "[containers][Array]") { @@ -109,7 +111,12 @@ TEST_CASE("test_array_movable", "[containers][Array]") { reference_array.at(idx) = idx; } auto const arr_moved{std::move(arr)}; - REQUIRE(std::ranges::equal(reference_array, arr_moved)); + REQUIRE(std::equal( + reference_array.begin(), + reference_array.end(), + arr_moved.begin(), + arr_moved.end() + )); } TEST_CASE("test_array_illegal_access", "[containers][Array]") { @@ -143,8 +150,8 @@ TEMPLATE_TEST_CASE( ) { REQUIRE(std::is_fundamental_v); Array arr(cBufferSize); - std::ranges::for_each(arr, [](auto const& p) -> void { - REQUIRE((static_cast(0) == p)); + std::for_each(arr.begin(), arr.end(), [](auto const& p) { + REQUIRE(static_cast(0) == p); }); } @@ -158,7 +165,7 @@ TEST_CASE("test_array_list_initialization", "[containers][Array]") { vec{"yscope", "clp", "ystdlib", "ystdlib::containers::Array", "default_initializable"}; Array const arr{"yscope", "clp", "ystdlib", "ystdlib::containers::Array", "default_initializable"}; - REQUIRE(std::ranges::equal(vec, arr)); + REQUIRE(std::equal(vec.cbegin(), vec.cend(), arr.begin(), arr.end())); // Test polymorphic list initialization REQUIRE(std::is_copy_constructible_v); @@ -174,10 +181,12 @@ TEST_CASE("test_array_list_initialization", "[containers][Array]") { cTestNum0, std::string{cTestStr}, ExplicitConstructor{cTestNum1}}; - REQUIRE(std::ranges::equal( - list_init_arr - | std::views::transform([](auto const& obj) { return obj.get_value(); }), - data + REQUIRE(std::equal( + list_init_arr.begin(), + list_init_arr.end(), + data.cbegin(), + data.cend(), + [](auto const& obj, auto const& v) { return obj.get_value() == v; } )); } diff --git a/src/ystdlib/error_handling/test/test_ErrorCode.cpp b/src/ystdlib/error_handling/test/test_ErrorCode.cpp index 3e362942..42b53cce 100644 --- a/src/ystdlib/error_handling/test/test_ErrorCode.cpp +++ b/src/ystdlib/error_handling/test/test_ErrorCode.cpp @@ -49,11 +49,18 @@ TEST_CASE("test_error_code", "[error_handling][ErrorCode]") { TEST_CASE("test_error_code_failure_condition", "[error_handling][ErrorCode]") { std::error_code const failure_error_code{BinaryErrorCode{BinaryErrorCodeEnum::Failure}}; - std::ranges::for_each(cFailureConditions, [&](auto const& failure_condition) { - REQUIRE((failure_error_code == failure_condition)); - }); - std::ranges::for_each(cNoneFailureConditions, [&](auto const& none_failure_condition) { - REQUIRE((failure_error_code != none_failure_condition)); - }); + std::for_each( + cFailureConditions.cbegin(), + cFailureConditions.cend(), + [&](auto const& failure_condition) { REQUIRE(failure_error_code == failure_condition); } + ); + + std::for_each( + cNoneFailureConditions.cbegin(), + cNoneFailureConditions.cend(), + [&](auto const& none_failure_condition) { + REQUIRE(failure_error_code != none_failure_condition); + } + ); } } // namespace ystdlib::error_handling::test diff --git a/src/ystdlib/error_handling/test/types.cpp b/src/ystdlib/error_handling/test/types.cpp index 8aba3d36..8d32aa2d 100644 --- a/src/ystdlib/error_handling/test/types.cpp +++ b/src/ystdlib/error_handling/test/types.cpp @@ -61,7 +61,7 @@ auto BinaryErrorCategory::equivalent( ) const noexcept -> bool { switch (error_enum) { case BinaryErrorCodeEnum::Failure: - return std::ranges::any_of( + return std::any_of( cFailureConditions.cbegin(), cFailureConditions.cend(), [&](auto failure_condition) -> bool { return condition == failure_condition; } From fa39bd88ad3431db80e93dc6a792e6ebee52472c Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Tue, 12 Aug 2025 13:55:52 -0400 Subject: [PATCH 05/13] Update workflow to use llvm15 for macos-14 --- .github/workflows/unit-tests.yaml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index d8426ccc..653dfdd9 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -43,21 +43,12 @@ jobs: run: "npm install -g @go-task/cli" - if: "'macos-14' == matrix.os" - name: "Install macOS 14 deps: coreutils (for md5sum) and Apple Clang 16 (for C++20)" + name: "Install macOS 14 deps: coreutils (for md5sum) and LLVM Clang 15 (for Velox)" run: |- brew install coreutils - brew install llvm@16 + brew install llvm@15 - name: "Run unit tests and examples" - env: >- - ${{ - 'macos-14' == matrix.os - && fromJson('{ - "CC": "/opt/homebrew/opt/llvm@16/bin/clang", - "CXX": "/opt/homebrew/opt/llvm@16/bin/clang++" - }') - || fromJson('{}') - }} # Currently unit tests rely on cassert and fail to compile in release mode. run: |- task test:run-debug From 59f3679d6d984ba4997ed2395d793094d5864abf Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Tue, 12 Aug 2025 14:21:20 -0400 Subject: [PATCH 06/13] Address coderabbit review on cmake --- .../Toolchains/llvm-clang-15-toolchain.cmake | 20 +++++++++++++++---- cmake/Toolchains/utils.cmake | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cmake/Toolchains/llvm-clang-15-toolchain.cmake b/cmake/Toolchains/llvm-clang-15-toolchain.cmake index 9a13cc3b..1b90c261 100644 --- a/cmake/Toolchains/llvm-clang-15-toolchain.cmake +++ b/cmake/Toolchains/llvm-clang-15-toolchain.cmake @@ -1,3 +1,15 @@ +# Used for CMake toolchain setup. Sets `VAR_NAME` to `BINARY_PATH` after verifying the toolchain +# binary exists. Stops configuration if the required binary is missing. +# +# @param {string} VAR_NAME Variable name to set. +# @param {string} BINARY_PATH Path to the cmake toolchain binary. +function(set_toolchian_binary_var VAR_NAME BINARY_PATH) + if(NOT EXISTS "${BINARY_PATH}") + message(FATAL_ERROR "Required cmake toolchain binary not found: ${BINARY_PATH}") + endif() + set(${VAR_NAME} "${BINARY_PATH}" PARENT_SCOPE) +endfunction() + message(STATUS "Setting up LLVM v15 toolchain...") execute_process( @@ -15,7 +27,7 @@ if(NOT 0 EQUAL BREW_RESULT) ) endif() -set(CMAKE_C_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang") -set(CMAKE_CXX_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang++") -set(CMAKE_AR "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ar") -set(CMAKE_RANLIB "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ranlib") +set_toolchian_binary_var(CMAKE_C_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang") +set_toolchian_binary_var(CMAKE_CXX_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang++") +set_toolchian_binary_var(CMAKE_AR "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ar") +set_toolchian_binary_var(CMAKE_RANLIB "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ranlib") diff --git a/cmake/Toolchains/utils.cmake b/cmake/Toolchains/utils.cmake index b918b71a..1185a733 100644 --- a/cmake/Toolchains/utils.cmake +++ b/cmake/Toolchains/utils.cmake @@ -43,7 +43,7 @@ function(validate_compiler_versions) message( FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at \ - least ${CXX_COMPILER_MIN_VERSION}." + least ${CXX_COMPILER_MIN_VERSION}." ) endif() endfunction() From f6df6223da8df4743340b11e27b9010d903bcf76 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Tue, 12 Aug 2025 14:24:38 -0400 Subject: [PATCH 07/13] Address coderabbit comment on cpp --- .../error_handling/test/test_ErrorCode.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/ystdlib/error_handling/test/test_ErrorCode.cpp b/src/ystdlib/error_handling/test/test_ErrorCode.cpp index 42b53cce..979b2281 100644 --- a/src/ystdlib/error_handling/test/test_ErrorCode.cpp +++ b/src/ystdlib/error_handling/test/test_ErrorCode.cpp @@ -49,18 +49,11 @@ TEST_CASE("test_error_code", "[error_handling][ErrorCode]") { TEST_CASE("test_error_code_failure_condition", "[error_handling][ErrorCode]") { std::error_code const failure_error_code{BinaryErrorCode{BinaryErrorCodeEnum::Failure}}; - std::for_each( - cFailureConditions.cbegin(), - cFailureConditions.cend(), - [&](auto const& failure_condition) { REQUIRE(failure_error_code == failure_condition); } - ); - - std::for_each( - cNoneFailureConditions.cbegin(), - cNoneFailureConditions.cend(), - [&](auto const& none_failure_condition) { - REQUIRE(failure_error_code != none_failure_condition); - } - ); + for (auto const& failure_condition : cFailureConditions) { + REQUIRE(failure_error_code == failure_condition); + } + for (auto const& none_failure_condition : cNoneFailureConditions) { + REQUIRE(failure_error_code != none_failure_condition); + } } } // namespace ystdlib::error_handling::test From af310c906ff88e7f5979d7f661e4f047044ac1b1 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Wed, 13 Aug 2025 08:19:03 -0400 Subject: [PATCH 08/13] Address coderabbit comments --- cmake/Toolchains/llvm-clang-15-toolchain.cmake | 14 +++++++------- cmake/Toolchains/utils.cmake | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmake/Toolchains/llvm-clang-15-toolchain.cmake b/cmake/Toolchains/llvm-clang-15-toolchain.cmake index 1b90c261..9c039200 100644 --- a/cmake/Toolchains/llvm-clang-15-toolchain.cmake +++ b/cmake/Toolchains/llvm-clang-15-toolchain.cmake @@ -3,7 +3,7 @@ # # @param {string} VAR_NAME Variable name to set. # @param {string} BINARY_PATH Path to the cmake toolchain binary. -function(set_toolchian_binary_var VAR_NAME BINARY_PATH) +function(set_toolchain_binary_var VAR_NAME BINARY_PATH) if(NOT EXISTS "${BINARY_PATH}") message(FATAL_ERROR "Required cmake toolchain binary not found: ${BINARY_PATH}") endif() @@ -22,12 +22,12 @@ execute_process( if(NOT 0 EQUAL BREW_RESULT) message( FATAL_ERROR - "Failed to locate LLVM v15 using Homebrew. Please ensure llvm@15 is installed: 'brew \ - install llvm@15'" + "Failed to locate LLVM v15 using Homebrew. Please ensure llvm@15 is installed: 'brew" + " install llvm@15'" ) endif() -set_toolchian_binary_var(CMAKE_C_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang") -set_toolchian_binary_var(CMAKE_CXX_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang++") -set_toolchian_binary_var(CMAKE_AR "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ar") -set_toolchian_binary_var(CMAKE_RANLIB "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ranlib") +set_toolchain_binary_var(CMAKE_C_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang") +set_toolchain_binary_var(CMAKE_CXX_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang++") +set_toolchain_binary_var(CMAKE_AR "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ar") +set_toolchain_binary_var(CMAKE_RANLIB "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ranlib") diff --git a/cmake/Toolchains/utils.cmake b/cmake/Toolchains/utils.cmake index 1185a733..446af30d 100644 --- a/cmake/Toolchains/utils.cmake +++ b/cmake/Toolchains/utils.cmake @@ -14,7 +14,7 @@ function(setup_toolchains) if("${MACOS_VERSION}" VERSION_LESS "15") set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/llvm-clang-15-toolchain.cmake" - CACHE STRING + CACHE FILEPATH "Toolchain file" ) endif() @@ -42,8 +42,8 @@ function(validate_compiler_versions) if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "${CXX_COMPILER_MIN_VERSION}") message( FATAL_ERROR - "${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at \ - least ${CXX_COMPILER_MIN_VERSION}." + "${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at" + " least ${CXX_COMPILER_MIN_VERSION}." ) endif() endfunction() From 3d288e14928600ed580d13446322ca2870bb428b Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Wed, 13 Aug 2025 08:20:06 -0400 Subject: [PATCH 09/13] Update dev utils --- tools/yscope-dev-utils | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/yscope-dev-utils b/tools/yscope-dev-utils index 15df0870..e121a57d 160000 --- a/tools/yscope-dev-utils +++ b/tools/yscope-dev-utils @@ -1 +1 @@ -Subproject commit 15df0870e8c00ebeddbfa12b2246070cba342f3f +Subproject commit e121a57d251285ac584c9ebb8de29d49dd8b5883 From 75fb463b7ff2c10e4a0cd79183a01211516cb268 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Fri, 15 Aug 2025 13:36:08 -0400 Subject: [PATCH 10/13] Remove llvm15 for macos14 --- .github/workflows/unit-tests.yaml | 3 +-- cmake/Toolchains/utils.cmake | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 653dfdd9..2fc9a78c 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -43,10 +43,9 @@ jobs: run: "npm install -g @go-task/cli" - if: "'macos-14' == matrix.os" - name: "Install macOS 14 deps: coreutils (for md5sum) and LLVM Clang 15 (for Velox)" + name: "Install macOS 14 deps: coreutils (for md5sum)" run: |- brew install coreutils - brew install llvm@15 - name: "Run unit tests and examples" # Currently unit tests rely on cassert and fail to compile in release mode. diff --git a/cmake/Toolchains/utils.cmake b/cmake/Toolchains/utils.cmake index 446af30d..748de0b4 100644 --- a/cmake/Toolchains/utils.cmake +++ b/cmake/Toolchains/utils.cmake @@ -11,7 +11,7 @@ function(setup_toolchains) OUTPUT_VARIABLE MACOS_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) - if("${MACOS_VERSION}" VERSION_LESS "15") + if("${MACOS_VERSION}" VERSION_LESS "14") set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/llvm-clang-15-toolchain.cmake" CACHE FILEPATH From ed0ea67ab29793a0a5e960f346add039a110644f Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Sat, 16 Aug 2025 01:36:40 +0800 Subject: [PATCH 11/13] Apply suggestions from code review Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> --- cmake/Toolchains/llvm-clang-15-toolchain.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Toolchains/llvm-clang-15-toolchain.cmake b/cmake/Toolchains/llvm-clang-15-toolchain.cmake index 9c039200..30789199 100644 --- a/cmake/Toolchains/llvm-clang-15-toolchain.cmake +++ b/cmake/Toolchains/llvm-clang-15-toolchain.cmake @@ -2,10 +2,10 @@ # binary exists. Stops configuration if the required binary is missing. # # @param {string} VAR_NAME Variable name to set. -# @param {string} BINARY_PATH Path to the cmake toolchain binary. +# @param {string} BINARY_PATH Path to the CMake toolchain binary. function(set_toolchain_binary_var VAR_NAME BINARY_PATH) if(NOT EXISTS "${BINARY_PATH}") - message(FATAL_ERROR "Required cmake toolchain binary not found: ${BINARY_PATH}") + message(FATAL_ERROR "Required CMake toolchain binary not found: ${BINARY_PATH}") endif() set(${VAR_NAME} "${BINARY_PATH}" PARENT_SCOPE) endfunction() From 7f5e22868df886d953d5843bab3f3d9829f3ceb0 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Fri, 15 Aug 2025 13:53:58 -0400 Subject: [PATCH 12/13] Remove unnecessary toolchain setup --- CMakeLists.txt | 10 ++---- .../Toolchains/llvm-clang-15-toolchain.cmake | 33 ------------------- cmake/Toolchains/utils.cmake | 24 ++------------ 3 files changed, 5 insertions(+), 62 deletions(-) delete mode 100644 cmake/Toolchains/llvm-clang-15-toolchain.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ce486a6a..249e38bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,15 @@ cmake_minimum_required(VERSION 3.23) -# Toolchain setup must come before the first project() call in the entire CMake buildsystem. -# If ystdlib is not the top-level project, the following setup has no effect. -include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/utils.cmake") -setup_toolchains() - project(ystdlib VERSION "0.1.0" LANGUAGES CXX) -validate_compiler_versions() - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include(CMakePackageConfigHelpers) include(GNUInstallDirs) +include(Toolchains/utils) include(ystdlib-helpers) +validate_compiler_versions() + option(BUILD_SHARED_LIBS "Build using shared libraries." OFF) option(ystdlib_BUILD_TESTING "Build the testing tree for ystdlib." ON) diff --git a/cmake/Toolchains/llvm-clang-15-toolchain.cmake b/cmake/Toolchains/llvm-clang-15-toolchain.cmake deleted file mode 100644 index 30789199..00000000 --- a/cmake/Toolchains/llvm-clang-15-toolchain.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# Used for CMake toolchain setup. Sets `VAR_NAME` to `BINARY_PATH` after verifying the toolchain -# binary exists. Stops configuration if the required binary is missing. -# -# @param {string} VAR_NAME Variable name to set. -# @param {string} BINARY_PATH Path to the CMake toolchain binary. -function(set_toolchain_binary_var VAR_NAME BINARY_PATH) - if(NOT EXISTS "${BINARY_PATH}") - message(FATAL_ERROR "Required CMake toolchain binary not found: ${BINARY_PATH}") - endif() - set(${VAR_NAME} "${BINARY_PATH}" PARENT_SCOPE) -endfunction() - -message(STATUS "Setting up LLVM v15 toolchain...") - -execute_process( - COMMAND - "brew" "--prefix" "llvm@15" - RESULT_VARIABLE BREW_RESULT - OUTPUT_VARIABLE LLVM_TOOLCHAIN_PREFIX - OUTPUT_STRIP_TRAILING_WHITESPACE -) -if(NOT 0 EQUAL BREW_RESULT) - message( - FATAL_ERROR - "Failed to locate LLVM v15 using Homebrew. Please ensure llvm@15 is installed: 'brew" - " install llvm@15'" - ) -endif() - -set_toolchain_binary_var(CMAKE_C_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang") -set_toolchain_binary_var(CMAKE_CXX_COMPILER "${LLVM_TOOLCHAIN_PREFIX}/bin/clang++") -set_toolchain_binary_var(CMAKE_AR "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ar") -set_toolchain_binary_var(CMAKE_RANLIB "${LLVM_TOOLCHAIN_PREFIX}/bin/llvm-ranlib") diff --git a/cmake/Toolchains/utils.cmake b/cmake/Toolchains/utils.cmake index 748de0b4..c39688c8 100644 --- a/cmake/Toolchains/utils.cmake +++ b/cmake/Toolchains/utils.cmake @@ -1,25 +1,5 @@ -# This file contains utility functions for setting up toolchains and validating toolchain versions -# to ensure compatibility with the C++20 features required by the project. - -# Sets up the appropriate toolchain file based on the host system. -function(setup_toolchains) - # For macOS versions below 15, use the LLVM 15 Clang toolchain. - if("Darwin" STREQUAL "${CMAKE_HOST_SYSTEM_NAME}") - execute_process( - COMMAND - "sw_vers" "--productVersion" - OUTPUT_VARIABLE MACOS_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if("${MACOS_VERSION}" VERSION_LESS "14") - set(CMAKE_TOOLCHAIN_FILE - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/llvm-clang-15-toolchain.cmake" - CACHE FILEPATH - "Toolchain file" - ) - endif() - endif() -endfunction() +# This file contains utility functions for validating toolchain versions to ensure compatibility +# with the C++20 features required by the project. # Checks if the compiler ID and version meet the minimum requirements to support C++20 features # required by the project: From 9ef42c1c98f733ce8d4563fcce9ca3c54c3f79a4 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 18 Aug 2025 01:21:48 +0800 Subject: [PATCH 13/13] Apply suggestions from code review Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> --- .github/workflows/unit-tests.yaml | 3 ++- cmake/Toolchains/utils.cmake | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 2fc9a78c..8f7b2ba3 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -43,11 +43,12 @@ jobs: run: "npm install -g @go-task/cli" - if: "'macos-14' == matrix.os" - name: "Install macOS 14 deps: coreutils (for md5sum)" + name: "Install coreutils (for md5sum)" run: |- brew install coreutils - name: "Run unit tests and examples" + # Currently unit tests rely on cassert and fail to compile in release mode. run: |- task test:run-debug diff --git a/cmake/Toolchains/utils.cmake b/cmake/Toolchains/utils.cmake index c39688c8..41f846e6 100644 --- a/cmake/Toolchains/utils.cmake +++ b/cmake/Toolchains/utils.cmake @@ -2,10 +2,7 @@ # with the C++20 features required by the project. # Checks if the compiler ID and version meet the minimum requirements to support C++20 features -# required by the project: -# - AppleClang: version 15+ -# - Clang: version 15+ -# - GNU: version 11+ +# required by the project. function(validate_compiler_versions) if("AppleClang" STREQUAL "${CMAKE_CXX_COMPILER_ID}") set(CXX_COMPILER_MIN_VERSION "15")