From 2275d7fae16be822da409128c6c4ededf9f1214b Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Wed, 19 Mar 2025 12:05:33 -0400 Subject: [PATCH 01/64] Refactor: Simplify range type constraints in pipelines --- include/daw/pipelines/enumerate.h | 10 ++++------ include/daw/pipelines/every.h | 6 +----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/include/daw/pipelines/enumerate.h b/include/daw/pipelines/enumerate.h index 83a91ea0a..2279da1c3 100644 --- a/include/daw/pipelines/enumerate.h +++ b/include/daw/pipelines/enumerate.h @@ -20,10 +20,9 @@ namespace daw::pipelines::pimpl { template struct Enumerate_t { - template + template [[nodiscard]] DAW_CPP23_STATIC_CALL_OP constexpr auto operator( )( R &&r ) DAW_CPP23_STATIC_CALL_OP_CONST { - static_assert( Range ); return zip_view, daw::remove_cvref_t>( iota_view( 0, max_value ), DAW_FWD( r ) ); } @@ -32,9 +31,8 @@ namespace daw::pipelines::pimpl { template struct EnumerateFrom_t { EnumType offset = EnumType{ }; - template + template [[nodiscard]] constexpr auto operator( )( R &&r ) const { - static_assert( Range ); return zip_view, daw::remove_cvref_t>( iota_view( offset, max_value ), DAW_FWD( r ) ); } @@ -42,7 +40,7 @@ namespace daw::pipelines::pimpl { template struct EnumerateApply_t { - template + template [[nodiscard]] DAW_CPP23_STATIC_CALL_OP constexpr auto operator( )( R &&r ) DAW_CPP23_STATIC_CALL_OP_CONST { if constexpr( RandomRange ) { @@ -59,7 +57,7 @@ namespace daw::pipelines::pimpl { template struct EnumerateApplyFrom_t { EnumType offset = EnumType{ }; - template + template [[nodiscard]] constexpr auto operator( )( R &&r ) const { if constexpr( RandomRange ) { auto const sz = static_cast( diff --git a/include/daw/pipelines/every.h b/include/daw/pipelines/every.h index d94f7c7bc..7c22d7b61 100644 --- a/include/daw/pipelines/every.h +++ b/include/daw/pipelines/every.h @@ -15,11 +15,7 @@ namespace daw::pipelines::pimpl { struct Every_t { std::size_t m_select_every; - template - [[nodiscard]] constexpr auto operator( )( R &&r ) const { - static_assert( Range, - "Every requires the previous algorithm in the pipeline " - "to return a range" ); + [[nodiscard]] constexpr auto operator( )( Range auto &&r ) const { return filter_view{ std::begin( DAW_FWD( r ) ), std::end( DAW_FWD( r ) ), [select_every = m_select_every, n = m_select_every]( auto const & ) mutable { From 3b0abb93dd9e4ccc302e97bfd4255c5100a1e16e Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 22 Mar 2025 13:32:24 -0400 Subject: [PATCH 02/64] Add contract validation utility with corresponding tests Introduce a `daw::contract` class for validating preconditions at runtime. Includes a failure handler --- .clang-format | 5 +- include/daw/daw_contract.h | 96 +++++++++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 1 + tests/daw_contract_test.cpp | 31 ++++++++++++ 4 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 include/daw/daw_contract.h create mode 100644 tests/daw_contract_test.cpp diff --git a/.clang-format b/.clang-format index 8a50165c0..6b092066a 100644 --- a/.clang-format +++ b/.clang-format @@ -6,8 +6,9 @@ AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: Always AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: false AllowShortFunctionsOnASingleLine: Empty -AllowShortIfStatementsOnASingleLine: "false" +AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakBeforeMultilineStrings: true @@ -42,7 +43,7 @@ PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Right -RequiresClausePosition: OwnLine +RequiresClausePosition: OwnLineWithBrace SpaceAfterCStyleCast: false SpaceAfterTemplateKeyword: false SpaceBeforeAssignmentOperators: true diff --git a/include/daw/daw_contract.h b/include/daw/daw_contract.h new file mode 100644 index 000000000..05bf33eb6 --- /dev/null +++ b/include/daw/daw_contract.h @@ -0,0 +1,96 @@ +// Copyright (c) Darrell Wright +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/beached/header_libraries +// + +#pragma once + +#include "daw/daw_assume.h" +#include "daw/daw_attributes.h" +#include "daw/daw_check_exceptions.h" +#include "daw/daw_consteval.h" +#include "daw/daw_cpp_feature_check.h" +#include "daw/daw_function_ref.h" + +#include +#include +#include +#include +#include + +namespace daw { +#if defined( DAW_USE_EXCEPTIONS ) + struct daw_contract_violation : std::exception {}; + [[noreturn]] inline void default_contract_failure( ) { + throw daw_contract_violation{ }; + } +#else + [[noreturn]] inline void default_contract_failure( ) { + std::abort( ); + } +#endif + constinit static thread_local daw::function_ref + contract_failure_handler = default_contract_failure; + + DAW_ATTRIB_NOINLINE inline void contract_failure( ) { + contract_failure_handler( ); + } + + template + requires( std::is_invocable_r_v and... ) // + class contract { + T value; + + static constexpr bool validate( T value ) { + return ( Preconditions{ }( value ) and ... ); + } + + public: + DAW_ATTRIB_FLATINLINE constexpr contract( T v ) + : value( std::move( v ) ) { + if( not validate( value ) ) { + contract_failure( ); + } + } + + DAW_ATTRIB_FLATINLINE constexpr T extract( ) { + DAW_ASSUME( validate( value ) ); + return std::move( value ); + } + + DAW_ATTRIB_FLATINLINE constexpr T &operator*( ) { + DAW_ASSUME( validate( value ) ); + return value; + } + + DAW_ATTRIB_FLATINLINE constexpr T const &operator*( ) const { + DAW_ASSUME( validate( value ) ); + return value; + } + + DAW_ATTRIB_FLATINLINE constexpr operator T const &( ) const { + DAW_ASSUME( validate( value ) ); + return value; + } + + template + using add_precondition_t = contract; + + template + DAW_ATTRIB_FLATINLINE constexpr operator contract( ) const { + DAW_ASSUME( validate( value ) ); + return contract( value ); + } + + template + requires( std::is_invocable_r_v and... ) // + constexpr auto add_condition( Pre2s... ) const { + + DAW_ASSUME( validate( value ) ); + return contract{ value }; + } + }; +} // namespace daw diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 33c02df95..9c095be5d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -142,6 +142,7 @@ set( CPP20_TEST_SOURCES daw_atomic_wait_test.cpp daw_any_if_test.cpp daw_concepts_test.cpp + daw_contract_test.cpp daw_contiguous_view_test.cpp daw_formatters_test.cpp daw_iter_view_test.cpp diff --git a/tests/daw_contract_test.cpp b/tests/daw_contract_test.cpp new file mode 100644 index 000000000..3b35589ad --- /dev/null +++ b/tests/daw_contract_test.cpp @@ -0,0 +1,31 @@ +// Copyright (c) Darrell Wright +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/beached/header_libraries +// + +#include +#include + +int main( ) { + using positive_integral = decltype( []( T const &value ) { + return value >= T{ }; + } ); + using pos_int = daw::contract; + static constexpr auto v0 = pos_int( 42 ); + constexpr int const &v0cr = v0; + (void)v0cr; + bool has_error = false; + daw::contract_failure_handler = [&] { + // This is not a good idea in real code. Do not call accessors if used + has_error = true; + }; + + { + auto v1 = pos_int{ -1 }; + daw_ensure( has_error = true ); + } + daw::contract_failure_handler = daw::default_contract_failure; +} From 69099dd958580d465dc41ca947746d1e71db6653 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 22 Mar 2025 13:46:45 -0400 Subject: [PATCH 03/64] Refactor contract tests to handle exceptions conditionally. --- tests/daw_contract_test.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/daw_contract_test.cpp b/tests/daw_contract_test.cpp index 3b35589ad..b6617c5eb 100644 --- a/tests/daw_contract_test.cpp +++ b/tests/daw_contract_test.cpp @@ -17,15 +17,12 @@ int main( ) { static constexpr auto v0 = pos_int( 42 ); constexpr int const &v0cr = v0; (void)v0cr; +#if defined( DAW_USE_EXCEPTIONS ) bool has_error = false; - daw::contract_failure_handler = [&] { - // This is not a good idea in real code. Do not call accessors if used - has_error = true; - }; - - { + try { auto v1 = pos_int{ -1 }; - daw_ensure( has_error = true ); - } - daw::contract_failure_handler = daw::default_contract_failure; + (void)v1; + } catch( daw::daw_contract_violation const & ) { has_error = true; } + daw_ensure( has_error ); +#endif } From 924d6734dda81d96d0b58ae64c2c4c3fffc19974 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 18 Apr 2025 21:24:26 -0400 Subject: [PATCH 04/64] Add support for counting leading zeros in uint128_t Introduce a constexpr function to handle leading zero count for uint128_t, ensuring compatibility with larger integers. Additionally, adjust `ToIota` initialization for consistency with type defaults. --- CMakeLists.txt | 2 +- include/daw/daw_cxmath.h | 12 ++++++++++++ include/daw/pipelines/iota.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f1b2a525..63a4c58ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ cmake_minimum_required( VERSION 3.14 ) project( "daw-header-libraries" - VERSION "2.124.1" + VERSION "2.125.0" DESCRIPTION "Various headers" HOMEPAGE_URL "https://github.com/beached/header_libraries" LANGUAGES C CXX diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index 75add3777..928d0ad0c 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -553,6 +553,18 @@ namespace daw::cxmath { return count_leading_zeroes( static_cast( v ) << 32U ); } #endif + [[nodiscard]] DAW_ATTRIB_FLATTEN constexpr std::uint32_t + count_leading_zeros( daw::uint128_t v ) { + if( v == 0 ) { + return 128U; + } + auto const h = + count_leading_zeros( static_cast( v >> 64ULL ) ); + if( h == 64U ) { + return count_leading_zeros( static_cast( v ) ); + } + return h; + } namespace cxmath_impl { [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::uint32_t diff --git a/include/daw/pipelines/iota.h b/include/daw/pipelines/iota.h index 3647d192e..6183f0f62 100644 --- a/include/daw/pipelines/iota.h +++ b/include/daw/pipelines/iota.h @@ -177,6 +177,6 @@ namespace daw::pipelines { iota_view( T, T ) -> iota_view; inline constexpr auto ToIota = []( I last ) { - return iota_view{ 0, last }; + return iota_view{ I{}, last }; }; } // namespace daw::pipelines From e1302c5318450c7243dddf4428734e094263b26a Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 18 Apr 2025 21:41:01 -0400 Subject: [PATCH 05/64] Refactor `count_leading_zeroes` handling for better builtin usage Introduced support for `__builtin_clzg` where available, improving compatibility and performance. Removed redundant overloads and reorganized function definitions to streamline the implementation. This cleanup simplifies the logic while maintaining backward compatibility. --- include/daw/daw_cxmath.h | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index 928d0ad0c..46cd96ab6 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -463,6 +463,13 @@ namespace daw::cxmath { } } +#if __has_builtin( __builtin_clzg ) + template, std::nullptr_t> = nullptr> + [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::uint32_t count_leading_zeroes( Unsigned u ) { + return __builtin_clzg( u ); + } +#else + #if DAW_HAS_BUILTIN( __builtin_clz ) [[nodiscard]] DAW_ATTRIB_INLINE constexpr unsigned count_leading_zeroes( unsigned v ) noexcept { @@ -480,10 +487,6 @@ namespace daw::cxmath { return static_cast( bit_count_v ); } - [[nodiscard]] DAW_ATTRIB_FLATINLINE inline constexpr unsigned - count_leading_zeroes( daw::UInt32 v ) noexcept { - return count_leading_zeroes( static_cast( v ) ); - } #if DAW_HAS_BUILTIN( __builtin_clzll ) [[nodiscard]] DAW_ATTRIB_INLINE constexpr unsigned @@ -512,11 +515,6 @@ namespace daw::cxmath { #endif - [[nodiscard]] DAW_ATTRIB_FLATINLINE inline constexpr unsigned - count_leading_zeroes( daw::UInt64 v ) noexcept { - return count_leading_zeroes( static_cast( v ) ); - } - #else // Based on code from // https://graphics.stanford.edu/~seander/bithacks.html @@ -542,17 +540,8 @@ namespace daw::cxmath { return 63U - static_cast( bit_position[( v * 0x021'8a39'2cd3'd5dbf ) >> 58U] ); // [3] } - - [[nodiscard]] constexpr std::uint32_t - count_leading_zeroes( daw::UInt64 v ) noexcept { - return count_leading_zeroes( static_cast( v ) ); - } - - [[nodiscard]] constexpr std::uint32_t - count_leading_zeroes( daw::UInt32 v ) noexcept { - return count_leading_zeroes( static_cast( v ) << 32U ); - } #endif + [[nodiscard]] DAW_ATTRIB_FLATTEN constexpr std::uint32_t count_leading_zeros( daw::uint128_t v ) { if( v == 0 ) { @@ -565,6 +554,16 @@ namespace daw::cxmath { } return h; } +#endif + [[nodiscard]] DAW_ATTRIB_FLATINLINE inline constexpr unsigned + count_leading_zeroes( daw::UInt32 v ) noexcept { + return count_leading_zeroes( static_cast( v ) ); + } + + [[nodiscard]] DAW_ATTRIB_FLATINLINE inline constexpr unsigned + count_leading_zeroes( daw::UInt64 v ) noexcept { + return count_leading_zeroes( static_cast( v ) ); + } namespace cxmath_impl { [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::uint32_t From cccf656a5a7c77480f98450428bd56e24167fc61 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 18 Apr 2025 21:52:35 -0400 Subject: [PATCH 06/64] Fix count_leading_zeroes for zero input handling Previously, calling count_leading_zeroes with a zero input could lead to undefined behavior. This update adds a check for zero inputs and returns the bit count for the type in such cases, ensuring correct results and improved safety. --- include/daw/daw_cxmath.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index 46cd96ab6..f7c39d43e 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -466,7 +466,10 @@ namespace daw::cxmath { #if __has_builtin( __builtin_clzg ) template, std::nullptr_t> = nullptr> [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::uint32_t count_leading_zeroes( Unsigned u ) { - return __builtin_clzg( u ); + if( u != Unsigned{} ) { + return static_cast( __builtin_clzg( u ) ); + } + return static_cast( bit_count_v ); } #else From 9e9abe4f87aa2411c93086521484e7422aa3081c Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 18 Apr 2025 22:00:58 -0400 Subject: [PATCH 07/64] Update LLVM repo URLs in CI for Ubuntu 24.04 workflows Replaced 'jammy' with 'noble' in LLVM repository URLs to match the correct distribution for Ubuntu 24.04. --- .github/workflows/ci_ubuntu.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci_ubuntu.yml b/.github/workflows/ci_ubuntu.yml index 3fa5d68b9..62ff64987 100644 --- a/.github/workflows/ci_ubuntu.yml +++ b/.github/workflows/ci_ubuntu.yml @@ -43,15 +43,15 @@ jobs: if: endsWith( matrix.os, '24.04' ) run: | sudo wget -O /etc/apt/trusted.gpg.d/llvm.asc https://apt.llvm.org/llvm-snapshot.gpg.key - sudo apt-add-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main' - sudo apt-add-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-13 main' - sudo apt-add-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main' - sudo apt-add-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main' - sudo apt-add-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' - sudo apt-add-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main' - sudo apt-add-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' - sudo apt-add-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main' - sudo apt-add-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main' + sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble main' + sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-13 main' + sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-14 main' + sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-15 main' + sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-16 main' + sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-17 main' + sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main' + sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main' + sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main' sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt update sudo apt install ninja-build libunwind-dev From af59e79b62bfb930c8130622024f02b08738da52 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 18 Apr 2025 22:05:36 -0400 Subject: [PATCH 08/64] Added missing conditional for `daw::uint128` with `DAW_HAS_INT128`. --- include/daw/daw_cxmath.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index f7c39d43e..326e83b08 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -464,9 +464,11 @@ namespace daw::cxmath { } #if __has_builtin( __builtin_clzg ) - template, std::nullptr_t> = nullptr> - [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::uint32_t count_leading_zeroes( Unsigned u ) { - if( u != Unsigned{} ) { + template, + std::nullptr_t> = nullptr> + [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::uint32_t + count_leading_zeroes( Unsigned u ) { + if( u != Unsigned{ } ) { return static_cast( __builtin_clzg( u ) ); } return static_cast( bit_count_v ); @@ -490,7 +492,6 @@ namespace daw::cxmath { return static_cast( bit_count_v ); } - #if DAW_HAS_BUILTIN( __builtin_clzll ) [[nodiscard]] DAW_ATTRIB_INLINE constexpr unsigned count_leading_zeroes( unsigned long long v ) noexcept { @@ -544,7 +545,7 @@ namespace daw::cxmath { bit_position[( v * 0x021'8a39'2cd3'd5dbf ) >> 58U] ); // [3] } #endif - +#if defined( DAW_HAS_INT128 ) [[nodiscard]] DAW_ATTRIB_FLATTEN constexpr std::uint32_t count_leading_zeros( daw::uint128_t v ) { if( v == 0 ) { @@ -558,15 +559,16 @@ namespace daw::cxmath { return h; } #endif - [[nodiscard]] DAW_ATTRIB_FLATINLINE inline constexpr unsigned - count_leading_zeroes( daw::UInt32 v ) noexcept { - return count_leading_zeroes( static_cast( v ) ); - } +#endif + [[nodiscard]] DAW_ATTRIB_FLATINLINE inline constexpr unsigned + count_leading_zeroes( daw::UInt32 v ) noexcept { + return count_leading_zeroes( static_cast( v ) ); + } - [[nodiscard]] DAW_ATTRIB_FLATINLINE inline constexpr unsigned - count_leading_zeroes( daw::UInt64 v ) noexcept { - return count_leading_zeroes( static_cast( v ) ); - } + [[nodiscard]] DAW_ATTRIB_FLATINLINE inline constexpr unsigned + count_leading_zeroes( daw::UInt64 v ) noexcept { + return count_leading_zeroes( static_cast( v ) ); + } namespace cxmath_impl { [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::uint32_t From 01b400f433058c6b7b90b101874d6f6c8385cae8 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 18 Apr 2025 22:11:18 -0400 Subject: [PATCH 09/64] Streamline CI by removing outdated compiler toolsets --- .github/workflows/ci_ubuntu.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/ci_ubuntu.yml b/.github/workflows/ci_ubuntu.yml index 62ff64987..5d2082aa5 100644 --- a/.github/workflows/ci_ubuntu.yml +++ b/.github/workflows/ci_ubuntu.yml @@ -25,7 +25,7 @@ jobs: cpp_version: [ 17, 20 ] build_type: [ Debug, Release ] os: [ ubuntu-24.04 ] - toolset: [ g++-12, g++-13, clang++-13, clang++-14, clang++-15, clang++-16, clang++-17, clang++-18, clang++-19, clang++-20 ] + toolset: [ g++-12, g++-13, clang++-19, clang++-20 ] exclude: - toolset: g++-12 cpp_version: 20 @@ -44,12 +44,6 @@ jobs: run: | sudo wget -O /etc/apt/trusted.gpg.d/llvm.asc https://apt.llvm.org/llvm-snapshot.gpg.key sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble main' - sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-13 main' - sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-14 main' - sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-15 main' - sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-16 main' - sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-17 main' - sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main' sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main' sudo apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main' sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test From a19d53cd01e6e0b891f19b6ece120cb013ffe721 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 18 Apr 2025 23:02:02 -0400 Subject: [PATCH 10/64] Fix incorrect handling of zero in count_leading_zeroes. --- include/daw/daw_cxmath.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index 326e83b08..28b04233c 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -468,10 +468,7 @@ namespace daw::cxmath { std::nullptr_t> = nullptr> [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::uint32_t count_leading_zeroes( Unsigned u ) { - if( u != Unsigned{ } ) { - return static_cast( __builtin_clzg( u ) ); - } - return static_cast( bit_count_v ); + return static_cast( __builtin_clzg( u, static_cast(daw::bit_count_v) ) ); } #else From 884d12156eb60892899bdf91c2df2bf7cdc456ea Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Mon, 21 Apr 2025 17:31:44 -0400 Subject: [PATCH 11/64] Update macro check for built-in function in count_leading_zeroes. Replaced `__has_builtin` with `DAW_HAS_BUILTIN` to ensure correct macro usage. This improves compatibility --- include/daw/daw_cxmath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index 28b04233c..33b4bf660 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -463,7 +463,7 @@ namespace daw::cxmath { } } -#if __has_builtin( __builtin_clzg ) +#if DAW_HAS_BUILTIN( __builtin_clzg ) template, std::nullptr_t> = nullptr> [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::uint32_t From c8fc18bc9e5f73b7d2b4c064ccbbbe85007140ff Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Mon, 12 May 2025 21:57:13 -0400 Subject: [PATCH 12/64] Add ASCII utilities and corresponding tests Introduce utility functions for ASCII character checks and transformations, such as detecting digits, letters, alphanumerics, printable characters, and case conversion. Included a test file to verify the correctness of these utilities. --- CMakeLists.txt | 2 +- include/daw/daw_ascii.h | 98 ++++++++++++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 1 + tests/daw_ascii_test.cpp | 20 ++++++++ 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 include/daw/daw_ascii.h create mode 100644 tests/daw_ascii_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 63a4c58ac..524f75384 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ cmake_minimum_required( VERSION 3.14 ) project( "daw-header-libraries" - VERSION "2.125.0" + VERSION "2.126.0" DESCRIPTION "Various headers" HOMEPAGE_URL "https://github.com/beached/header_libraries" LANGUAGES C CXX diff --git a/include/daw/daw_ascii.h b/include/daw/daw_ascii.h new file mode 100644 index 000000000..364967d26 --- /dev/null +++ b/include/daw/daw_ascii.h @@ -0,0 +1,98 @@ +// Copyright (c) Darrell Wright +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/beached/header_libraries +// + +#pragma once + +#include "daw/daw_attributes.h" +#include "daw/daw_cpp_feature_check.h" +#include "daw/impl/daw_make_trait.h" + +#include + +namespace daw { + struct is_ascii_digit_t { + explicit is_ascii_digit_t( ) = default; + + template, + std::nullptr_t> = nullptr> + DAW_ATTRIB_INLINE DAW_CPP23_STATIC_CALL_OP constexpr bool + operator( )( Integer c ) DAW_CPP23_STATIC_CALL_OP_CONST { + // '0' <= c <= '9' + return Integer{ 48 } <= c and c <= Integer{ 57 }; + } + }; + inline constexpr auto is_ascii_digit = is_ascii_digit_t{ }; + + struct is_ascii_alpha_t { + explicit is_ascii_alpha_t( ) = default; + + template, + std::nullptr_t> = nullptr> + DAW_ATTRIB_INLINE DAW_CPP23_STATIC_CALL_OP constexpr bool + operator( )( Integer c ) DAW_CPP23_STATIC_CALL_OP_CONST { + // ( 'A' <= c <= 'Z' ) or ( 'a' <= c <= 'z' ) + return ( Integer{ 65 } <= c and c <= Integer{ 90 } ) or + ( Integer{ 97 } <= c and c <= Integer{ 122 } ); + } + }; + inline constexpr auto is_ascii_alpha = is_ascii_alpha_t{ }; + + struct is_ascii_alphanum_t { + explicit is_ascii_alphanum_t( ) = default; + + template, + std::nullptr_t> = nullptr> + DAW_ATTRIB_INLINE DAW_CPP23_STATIC_CALL_OP constexpr bool + operator( )( Integer c ) DAW_CPP23_STATIC_CALL_OP_CONST { + return is_ascii_digit( c ) or is_ascii_alpha( c ); + } + }; + inline constexpr auto is_ascii_alphanum = is_ascii_alphanum_t{ }; + + struct is_ascii_printable_t { + explicit is_ascii_printable_t( ) = default; + + template, + std::nullptr_t> = nullptr> + DAW_ATTRIB_INLINE DAW_CPP23_STATIC_CALL_OP constexpr bool + operator( )( Integer c ) DAW_CPP23_STATIC_CALL_OP_CONST { + return Integer{ 32 } < c and c < Integer{ 127 }; + } + }; + inline constexpr auto is_ascii_printable = is_ascii_printable_t{ }; + + struct to_upper_ascii_t { + explicit to_upper_ascii_t( ) = default; + + template, + std::nullptr_t> = nullptr> + DAW_ATTRIB_INLINE DAW_CPP23_STATIC_CALL_OP constexpr Integer + operator( )( Integer c ) DAW_CPP23_STATIC_CALL_OP_CONST { + if( Integer{ 97 } <= c and c <= Integer{ 122 } ) { + return static_cast( c - Integer{ 32 } ); + } + return c; + } + }; + inline constexpr auto to_upper_ascii = to_upper_ascii_t{ }; + + struct to_lower_ascii_t { + explicit to_lower_ascii_t( ) = default; + + template, + std::nullptr_t> = nullptr> + DAW_ATTRIB_INLINE DAW_CPP23_STATIC_CALL_OP constexpr Integer + operator( )( Integer c ) DAW_CPP23_STATIC_CALL_OP_CONST { + if( Integer{ 65 } <= c and c <= Integer{ 90 } ) { + return static_cast( c + Integer{ 32 } ); + } + return c; + } + }; + inline constexpr auto to_lower_ascii = to_lower_ascii_t{ }; +} // namespace daw diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9c095be5d..1f0fbeec4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -21,6 +21,7 @@ set( TEST_SOURCES daw_arith_traits_test.cpp daw_array_compare_test.cpp daw_array_test.cpp + daw_ascii_test.cpp daw_assume_test.cpp daw_attributes_test.cpp daw_benchmark_test.cpp diff --git a/tests/daw_ascii_test.cpp b/tests/daw_ascii_test.cpp new file mode 100644 index 000000000..ab65233da --- /dev/null +++ b/tests/daw_ascii_test.cpp @@ -0,0 +1,20 @@ +// Copyright (c) Darrell Wright +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/beached/header_libraries +// + +#include +#include + +int main( ) { + daw_ensure( daw::is_ascii_alpha( 'a' ) ); + daw_ensure( not daw::is_ascii_alpha( '0' ) ); + daw_ensure( daw::is_ascii_digit( '0' ) ); + daw_ensure( not daw::is_ascii_digit( 'a' ) ); + daw_ensure( daw::is_ascii_alphanum( 'a' ) ); + daw_ensure( not daw::is_ascii_alphanum( ' ' ) ); + daw_ensure( daw::is_ascii_printable( '!' ) ); +} \ No newline at end of file From 4f3c3beac232668dbe848be2c2ec0d2e70b393de Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Mon, 12 May 2025 21:59:58 -0400 Subject: [PATCH 13/64] Fix ASCII printable check to include space character The previous logic excluded the space character (ASCII code 32) from being considered printable. This change modifies the comparison to include space, ensuring correct behavior for determining ASCII printable characters. --- include/daw/daw_ascii.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/daw/daw_ascii.h b/include/daw/daw_ascii.h index 364967d26..28750ba40 100644 --- a/include/daw/daw_ascii.h +++ b/include/daw/daw_ascii.h @@ -61,7 +61,7 @@ namespace daw { std::nullptr_t> = nullptr> DAW_ATTRIB_INLINE DAW_CPP23_STATIC_CALL_OP constexpr bool operator( )( Integer c ) DAW_CPP23_STATIC_CALL_OP_CONST { - return Integer{ 32 } < c and c < Integer{ 127 }; + return Integer{ 32 } <= c and c < Integer{ 127 }; } }; inline constexpr auto is_ascii_printable = is_ascii_printable_t{ }; From cb1e9c7da33d4656286bf3ede24e8d2b094463f9 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Mon, 19 May 2025 01:51:57 -0400 Subject: [PATCH 14/64] Add utility to convert enums to their underlying type Introduce `to_underlying_type` in `daw_to_underlying_type.h`, allowing seamless conversion of enums to their underlying integer type. This simplifies operations requiring direct manipulation of enum values. --- CMakeLists.txt | 2 +- include/daw/daw_to_underlying_type.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 include/daw/daw_to_underlying_type.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 524f75384..df2c838a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ cmake_minimum_required( VERSION 3.14 ) project( "daw-header-libraries" - VERSION "2.126.0" + VERSION "2.127.0" DESCRIPTION "Various headers" HOMEPAGE_URL "https://github.com/beached/header_libraries" LANGUAGES C CXX diff --git a/include/daw/daw_to_underlying_type.h b/include/daw/daw_to_underlying_type.h new file mode 100644 index 000000000..2eb8faa2b --- /dev/null +++ b/include/daw/daw_to_underlying_type.h @@ -0,0 +1,19 @@ +// Copyright (c) Darrell Wright +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/beached/header_libraries +// + +#pragma once + +#include + +namespace daw { + template, std::nullptr_t> = nullptr> + constexpr auto to_underlying_type( Enum e ) { + return static_cast>( e ); + } +} // namespace daw From b6facb8c63b8af30a90e8115535bfa009ac81909 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Mon, 19 May 2025 16:28:54 -0400 Subject: [PATCH 15/64] Rename `to_underlying_type` to `to_underlying` --- include/daw/daw_to_underlying_type.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/daw/daw_to_underlying_type.h b/include/daw/daw_to_underlying_type.h index 2eb8faa2b..fa72eeec6 100644 --- a/include/daw/daw_to_underlying_type.h +++ b/include/daw/daw_to_underlying_type.h @@ -13,7 +13,7 @@ namespace daw { template, std::nullptr_t> = nullptr> - constexpr auto to_underlying_type( Enum e ) { + constexpr auto to_underlying( Enum e ) { return static_cast>( e ); } } // namespace daw From 0bf238911c0d016c3b1cc2802190ebec32a51ef6 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 22 May 2025 19:44:30 -0400 Subject: [PATCH 16/64] Refactor `function_ref` to handle null-thunk pointers as it isn't needed for fp's passed. --- include/daw/daw_function_ref.h | 9 ++++++--- tests/daw_function_ref_test.cpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/daw/daw_function_ref.h b/include/daw/daw_function_ref.h index 83dd4f4be..7169c3f53 100644 --- a/include/daw/daw_function_ref.h +++ b/include/daw/daw_function_ref.h @@ -84,19 +84,22 @@ namespace daw { constexpr function_ref( Result ( *ptr )( Params... ) ) noexcept : m_data( ptr ) - , m_thunk( fp_thunk ) { + , m_thunk( nullptr ) { assert( ptr ); } constexpr function_ref &operator=( Result ( *ptr )( Params... ) ) noexcept { m_data = ptr; - m_thunk = fp_thunk; + m_thunk = nullptr; assert( ptr ); return *this; } constexpr Result operator( )( Params... params ) const { - return m_thunk( m_data, params... ); + if( not m_thunk ) { + return m_data.func_ptr( std::forward( params )... ); + } + return m_thunk( m_data, std::forward( params )... ); } }; diff --git a/tests/daw_function_ref_test.cpp b/tests/daw_function_ref_test.cpp index a9e1c0673..325610b18 100644 --- a/tests/daw_function_ref_test.cpp +++ b/tests/daw_function_ref_test.cpp @@ -34,7 +34,7 @@ inline constexpr int add( int a, int b, int c ) { } DAW_CONSTEVAL void test2( ) { - auto const r = func( add ); + constexpr auto const r = func( add ); daw_ensure( r == 96 ); } From 807fb9871c078c43031e6104558ae4de0693c1c8 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 26 Jun 2025 18:26:01 -0400 Subject: [PATCH 17/64] Fix type handling and formatting in `count_digits` and `count_leading_zeroes`. --- include/daw/daw_cxmath.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index 33b4bf660..a8321713c 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -468,7 +468,8 @@ namespace daw::cxmath { std::nullptr_t> = nullptr> [[nodiscard]] DAW_ATTRIB_INLINE constexpr std::uint32_t count_leading_zeroes( Unsigned u ) { - return static_cast( __builtin_clzg( u, static_cast(daw::bit_count_v) ) ); + return static_cast( + __builtin_clzg( u, static_cast( daw::bit_count_v ) ) ); } #else @@ -1385,9 +1386,11 @@ namespace daw::cxmath { 10'000'000'000'000'000'000ull }; constexpr int count_digits( std::uint64_t value ) { - auto b = -( value > 0 ) & ( 63 - count_leading_zeroes( value ) ); + auto b = -static_cast( value > 0 ) & + ( 63 - count_leading_zeroes( value ) ); auto a = ( b * 77 ) / 256; - return static_cast( 1 + a + ( value >= powers_of_ten[a] ) ); + return static_cast( + 1 + a + static_cast( value >= powers_of_ten[a] ) ); } static_assert( count_digits( 1'000'000ULL ) == 7 ); } // namespace daw::cxmath From 895ca550404cfe9d37915793ca880e8648842ac3 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 19:36:27 -0400 Subject: [PATCH 18/64] Fix formatting in `basic_string_view` and adjust logic for conditional compilation. --- include/daw/daw_string_view.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/daw/daw_string_view.h b/include/daw/daw_string_view.h index f3b5da826..ca759bf05 100644 --- a/include/daw/daw_string_view.h +++ b/include/daw/daw_string_view.h @@ -536,8 +536,8 @@ namespace daw { /// refer to a constant contiguous sequence of char-like objects with the /// first element of the sequence at position zero. template - struct [[DAW_PREF_NAME( string_view ), - DAW_PREF_NAME( wstring_view )]] basic_string_view { + struct [[DAW_PREF_NAME( string_view ), DAW_PREF_NAME( wstring_view )]] + basic_string_view { using value_type = CharT; using pointer = CharT *; using const_pointer = std::add_const_t *; @@ -1938,13 +1938,18 @@ namespace daw { reinterpret_cast( r ) - first ); } } + else { #endif - for( std::size_t n = pos; n < sz; ++n ) { - if( first[n] == c ) { - return n; + for( std::size_t n = pos; n < sz; ++n ) { + if( first[n] == c ) { + return n; + } } + return npos; + +#if defined( DAW_HAS_IF_CONSTEVAL_COMPAT ) } - return npos; +#endif } [[nodiscard]] DAW_ATTRIB_FLATTEN constexpr size_type From ea8b432ae66c7695c43e19cf0603c401cd23abbe Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 19:40:43 -0400 Subject: [PATCH 19/64] Update CI for Windows to use Visual Studio 2022 toolset --- .github/workflows/ci_windows_clangcl.yml | 2 +- ci_scripts/ci_windows_build.cmd | 6 +++--- ci_scripts/ci_windows_build_clangcl.cmd | 6 +++--- ci_scripts/ci_windows_install_test.cmd | 8 ++++---- ci_scripts/ci_windows_install_test_clangcl.cmd | 8 ++++---- ci_scripts/ci_windows_test.cmd | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci_windows_clangcl.yml b/.github/workflows/ci_windows_clangcl.yml index 25a8e13b2..9127e2031 100644 --- a/.github/workflows/ci_windows_clangcl.yml +++ b/.github/workflows/ci_windows_clangcl.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: [windows-2019] + runs-on: [windows-2022] steps: - uses: actions/checkout@v1 - name: Build diff --git a/ci_scripts/ci_windows_build.cmd b/ci_scripts/ci_windows_build.cmd index 6ea9172e5..0d68f8339 100755 --- a/ci_scripts/ci_windows_build.cmd +++ b/ci_scripts/ci_windows_build.cmd @@ -10,13 +10,13 @@ cd build ECHO "##############################" ECHO "Setting VCVars" -@call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 +@call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 ECHO "##############################" ECHO "Running cmake" -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_C_COMPILER=cl.exe -DDAW_ENABLE_TESTING=On .. +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_C_COMPILER=cl.exe -DDAW_ENABLE_TESTING=On .. ECHO "##############################" ECHO "Building" -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug --target daw-header-libraries_full -j 2 -- -k 1000 +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug --target daw-header-libraries_full -j 2 -- -k 1000 diff --git a/ci_scripts/ci_windows_build_clangcl.cmd b/ci_scripts/ci_windows_build_clangcl.cmd index f0051cda0..509cbf7da 100755 --- a/ci_scripts/ci_windows_build_clangcl.cmd +++ b/ci_scripts/ci_windows_build_clangcl.cmd @@ -5,12 +5,12 @@ cd build ECHO "##############################" ECHO "Setting VCVars" -@call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 +@call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 ECHO "##############################" ECHO "Running cmake" -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DDAW_ENABLE_TESTING=On .. +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DDAW_ENABLE_TESTING=On .. ECHO "##############################" ECHO "Building" -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug --target daw-header-libraries_full -j 2 -- -k 1000 +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug --target daw-header-libraries_full -j 2 -- -k 1000 diff --git a/ci_scripts/ci_windows_install_test.cmd b/ci_scripts/ci_windows_install_test.cmd index f2e1595b9..03049d0b5 100755 --- a/ci_scripts/ci_windows_install_test.cmd +++ b/ci_scripts/ci_windows_install_test.cmd @@ -4,7 +4,7 @@ cd build ECHO "##############################" ECHO "Setting VCVars" -@call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 +@call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 echo "#################################" echo "Starting Install Tests" @@ -12,9 +12,9 @@ cmake --install . cd ../cmake/test_project/ md build cd build -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_C_COMPILER=cl.exe .. +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_C_COMPILER=cl.exe .. IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/ctest.exe" -C Debug -VV +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/ctest.exe" -C Debug -VV IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% diff --git a/ci_scripts/ci_windows_install_test_clangcl.cmd b/ci_scripts/ci_windows_install_test_clangcl.cmd index 75e556cd3..beaa39370 100755 --- a/ci_scripts/ci_windows_install_test_clangcl.cmd +++ b/ci_scripts/ci_windows_install_test_clangcl.cmd @@ -4,7 +4,7 @@ cd build ECHO "##############################" ECHO "Setting VCVars" -@call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 +@call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 echo "#################################" echo "Starting Install Tests" @@ -12,9 +12,9 @@ cmake --install . cd ../cmake/test_project/ md build cd build -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" .. +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" .. IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/ctest.exe" -C Debug -VV +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/ctest.exe" -C Debug -VV IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% diff --git a/ci_scripts/ci_windows_test.cmd b/ci_scripts/ci_windows_test.cmd index 780823aa8..d40c07052 100755 --- a/ci_scripts/ci_windows_test.cmd +++ b/ci_scripts/ci_windows_test.cmd @@ -3,4 +3,4 @@ cd build ECHO "#################################3" ECHO "Starting Tests" -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/ctest.exe" -C Debug --target daw-header-libraries_full -j 2 -VV --timeout 300 +"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/ctest.exe" -C Debug --target daw-header-libraries_full -j 2 -VV --timeout 300 From 3e970a083969719ad98ecab96ef5f0c271413155 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 19:48:42 -0400 Subject: [PATCH 20/64] Refactor Windows CI workflows: merge `ci_windows_clangcl.yml` into `ci_windows.yml`, add improved matrix configuration, and update build/test steps for better toolset coverage. --- .github/workflows/ci_windows.yml | 71 +++++++++++++++++++++--- .github/workflows/ci_windows_clangcl.yml | 18 ------ 2 files changed, 62 insertions(+), 27 deletions(-) delete mode 100644 .github/workflows/ci_windows_clangcl.yml diff --git a/.github/workflows/ci_windows.yml b/.github/workflows/ci_windows.yml index 74d74c1fd..ddb94398c 100644 --- a/.github/workflows/ci_windows.yml +++ b/.github/workflows/ci_windows.yml @@ -1,19 +1,72 @@ name: Windows - on: + schedule: + - cron: '10 5 * * *' push: - branches-ignore: dev + branches: [ release, develop ] pull_request: - branches-ignore: dev + push: + branches-ignore: develop + pull_request: + branches-ignore: develop jobs: - build: - runs-on: [windows-2019] + Windows: + permissions: + actions: none + checks: none + contents: none + deployments: none + issues: none + packages: none + pull-requests: none + repository-projects: none + security-events: none + statuses: none + defaults: + run: + shell: cmd + strategy: + fail-fast: false + matrix: + config: + - { cpp_version: 17, build_type: Debug, arch: x64, os: windows-2022, toolset: MSVC, cmake_flags: "-GNinja" } + - { cpp_version: 17, build_type: Release, arch: x64, os: windows-2022, toolset: MSVC, cmake_flags: "-GNinja" } + - { cpp_version: 20, build_type: Debug, arch: x64, os: windows-2022, toolset: MSVC, cmake_flags: "-GNinja" } + - { cpp_version: 20, build_type: Release, arch: x64, os: windows-2022, toolset: MSVC, cmake_flags: "-GNinja" } + - { cpp_version: 17, build_type: Debug, arch: Win32, os: windows-2022, toolset: MSVC, cmake_flags: "-GNinja" } + - { cpp_version: 17, build_type: Release, arch: Win32, os: windows-2022, toolset: MSVC, cmake_flags: "-GNinja" } + - { cpp_version: 20, build_type: Debug, arch: Win32, os: windows-2022, toolset: MSVC, cmake_flags: "-GNinja" } + - { cpp_version: 20, build_type: Release, arch: Win32, os: windows-2022, toolset: MSVC, cmake_flags: "-GNinja" } + - { cpp_version: 23, build_type: Debug, arch: Win32, os: windows-2022, toolset: MSVC, cmake_flags: "-GNinja" } + - { cpp_version: 23, build_type: Release, arch: Win32, os: windows-2022, toolset: MSVC, cmake_flags: "-GNinja" } + - { cpp_version: 23, build_type: Debug, arch: Win32, os: windows-2022, toolset: ClangCL, cmake_flags: " -T ClangCL -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe" } + - { cpp_version: 23, build_type: Release, arch: Win32, os: windows-2022, toolset: ClangCL, cmake_flags: " -T ClangCL -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe" } + runs-on: ${{ matrix.config.os }} + name: "${{ matrix.config.os }} ${{ matrix.config.toolset }} ${{ matrix.config.cpp_version }} ${{ matrix.config.arch }} ${{ matrix.config.build_type }}" + env: + DAW_BUILD_DIR: "build_${{ matrix.config.cpp_version }}_${{ matrix.config.arch }}_${{ matrix.config.build_type }}_${{ matrix.config.toolset }}" steps: - uses: actions/checkout@v1 + - uses: beached/msvc-dev-cmd@285e7c0b9b57a02c900951da93a77e656425d783 + with: + arch: ${{ matrix.config.arch }} + - name: Setup Build Environment + run: md ${{ env.DAW_BUILD_DIR }} + - name: CMake Config + run: cmake.exe ${{ matrix.config.cmake_flags }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCMAKE_CXX_STANDARD=${{ matrix.config.cpp_version }} -DDAW_ENABLE_TESTING=On -B${{ env.DAW_BUILD_DIR }}/ . - name: Build - run: .\ci_scripts\ci_windows_build.cmd + run: cmake.exe --build ${{ env.DAW_BUILD_DIR }}/ --target ci_tests --config ${{ matrix.config.build_type }} + continue-on-error: true - name: Test - run: .\ci_scripts\ci_windows_test.cmd - - name: InstallTest - run: .\ci_scripts\ci_windows_install_test.cmd + run: ctest.exe -C ${{ matrix.config.build_type }} -j2 -VV --timeout 1200 --test-dir ${{ env.DAW_BUILD_DIR }}/ + - name: Archive any crashes as an artifact + uses: actions/upload-artifact@v4 + if: always( ) + with: + name: crashes + path: | + crash-* + leak-* + timeout-* + if-no-files-found: ignore diff --git a/.github/workflows/ci_windows_clangcl.yml b/.github/workflows/ci_windows_clangcl.yml deleted file mode 100644 index 9127e2031..000000000 --- a/.github/workflows/ci_windows_clangcl.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Windows_ClangCl - -on: - push: - branches-ignore: dev - pull_request: - branches-ignore: dev - -jobs: - build: - runs-on: [windows-2022] - steps: - - uses: actions/checkout@v1 - - name: Build - run: .\ci_scripts\ci_windows_build_clangcl.cmd - - name: Test - run: .\ci_scripts\ci_windows_test.cmd - From ccc8a3be099998b71d7198abefd854f7b0ff72d4 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 19:51:51 -0400 Subject: [PATCH 21/64] Update Windows CI workflow to build `daw-header-libraries_full` target instead of `ci_tests` --- .github/workflows/ci_windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_windows.yml b/.github/workflows/ci_windows.yml index ddb94398c..4e96f8b42 100644 --- a/.github/workflows/ci_windows.yml +++ b/.github/workflows/ci_windows.yml @@ -56,7 +56,7 @@ jobs: - name: CMake Config run: cmake.exe ${{ matrix.config.cmake_flags }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCMAKE_CXX_STANDARD=${{ matrix.config.cpp_version }} -DDAW_ENABLE_TESTING=On -B${{ env.DAW_BUILD_DIR }}/ . - name: Build - run: cmake.exe --build ${{ env.DAW_BUILD_DIR }}/ --target ci_tests --config ${{ matrix.config.build_type }} + run: cmake.exe --build ${{ env.DAW_BUILD_DIR }}/ --target daw-header-libraries_full --config ${{ matrix.config.build_type }} continue-on-error: true - name: Test run: ctest.exe -C ${{ matrix.config.build_type }} -j2 -VV --timeout 1200 --test-dir ${{ env.DAW_BUILD_DIR }}/ From 3391ca1881901ed706df7910cc91c0233e83f2e4 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 20:07:04 -0400 Subject: [PATCH 22/64] Simplify `append_hash` logic in `daw_fnv1a_hash.h` by extracting `current_char` computation. --- include/daw/daw_fnv1a_hash.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/daw/daw_fnv1a_hash.h b/include/daw/daw_fnv1a_hash.h index e7f72642b..4db4445ac 100644 --- a/include/daw/daw_fnv1a_hash.h +++ b/include/daw/daw_fnv1a_hash.h @@ -69,10 +69,11 @@ namespace daw { [[nodiscard]] static constexpr fnv1a_uint_t append_hash( fnv1a_uint_t current_hash, Value const &value ) noexcept { for( fnv1a_uint_t n = 0; n < sizeof( Value ); ++n ) { - current_hash ^= static_cast( - ( static_cast( value ) & - ( fnv1a_uint_t{ 0xFFU } << (n * bit_count_v)) ) >> - (n * bit_count_v)); + auto const current_char = + ( static_cast( value ) >> (n * bit_count_v)) & + fnv1a_uint_t{ 0xFFU }; + current_hash ^= current_char; + current_hash *= fnv1a_impl::fnv_prime; } return current_hash; From 21012c6f0ae5ba41f781d8793c7eb79a27d13c59 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 20:11:07 -0400 Subject: [PATCH 23/64] Undid change to string_view --- include/daw/daw_string_view.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/include/daw/daw_string_view.h b/include/daw/daw_string_view.h index ca759bf05..b78110e75 100644 --- a/include/daw/daw_string_view.h +++ b/include/daw/daw_string_view.h @@ -1938,18 +1938,13 @@ namespace daw { reinterpret_cast( r ) - first ); } } - else { #endif - for( std::size_t n = pos; n < sz; ++n ) { - if( first[n] == c ) { - return n; - } + for( std::size_t n = pos; n < sz; ++n ) { + if( first[n] == c ) { + return n; } - return npos; - -#if defined( DAW_HAS_IF_CONSTEVAL_COMPAT ) } -#endif + return npos; } [[nodiscard]] DAW_ATTRIB_FLATTEN constexpr size_type From 5df2ddc40bab7525995e04c824824076e2601c90 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 20:36:44 -0400 Subject: [PATCH 24/64] Ensuring msvc::no_unique_address is used for clang-cl --- include/daw/daw_attributes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/daw/daw_attributes.h b/include/daw/daw_attributes.h index 90486f533..a78491b02 100644 --- a/include/daw/daw_attributes.h +++ b/include/daw/daw_attributes.h @@ -104,7 +104,7 @@ #endif -#if defined( DAW_HAS_MSVC ) +#if defined( DAW_HAS_MSVC_LIKE ) #define DAW_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] #else #define DAW_NO_UNIQUE_ADDRESS [[no_unique_address]] From 59fbd995ef091059924cfa4b0ad592156d343de2 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 20:51:32 -0400 Subject: [PATCH 25/64] Add `-Wno-missing-braces` compiler option to suppress warnings --- tests/cmake/test_compiler_options.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cmake/test_compiler_options.cmake b/tests/cmake/test_compiler_options.cmake index 34e857bf7..34dde0bb4 100644 --- a/tests/cmake/test_compiler_options.cmake +++ b/tests/cmake/test_compiler_options.cmake @@ -16,6 +16,7 @@ if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQU if( DAW_WERROR ) add_compile_options( /WX ) endif() + add_compile_options( -Wno-missing-braces ) else() message( STATUS "Clang ${CMAKE_CXX_COMPILER_VERSION} detected" ) add_compile_options( From 1e6f46739d2836ef8ab162856fc1c838f912e216 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 20:58:38 -0400 Subject: [PATCH 26/64] Remove unnecessary `constexpr` in `formatter::parse` signature --- ci_scripts/ci_windows_build.cmd | 22 ------------------- ci_scripts/ci_windows_build_clangcl.cmd | 16 -------------- ci_scripts/ci_windows_install_test.cmd | 20 ----------------- .../ci_windows_install_test_clangcl.cmd | 20 ----------------- ci_scripts/ci_windows_test.cmd | 6 ----- include/daw/daw_format_range.h | 2 +- 6 files changed, 1 insertion(+), 85 deletions(-) delete mode 100755 ci_scripts/ci_windows_build.cmd delete mode 100755 ci_scripts/ci_windows_build_clangcl.cmd delete mode 100755 ci_scripts/ci_windows_install_test.cmd delete mode 100755 ci_scripts/ci_windows_install_test_clangcl.cmd delete mode 100755 ci_scripts/ci_windows_test.cmd diff --git a/ci_scripts/ci_windows_build.cmd b/ci_scripts/ci_windows_build.cmd deleted file mode 100755 index 0d68f8339..000000000 --- a/ci_scripts/ci_windows_build.cmd +++ /dev/null @@ -1,22 +0,0 @@ -@ECHO OFF - -ECHO "##############################" -ECHO "Installing Ninja" -vcpkg upgrade -REM vcpkg install ninja - -md build -cd build - -ECHO "##############################" -ECHO "Setting VCVars" -@call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 - -ECHO "##############################" -ECHO "Running cmake" -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_C_COMPILER=cl.exe -DDAW_ENABLE_TESTING=On .. - - -ECHO "##############################" -ECHO "Building" -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug --target daw-header-libraries_full -j 2 -- -k 1000 diff --git a/ci_scripts/ci_windows_build_clangcl.cmd b/ci_scripts/ci_windows_build_clangcl.cmd deleted file mode 100755 index 509cbf7da..000000000 --- a/ci_scripts/ci_windows_build_clangcl.cmd +++ /dev/null @@ -1,16 +0,0 @@ -@ECHO OFF - -md build -cd build - -ECHO "##############################" -ECHO "Setting VCVars" -@call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 - -ECHO "##############################" -ECHO "Running cmake" -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DDAW_ENABLE_TESTING=On .. - -ECHO "##############################" -ECHO "Building" -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug --target daw-header-libraries_full -j 2 -- -k 1000 diff --git a/ci_scripts/ci_windows_install_test.cmd b/ci_scripts/ci_windows_install_test.cmd deleted file mode 100755 index 03049d0b5..000000000 --- a/ci_scripts/ci_windows_install_test.cmd +++ /dev/null @@ -1,20 +0,0 @@ -@echo off -cd build - - -ECHO "##############################" -ECHO "Setting VCVars" -@call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 - -echo "#################################" -echo "Starting Install Tests" -cmake --install . -cd ../cmake/test_project/ -md build -cd build -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_C_COMPILER=cl.exe .. -IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug -IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/ctest.exe" -C Debug -VV -IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% diff --git a/ci_scripts/ci_windows_install_test_clangcl.cmd b/ci_scripts/ci_windows_install_test_clangcl.cmd deleted file mode 100755 index beaa39370..000000000 --- a/ci_scripts/ci_windows_install_test_clangcl.cmd +++ /dev/null @@ -1,20 +0,0 @@ -@ECHO OFF - -cd build - -ECHO "##############################" -ECHO "Setting VCVars" -@call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 - -echo "#################################" -echo "Starting Install Tests" -cmake --install . -cd ../cmake/test_project/ -md build -cd build -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe" .. -IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/cmake.exe" --build . --config Debug -IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/ctest.exe" -C Debug -VV -IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% diff --git a/ci_scripts/ci_windows_test.cmd b/ci_scripts/ci_windows_test.cmd deleted file mode 100755 index d40c07052..000000000 --- a/ci_scripts/ci_windows_test.cmd +++ /dev/null @@ -1,6 +0,0 @@ -@echo off -cd build - -ECHO "#################################3" -ECHO "Starting Tests" -"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2022/ENTERPRISE/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CMAKE/CMake/bin/ctest.exe" -C Debug --target daw-header-libraries_full -j 2 -VV --timeout 300 diff --git a/include/daw/daw_format_range.h b/include/daw/daw_format_range.h index 9d01bde96..506c948c7 100644 --- a/include/daw/daw_format_range.h +++ b/include/daw/daw_format_range.h @@ -63,7 +63,7 @@ namespace std { formatter( ) = default; template - constexpr typename ParseContext::iterator parse( ParseContext &ctx ) { + typename ParseContext::iterator parse( ParseContext &ctx ) { auto f = daw::string_view( ctx.begin( ), ctx.end( ) ); if( ctx.begin( ) == ctx.end( ) or *ctx.begin( ) == '}' ) { flags = "{}"; From 8931321934836a372745eefd7547c1c1e06d2af9 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 21:14:17 -0400 Subject: [PATCH 27/64] Refactor `append_hash` to use `array_t` for byte extraction, simplifying logic. --- include/daw/daw_fnv1a_hash.h | 10 +++++----- include/daw/daw_format_range.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/daw/daw_fnv1a_hash.h b/include/daw/daw_fnv1a_hash.h index 4db4445ac..462250026 100644 --- a/include/daw/daw_fnv1a_hash.h +++ b/include/daw/daw_fnv1a_hash.h @@ -68,12 +68,12 @@ namespace daw { std::nullptr_t> = nullptr> [[nodiscard]] static constexpr fnv1a_uint_t append_hash( fnv1a_uint_t current_hash, Value const &value ) noexcept { + struct array_t { + unsigned char values[sizeof( Value )]; + }; + auto const chars = DAW_BIT_CAST( array_t, value ); for( fnv1a_uint_t n = 0; n < sizeof( Value ); ++n ) { - auto const current_char = - ( static_cast( value ) >> (n * bit_count_v)) & - fnv1a_uint_t{ 0xFFU }; - current_hash ^= current_char; - + current_hash ^= chars.values[n]; current_hash *= fnv1a_impl::fnv_prime; } return current_hash; diff --git a/include/daw/daw_format_range.h b/include/daw/daw_format_range.h index 506c948c7..9d01bde96 100644 --- a/include/daw/daw_format_range.h +++ b/include/daw/daw_format_range.h @@ -63,7 +63,7 @@ namespace std { formatter( ) = default; template - typename ParseContext::iterator parse( ParseContext &ctx ) { + constexpr typename ParseContext::iterator parse( ParseContext &ctx ) { auto f = daw::string_view( ctx.begin( ), ctx.end( ) ); if( ctx.begin( ) == ctx.end( ) or *ctx.begin( ) == '}' ) { flags = "{}"; From 8d3dddaf91682e396e0e51613b125a3d47e7554b Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 21:22:03 -0400 Subject: [PATCH 28/64] Change `operator""` return type from `size_t` to `unsigned long long` in `daw_size_literals` for consistency with input type. --- include/daw/daw_size_literals.h | 22 ++++++++++------------ tests/daw_size_literals_test.cpp | 4 ++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/include/daw/daw_size_literals.h b/include/daw/daw_size_literals.h index a10d61ae1..9f1cba752 100644 --- a/include/daw/daw_size_literals.h +++ b/include/daw/daw_size_literals.h @@ -8,55 +8,53 @@ #pragma once -#include - namespace daw::size_literals { - [[nodiscard]] constexpr size_t + [[nodiscard]] constexpr unsigned long long operator""_KB( unsigned long long val ) noexcept { return val * 1024ull; } - [[nodiscard]] constexpr size_t + [[nodiscard]] constexpr unsigned long long operator""_MB( unsigned long long val ) noexcept { return val * 1024ull * 1024ull; } - [[nodiscard]] constexpr size_t + [[nodiscard]] constexpr unsigned long long operator""_GB( unsigned long long val ) noexcept { return val * 1024ull * 1024ull * 1024ull; } - [[nodiscard]] constexpr size_t + [[nodiscard]] constexpr unsigned long long operator""_TB( unsigned long long val ) noexcept { return val * 1024ull * 1024ull * 1024ull * 1024ull; } - [[nodiscard]] constexpr size_t + [[nodiscard]] constexpr unsigned long long operator""_PB( unsigned long long val ) noexcept { return val * 1024ull * 1024ull * 1024ull * 1024ull * 1024ull; } - [[nodiscard]] constexpr size_t + [[nodiscard]] constexpr unsigned long long operator""_KiB( unsigned long long val ) noexcept { return val * 1000ull; } - [[nodiscard]] constexpr size_t + [[nodiscard]] constexpr unsigned long long operator""_MiB( unsigned long long val ) noexcept { return val * 1000ull * 1000ull; } - [[nodiscard]] constexpr size_t + [[nodiscard]] constexpr unsigned long long operator""_GiB( unsigned long long val ) noexcept { return val * 1000ull * 1000ull * 1000ull; } - [[nodiscard]] constexpr size_t + [[nodiscard]] constexpr unsigned long long operator""_TiB( unsigned long long val ) noexcept { return val * 1000ull * 1000ull * 1000ull * 1000ull; } - [[nodiscard]] constexpr size_t + [[nodiscard]] constexpr unsigned long long operator""_PiB( unsigned long long val ) noexcept { return val * 1000ull * 1000ull * 1000ull * 1000ull * 1000ull; } diff --git a/tests/daw_size_literals_test.cpp b/tests/daw_size_literals_test.cpp index ae6b95542..be0b27f69 100644 --- a/tests/daw_size_literals_test.cpp +++ b/tests/daw_size_literals_test.cpp @@ -13,8 +13,8 @@ namespace daw_size_literals_001 { static_assert( 1_KB == 1024ull ); static_assert( 1_MB == 1024ull * 1024u ); static_assert( 1_GB == 1024ull * 1024u * 1024u ); - static_assert( 1_TB == 1024ull * 1024u * 1024u * 1024u ); - static_assert( 1_PB == 1024ull * 1024u * 1024u * 1024u * 1024u ); + static_assert( 1_TB == 1024ull * 1024ull * 1024ull * 1024ull ); + static_assert( 1_PB == 1024ull * 1024ull * 1024ull * 1024ull * 1024ull ); } // namespace daw_size_literals_001 int main( ) {} From 4f5ace045a195c72d4fb653807a0add405e58e9b Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 21:28:08 -0400 Subject: [PATCH 29/64] Refine aggregate initialization in `daw_uninitialized_storage` by checking for class types. --- include/daw/daw_uninitialized_storage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/daw/daw_uninitialized_storage.h b/include/daw/daw_uninitialized_storage.h index f69150446..17363d8a4 100644 --- a/include/daw/daw_uninitialized_storage.h +++ b/include/daw/daw_uninitialized_storage.h @@ -39,7 +39,7 @@ namespace daw { void construct( Args &&...args ) noexcept( std::is_nothrow_constructible_v ) { - if constexpr( std::is_aggregate_v ) { + if constexpr( std::is_class_v and std::is_aggregate_v ) { new( m_data ) T{ DAW_FWD( args )... }; } else { new( m_data ) T( std ::forward( args )... ); From b7a1dacd781043d146e99268365dbdecab662d6c Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Thu, 3 Jul 2025 22:22:26 -0400 Subject: [PATCH 30/64] - Move `daw_contract_test.cpp` to `CPP20_NOT_MSVC_TEST_SOURCES` in CMakeLists. - Add MSVC-friendly file handling in `daw_read_file.h` with `fopen_s` and `_wfopen_s`. --- include/daw/daw_read_file.h | 13 +++++++++++-- tests/CMakeLists.txt | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/daw/daw_read_file.h b/include/daw/daw_read_file.h index c4b7a2440..40b0bd26d 100644 --- a/include/daw/daw_read_file.h +++ b/include/daw/daw_read_file.h @@ -36,10 +36,18 @@ namespace daw { } auto result = std::basic_string( static_cast( fsize ), CharT{ } ); +#if defined( _MSC_VER ) + FILE * f = nullptr; + auto err = fopen_s( &f, path.c_str( ), "rb" ); + if( err ) { + return std::nullopt; + } +#else auto *f = fopen( path.c_str( ), "rb" ); if( not f ) { return std::nullopt; } +#endif auto num_read = fread( result.data( ), sizeof( CharT ), result.size( ), f ); if( num_read != ( result.size( ) / sizeof( CharT ) ) ) { return std::nullopt; @@ -76,8 +84,9 @@ namespace daw { } auto result = std::basic_string( static_cast( fsize ), CharT{ } ); - auto *f = _wfopen( path.c_str( ), L"rb" ); - if( not f ) { + FILE * f = nullptr; + auto err = _wfopen_s( &f, path.c_str( ), L"rb" ); + if( err ) { return std::nullopt; } auto num_read = fread( result.data( ), sizeof( CharT ), result.size( ), f ); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1f0fbeec4..35408eedf 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -143,7 +143,6 @@ set( CPP20_TEST_SOURCES daw_atomic_wait_test.cpp daw_any_if_test.cpp daw_concepts_test.cpp - daw_contract_test.cpp daw_contiguous_view_test.cpp daw_formatters_test.cpp daw_iter_view_test.cpp @@ -154,6 +153,7 @@ set( CPP20_TEST_SOURCES ) set( CPP20_NOT_MSVC_TEST_SOURCES + daw_contract_test.cpp daw_pipelines_test.cpp vector_test.cpp ) From 4b11ef7b7997af29a87274da26e8174b63bc645d Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 5 Jul 2025 18:05:25 -0400 Subject: [PATCH 31/64] Remove redundant macOS CI scripts and modernize workflows with matrix strategy --- .github/workflows/ci_macos.yml | 67 +++++++++++++++++++++++----- ci_scripts/ci_add_llvm_apt_ubuntu.sh | 7 --- ci_scripts/ci_macos_build.sh | 18 -------- ci_scripts/ci_macos_install_test.sh | 15 ------- ci_scripts/ci_macos_test.sh | 7 --- 5 files changed, 56 insertions(+), 58 deletions(-) delete mode 100755 ci_scripts/ci_add_llvm_apt_ubuntu.sh delete mode 100755 ci_scripts/ci_macos_build.sh delete mode 100755 ci_scripts/ci_macos_install_test.sh delete mode 100755 ci_scripts/ci_macos_test.sh diff --git a/.github/workflows/ci_macos.yml b/.github/workflows/ci_macos.yml index 06a3aaa9a..d0b665d8f 100644 --- a/.github/workflows/ci_macos.yml +++ b/.github/workflows/ci_macos.yml @@ -1,19 +1,64 @@ name: MacOS on: + schedule: + - cron: '0 5 * * *' push: - branches-ignore: dev + branches: [ release, develop ] pull_request: - branches-ignore: dev + push: + branches-ignore: develop + pull_request: + branches-ignore: develop jobs: - build: - runs-on: [macOS-latest] + CI_Tests: + permissions: + actions: none + checks: none + contents: none + deployments: none + issues: none + packages: none + pull-requests: none + repository-projects: none + security-events: none + statuses: none + strategy: + fail-fast: false + matrix: + cpp_version: [ 17, 20 ] + build_type: [ Debug, Release ] + os: [ macos-latest, macos-14 ] + toolset: [ clang++ ] + runs-on: ${{ matrix.os }} + name: "${{ matrix.os }} ${{ matrix.toolset }} ${{ matrix.cpp_version }} ${{ matrix.build_type }}" steps: - - uses: actions/checkout@v1 - - name: Build - run: ./ci_scripts/ci_macos_build.sh - - name: Test - run: ./ci_scripts/ci_macos_test.sh - - name: InstallTest - run: ./ci_scripts/ci_macos_install_test.sh + - uses: actions/checkout@v1 + - name: Create Build + run: | + mkdir build && \ + brew install ninja + - name: Build Dependencies + env: + CXX: ${{ matrix.toolset }} + run: cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DDAW_NUM_RUNS=1 -DDAW_ENABLE_TESTING=ON -DDAW_WERROR=ON -DDAW_JSON_USE_SANITIZERS=ON -DDAW_NO_FLATTEN=ON -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} -Bbuild/ . + - name: Build + run: cmake --build build/ --target daw-header-libraries_full -- -k 0 + continue-on-error: true + - name: Test + run: | + ulimit -c unlimited + ulimit -c + ctest -C ${{ matrix.build_type }} -j2 -VV --timeout 1200 --test-dir build/ + - name: Archive any crashes as an artifact + uses: actions/upload-artifact@v4 + if: always( ) + with: + name: crashes + path: | + crash-* + leak-* + timeout-* + /cores/** + if-no-files-found: ignore \ No newline at end of file diff --git a/ci_scripts/ci_add_llvm_apt_ubuntu.sh b/ci_scripts/ci_add_llvm_apt_ubuntu.sh deleted file mode 100755 index 163f6b0f4..000000000 --- a/ci_scripts/ci_add_llvm_apt_ubuntu.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -echo "#################################" -echo "Installing llvm" -wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc -apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble main' -apt-add-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main' \ No newline at end of file diff --git a/ci_scripts/ci_macos_build.sh b/ci_scripts/ci_macos_build.sh deleted file mode 100755 index 54b8de43c..000000000 --- a/ci_scripts/ci_macos_build.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -mkdir build -cd build - -echo "#################################" -echo "Install Ninja" -brew install ninja - -echo "#################################" -echo "Configure Cmake" -cmake -GNinja -DCMAKE_BUILD_TYPE=Debug .. -DDAW_ENABLE_TESTING=On -DCMAKE_INSTALL_PREFIX=/tmp/header_libraries - -echo "#################################" -echo "Starting full build" -cmake --build . --config Debug --target daw-header-libraries_full -j 2 -echo "#################################" -echo "Full build complete" diff --git a/ci_scripts/ci_macos_install_test.sh b/ci_scripts/ci_macos_install_test.sh deleted file mode 100755 index a913d771a..000000000 --- a/ci_scripts/ci_macos_install_test.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -e - -cd build - -echo "#################################" -echo "Starting Install Tests" -cmake --install . -cd ../cmake/test_project/ -mkdir build -cd build -cmake .. -DCMAKE_PREFIX_PATH=/tmp/header_libraries/ -cmake --build . -ctest -C Debug -VV diff --git a/ci_scripts/ci_macos_test.sh b/ci_scripts/ci_macos_test.sh deleted file mode 100755 index 1e7646f00..000000000 --- a/ci_scripts/ci_macos_test.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -cd build - -echo "#################################" -echo "Starting Tests" -ctest -C Debug --build-target daw-header-libraries_full -j 2 From 5ddaf849b93e543f9065a89307bbd13799e4f7b1 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 5 Jul 2025 18:09:01 -0400 Subject: [PATCH 32/64] Update CI workflows to use `master` and `v2` branches, adjust ignored branches --- .github/workflows/ci_macos.yml | 6 +++--- .github/workflows/ci_ubuntu.yml | 4 ++-- .github/workflows/ci_windows.yml | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci_macos.yml b/.github/workflows/ci_macos.yml index d0b665d8f..94e2a77dc 100644 --- a/.github/workflows/ci_macos.yml +++ b/.github/workflows/ci_macos.yml @@ -4,12 +4,12 @@ on: schedule: - cron: '0 5 * * *' push: - branches: [ release, develop ] + branches: [ master, v2 ] pull_request: push: - branches-ignore: develop + branches-ignore: dev, v2 pull_request: - branches-ignore: develop + branches-ignore: dev, v2 jobs: CI_Tests: diff --git a/.github/workflows/ci_ubuntu.yml b/.github/workflows/ci_ubuntu.yml index 5d2082aa5..c5b2f6d28 100644 --- a/.github/workflows/ci_ubuntu.yml +++ b/.github/workflows/ci_ubuntu.yml @@ -2,9 +2,9 @@ name: Ubuntu on: push: - branches-ignore: develop + branches-ignore: dev pull_request: - branches-ignore: develop + branches-ignore: dev, v2 jobs: CI_Tests: diff --git a/.github/workflows/ci_windows.yml b/.github/workflows/ci_windows.yml index 4e96f8b42..65e019cf3 100644 --- a/.github/workflows/ci_windows.yml +++ b/.github/workflows/ci_windows.yml @@ -3,12 +3,12 @@ on: schedule: - cron: '10 5 * * *' push: - branches: [ release, develop ] + branches: [ master, v2 ] pull_request: push: - branches-ignore: develop + branches-ignore: dev, v2 pull_request: - branches-ignore: develop + branches-ignore: dev, v2 jobs: Windows: From 0d07c0d8709c558295fc02d0e51916a1adf00acd Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 5 Jul 2025 18:43:57 -0400 Subject: [PATCH 33/64] Remove redundant Ubuntu CI scripts and clean up macOS workflow configuration --- .github/workflows/ci_macos.yml | 2 +- ci_scripts/ci_ubuntu_build.sh | 15 --------------- ci_scripts/ci_ubuntu_install_test.sh | 15 --------------- ci_scripts/ci_ubuntu_test.sh | 7 ------- 4 files changed, 1 insertion(+), 38 deletions(-) delete mode 100755 ci_scripts/ci_ubuntu_build.sh delete mode 100755 ci_scripts/ci_ubuntu_install_test.sh delete mode 100755 ci_scripts/ci_ubuntu_test.sh diff --git a/.github/workflows/ci_macos.yml b/.github/workflows/ci_macos.yml index 94e2a77dc..421fcbb78 100644 --- a/.github/workflows/ci_macos.yml +++ b/.github/workflows/ci_macos.yml @@ -42,7 +42,7 @@ jobs: - name: Build Dependencies env: CXX: ${{ matrix.toolset }} - run: cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DDAW_NUM_RUNS=1 -DDAW_ENABLE_TESTING=ON -DDAW_WERROR=ON -DDAW_JSON_USE_SANITIZERS=ON -DDAW_NO_FLATTEN=ON -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} -Bbuild/ . + run: cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DDAW_ENABLE_TESTING=ON -DDAW_WERROR=ON -DDAW_JSON_USE_SANITIZERS=ON -DDAW_NO_FLATTEN=ON -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} -Bbuild/ . - name: Build run: cmake --build build/ --target daw-header-libraries_full -- -k 0 continue-on-error: true diff --git a/ci_scripts/ci_ubuntu_build.sh b/ci_scripts/ci_ubuntu_build.sh deleted file mode 100755 index eef1ea644..000000000 --- a/ci_scripts/ci_ubuntu_build.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -mkdir build -cd build - -echo "#################################" -echo "Configure Cmake" -CC=clang-20 CXX=clang++-20 CXXFLAGS=-stdlib=libc++ cmake -DCMAKE_BUILD_TYPE=Debug -DDAW_ENABLE_TESTING=On .. - -echo "#################################" -echo "Starting full build" -cmake --build . --config Debug --target daw-header-libraries_full -j 2 -- -k 1000 -echo "#################################" -echo "Full build complete" - diff --git a/ci_scripts/ci_ubuntu_install_test.sh b/ci_scripts/ci_ubuntu_install_test.sh deleted file mode 100755 index 8c53397a3..000000000 --- a/ci_scripts/ci_ubuntu_install_test.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -e - -cd build - -echo "#################################" -echo "Starting Install Tests" -sudo cmake --install . -cd ../cmake/test_project/ -mkdir build -cd build -cmake .. -cmake --build . -ctest -C Debug -VV diff --git a/ci_scripts/ci_ubuntu_test.sh b/ci_scripts/ci_ubuntu_test.sh deleted file mode 100755 index 5da27e920..000000000 --- a/ci_scripts/ci_ubuntu_test.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -cd build - -echo "#################################3" -echo "Starting Tests" -ctest -C Debug --build-target daw-header-libraries_full -j 2 From c2ba2e911382fe45cf417e6d8750135126fbb788 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 5 Jul 2025 21:39:52 -0400 Subject: [PATCH 34/64] Enable stricter compiler warnings and update CI configurations --- .github/workflows/ci_macos.yml | 2 +- .github/workflows/ci_ubuntu.yml | 2 +- .github/workflows/ci_windows.yml | 2 +- tests/cmake/test_compiler_options.cmake | 12 +++++++++++- tests/daw_pipelines_test.cpp | 4 ++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_macos.yml b/.github/workflows/ci_macos.yml index 421fcbb78..6d370e36c 100644 --- a/.github/workflows/ci_macos.yml +++ b/.github/workflows/ci_macos.yml @@ -42,7 +42,7 @@ jobs: - name: Build Dependencies env: CXX: ${{ matrix.toolset }} - run: cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DDAW_ENABLE_TESTING=ON -DDAW_WERROR=ON -DDAW_JSON_USE_SANITIZERS=ON -DDAW_NO_FLATTEN=ON -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} -Bbuild/ . + run: cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DDAW_ENABLE_TESTING=ON -DDAW_WERROR=ON -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} -Bbuild/ . - name: Build run: cmake --build build/ --target daw-header-libraries_full -- -k 0 continue-on-error: true diff --git a/.github/workflows/ci_ubuntu.yml b/.github/workflows/ci_ubuntu.yml index c5b2f6d28..d7853fd85 100644 --- a/.github/workflows/ci_ubuntu.yml +++ b/.github/workflows/ci_ubuntu.yml @@ -82,7 +82,7 @@ jobs: run: | mkdir build - name: Build Dependencies - run: cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DDAW_ENABLE_TESTING=ON -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} -Bbuild/ . + run: cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DDAW_ENABLE_TESTING=ON -DDAW_WERROR=ON -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} -Bbuild/ . - name: Build run: cmake --build build/ --target daw-header-libraries_full -- -k 0 continue-on-error: true diff --git a/.github/workflows/ci_windows.yml b/.github/workflows/ci_windows.yml index 65e019cf3..3681eeb0c 100644 --- a/.github/workflows/ci_windows.yml +++ b/.github/workflows/ci_windows.yml @@ -54,7 +54,7 @@ jobs: - name: Setup Build Environment run: md ${{ env.DAW_BUILD_DIR }} - name: CMake Config - run: cmake.exe ${{ matrix.config.cmake_flags }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCMAKE_CXX_STANDARD=${{ matrix.config.cpp_version }} -DDAW_ENABLE_TESTING=On -B${{ env.DAW_BUILD_DIR }}/ . + run: cmake.exe ${{ matrix.config.cmake_flags }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCMAKE_CXX_STANDARD=${{ matrix.config.cpp_version }} -DDAW_ENABLE_TESTING=ON -DDAW_WERROR=ON -B${{ env.DAW_BUILD_DIR }}/ . - name: Build run: cmake.exe --build ${{ env.DAW_BUILD_DIR }}/ --target daw-header-libraries_full --config ${{ matrix.config.build_type }} continue-on-error: true diff --git a/tests/cmake/test_compiler_options.cmake b/tests/cmake/test_compiler_options.cmake index 34dde0bb4..527938cfe 100644 --- a/tests/cmake/test_compiler_options.cmake +++ b/tests/cmake/test_compiler_options.cmake @@ -68,6 +68,11 @@ if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQU -Wno-c++2b-extensions -Wno-c++20-compat ) + if( CMAKE_CXX_COMPILER_VERSION LESS "16.0.0" ) + add_compile_options( + -Wno-undefined-func-template + ) + endif() endif() add_compile_options( -Wno-poison-system-directories ) @@ -101,8 +106,13 @@ if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQU if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 16.0.0 ) add_compile_options( -Wno-unsafe-buffer-usage - -Wc++2b-extensions + -Wno-c++2b-extensions ) + if( CMAKE_CXX_COMPILER_VERSION LESS 17.0.0 ) + add_compile_options( + -Wno-undefined-func-template + ) + endif() endif() if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 17.0.0 ) add_compile_options( diff --git a/tests/daw_pipelines_test.cpp b/tests/daw_pipelines_test.cpp index e6ac795cf..10cdbbc73 100644 --- a/tests/daw_pipelines_test.cpp +++ b/tests/daw_pipelines_test.cpp @@ -548,13 +548,13 @@ namespace tests { static constexpr int arr1[] = { 0, 1, 2, 3, 4 }; static constexpr int arr2[] = { 0, 100, 200, 300, 400 }; - constexpr auto zipped = pipeline( Zip, MapApply( std::plus{ } ) ); + constexpr auto zipped = pipeline( Zip, MapApply( std::plus<>{ } ) ); daw::println( "test032: Expecting: 0, 101, 202, 303, 404" ); for( auto p : zipped( arr1, arr2 ) ) { daw::println( "{}", p ); } constexpr auto zipped2 = - pipeline( Zip( arr1, arr2 ), MapApply( std::plus{ } ) ); + pipeline( Zip( arr1, arr2 ), MapApply( std::plus<>{ } ) ); for( auto p : zipped2 ) { daw::println( "{}", p ); } From 5def6b9d45a969aa69df9b0eadf2ef881b4ee268 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 5 Jul 2025 21:59:50 -0400 Subject: [PATCH 35/64] Update CI workflows with new macOS and Ubuntu configurations --- .github/workflows/ci_macos.yml | 2 +- .github/workflows/ci_ubuntu.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_macos.yml b/.github/workflows/ci_macos.yml index 6d370e36c..6622f7530 100644 --- a/.github/workflows/ci_macos.yml +++ b/.github/workflows/ci_macos.yml @@ -29,7 +29,7 @@ jobs: matrix: cpp_version: [ 17, 20 ] build_type: [ Debug, Release ] - os: [ macos-latest, macos-14 ] + os: [ macos-15, macos-14 ] toolset: [ clang++ ] runs-on: ${{ matrix.os }} name: "${{ matrix.os }} ${{ matrix.toolset }} ${{ matrix.cpp_version }} ${{ matrix.build_type }}" diff --git a/.github/workflows/ci_ubuntu.yml b/.github/workflows/ci_ubuntu.yml index d7853fd85..4eae6515e 100644 --- a/.github/workflows/ci_ubuntu.yml +++ b/.github/workflows/ci_ubuntu.yml @@ -25,7 +25,7 @@ jobs: cpp_version: [ 17, 20 ] build_type: [ Debug, Release ] os: [ ubuntu-24.04 ] - toolset: [ g++-12, g++-13, clang++-19, clang++-20 ] + toolset: [ g++-12, g++-13, g++-15 clang++-19, clang++-20 ] exclude: - toolset: g++-12 cpp_version: 20 From e1bc445d702a0987ee96ea2b0957ac4e8b9b0821 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 5 Jul 2025 22:05:15 -0400 Subject: [PATCH 36/64] Fix typo in Ubuntu CI toolset and simplify compiler options handling --- .github/workflows/ci_ubuntu.yml | 2 +- tests/cmake/test_compiler_options.cmake | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_ubuntu.yml b/.github/workflows/ci_ubuntu.yml index 4eae6515e..55090161d 100644 --- a/.github/workflows/ci_ubuntu.yml +++ b/.github/workflows/ci_ubuntu.yml @@ -25,7 +25,7 @@ jobs: cpp_version: [ 17, 20 ] build_type: [ Debug, Release ] os: [ ubuntu-24.04 ] - toolset: [ g++-12, g++-13, g++-15 clang++-19, clang++-20 ] + toolset: [ g++-12, g++-13, g++-15, clang++-19, clang++-20 ] exclude: - toolset: g++-12 cpp_version: 20 diff --git a/tests/cmake/test_compiler_options.cmake b/tests/cmake/test_compiler_options.cmake index 527938cfe..a9f819a96 100644 --- a/tests/cmake/test_compiler_options.cmake +++ b/tests/cmake/test_compiler_options.cmake @@ -67,12 +67,8 @@ if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQU add_compile_options( -Wno-c++2b-extensions -Wno-c++20-compat + -Wno-undefined-func-template ) - if( CMAKE_CXX_COMPILER_VERSION LESS "16.0.0" ) - add_compile_options( - -Wno-undefined-func-template - ) - endif() endif() add_compile_options( -Wno-poison-system-directories ) From d0ad53acdc791bec4b461ba85557465509b37ead Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 5 Jul 2025 22:12:50 -0400 Subject: [PATCH 37/64] Remove g++-15 from Ubuntu CI toolset and add warning 2220 suppression in tests --- .github/workflows/ci_ubuntu.yml | 2 +- tests/cmake/test_compiler_options.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_ubuntu.yml b/.github/workflows/ci_ubuntu.yml index 55090161d..d7853fd85 100644 --- a/.github/workflows/ci_ubuntu.yml +++ b/.github/workflows/ci_ubuntu.yml @@ -25,7 +25,7 @@ jobs: cpp_version: [ 17, 20 ] build_type: [ Debug, Release ] os: [ ubuntu-24.04 ] - toolset: [ g++-12, g++-13, g++-15, clang++-19, clang++-20 ] + toolset: [ g++-12, g++-13, clang++-19, clang++-20 ] exclude: - toolset: g++-12 cpp_version: 20 diff --git a/tests/cmake/test_compiler_options.cmake b/tests/cmake/test_compiler_options.cmake index a9f819a96..822edc2b4 100644 --- a/tests/cmake/test_compiler_options.cmake +++ b/tests/cmake/test_compiler_options.cmake @@ -219,7 +219,7 @@ elseif( MSVC ) else() add_compile_options( /W4 ) endif() - add_compile_options( /wd4127 /WX ) + add_compile_options( /wd4127 /wd2220 /WX ) add_definitions( -D_CRT_SECURE_NO_WARNINGS ) endif() if( DAW_HEADERLIBS_USE_SANITIZERS ) From 35cc011ac20580e7607c84ed576c97374abf0da9 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sun, 6 Jul 2025 22:24:13 -0400 Subject: [PATCH 38/64] Update minimum required C++ compiler version to 14 for debug flag configuration. It was giving false positives for graph stuff/libstdc++ --- tests/cmake/test_compiler_options.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cmake/test_compiler_options.cmake b/tests/cmake/test_compiler_options.cmake index 822edc2b4..c93d6ef0c 100644 --- a/tests/cmake/test_compiler_options.cmake +++ b/tests/cmake/test_compiler_options.cmake @@ -189,7 +189,7 @@ elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" ) endif() set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -DDEBUG" ) set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g -DDEBUG" ) - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 12.0.0 ) + if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 14.0.0 ) set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wnull-dereference" ) endif() From 2fbc1154c2d399c76302a8a5edc8a458591292fe Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 11 Jul 2025 11:01:43 -0400 Subject: [PATCH 39/64] Suppress MSVC warning 4305 in test compiler options configuration. --- tests/cmake/test_compiler_options.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cmake/test_compiler_options.cmake b/tests/cmake/test_compiler_options.cmake index c93d6ef0c..7e7afa9e8 100644 --- a/tests/cmake/test_compiler_options.cmake +++ b/tests/cmake/test_compiler_options.cmake @@ -219,7 +219,7 @@ elseif( MSVC ) else() add_compile_options( /W4 ) endif() - add_compile_options( /wd4127 /wd2220 /WX ) + add_compile_options( /wd4127 /wd2220 /wd4305 /WX ) add_definitions( -D_CRT_SECURE_NO_WARNINGS ) endif() if( DAW_HEADERLIBS_USE_SANITIZERS ) From 64d72471ccfd57ea38afe5d62a83b1dc5ee0b230 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 11 Jul 2025 11:18:50 -0400 Subject: [PATCH 40/64] Refactor: replace `size_t` with `std::uint64_t` in `daw_hash_set` to ensure 64bit values --- include/daw/daw_hash_set.h | 31 ++++++++++++++++--------------- tests/daw_hash_set_test.cpp | 16 ++++++++-------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/include/daw/daw_hash_set.h b/include/daw/daw_hash_set.h index b359f0262..0d084b584 100644 --- a/include/daw/daw_hash_set.h +++ b/include/daw/daw_hash_set.h @@ -9,9 +9,10 @@ #pragma once #include "ciso646.h" -#include "daw_algorithm.h" #include "daw/daw_check_exceptions.h" +#include "daw_algorithm.h" +#include #include #include #include @@ -21,18 +22,18 @@ namespace daw { class hash_set_t { std::vector> m_indices; - [[nodiscard]] static constexpr size_t scale_hash( size_t hash, - size_t range_size ) { - size_t const prime_a = 18446744073709551557u; - size_t const prime_b = 18446744073709551533u; + [[nodiscard]] static constexpr std::uint64_t + scale_hash( std::uint64_t hash, std::uint64_t range_size ) { + constexpr std::uint64_t prime_a = 18446744073709551557ull; + constexpr std::uint64_t prime_b = 18446744073709551533ull; return ( hash * prime_a + prime_b ) % range_size; } - [[nodiscard]] std::optional find_index( size_t hash, - Key const &key ) const { - size_t const scaled_hash = scale_hash( hash, m_indices.size( ) ); + [[nodiscard]] std::optional + find_index( std::uint64_t hash, Key const &key ) const { + std::uint64_t const scaled_hash = scale_hash( hash, m_indices.size( ) ); - for( size_t n = scaled_hash; n < m_indices.size( ); ++n ) { + for( std::uint64_t n = scaled_hash; n < m_indices.size( ); ++n ) { if( !m_indices[n] ) { return n; } @@ -40,7 +41,7 @@ namespace daw { return n; } } - for( size_t n = 0; n < scaled_hash; ++n ) { + for( std::uint64_t n = 0; n < scaled_hash; ++n ) { if( !m_indices[n] ) { return n; } @@ -52,10 +53,10 @@ namespace daw { } public: - hash_set_t( size_t range_size ) noexcept + hash_set_t( std::uint64_t range_size ) noexcept : m_indices( range_size, std::nullopt ) {} - size_t insert( Key const &key ) { + std::uint64_t insert( Key const &key ) { auto const hash = Hash{ }( key ); auto const index = find_index( hash, key ); if( not index ) { @@ -65,7 +66,7 @@ namespace daw { return *index; } - std::optional erase( Key const &key ) { + std::optional erase( Key const &key ) { auto const hash = Hash{ }( key ); auto const index = find_index( hash, key ); if( not index ) { @@ -86,11 +87,11 @@ namespace daw { return exists( key ) ? 1 : 0; } - [[nodiscard]] size_t capacity( ) const noexcept { + [[nodiscard]] std::uint64_t capacity( ) const noexcept { return m_indices.size( ); } - [[nodiscard]] size_t size( ) const noexcept { + [[nodiscard]] std::uint64_t size( ) const noexcept { return daw::algorithm::accumulate( std::begin( m_indices ), std::end( m_indices ), 0ULL, []( auto const &opt ) { diff --git a/tests/daw_hash_set_test.cpp b/tests/daw_hash_set_test.cpp index ecc76c1c1..557498527 100644 --- a/tests/daw_hash_set_test.cpp +++ b/tests/daw_hash_set_test.cpp @@ -10,23 +10,23 @@ #include "daw/daw_benchmark.h" -#include +#include void test_001( ) { - size_t count = 1024ULL; - daw::hash_set_t adapt( count ); - for( size_t n = 0; n < count; ++n ) { + std::uint64_t count = 1024ULL; + daw::hash_set_t adapt( count ); + for( std::uint64_t n = 0; n < count; ++n ) { adapt.insert( n ); } } void test_003( ) { - size_t count = 1024ULL; - daw::hash_set_t adapt( count ); - for( size_t n = 0; n < count; ++n ) { + std::uint64_t count = 1024ULL; + daw::hash_set_t adapt( count ); + for( std::uint64_t n = 0; n < count; ++n ) { adapt.insert( n ); } - for( size_t n = 0; n < count; ++n ) { + for( std::uint64_t n = 0; n < count; ++n ) { daw::expecting( adapt.exists( n ) ); } } From ed24d5bb9ec6f4884772731b65a2447bcc2cb9b0 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 11 Jul 2025 11:49:07 -0400 Subject: [PATCH 41/64] Suppress MSVC warning 4296 and update test compiler options configuration. --- tests/cmake/test_compiler_options.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cmake/test_compiler_options.cmake b/tests/cmake/test_compiler_options.cmake index 7e7afa9e8..c4e195c92 100644 --- a/tests/cmake/test_compiler_options.cmake +++ b/tests/cmake/test_compiler_options.cmake @@ -212,14 +212,14 @@ elseif( MSVC ) # Ensure that string pooling is enabled. Otherwise it breaks constexpr string literals. # This affects debug modes by default, but optionally Release # https://developercommunity.visualstudio.com/t/codegen:-constexpr-pointer-to-trailing-z/900648 - add_compile_options( "/GF" ) + # shouldn't be needed any longer add_compile_options( "/GF" ) if( DAW_WERROR ) if( CMAKE_CXX_FLAGS MATCHES "/W[0-4]" ) string( REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" ) else() add_compile_options( /W4 ) endif() - add_compile_options( /wd4127 /wd2220 /wd4305 /WX ) + add_compile_options( /wd4127 /wd4296 /wd4305 /WX ) add_definitions( -D_CRT_SECURE_NO_WARNINGS ) endif() if( DAW_HEADERLIBS_USE_SANITIZERS ) From dc84d53cb54b01fb1f3bf981868d02060ecd2b1b Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 11 Jul 2025 12:06:57 -0400 Subject: [PATCH 42/64] Flush output stream in `output_expected_error`, fix `else` consistency in `daw_stack_function`, and suppress MSVC warning 4324 in test compiler options. --- include/daw/daw_benchmark.h | 2 +- include/daw/daw_stack_function.h | 3 ++- tests/cmake/test_compiler_options.cmake | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/daw/daw_benchmark.h b/include/daw/daw_benchmark.h index 40a9dd0c5..1b0cb410f 100644 --- a/include/daw/daw_benchmark.h +++ b/include/daw/daw_benchmark.h @@ -594,7 +594,7 @@ namespace daw { DAW_ATTRIB_NOINLINE void output_expected_error( T &&expected_result, U &&result ) { std::cerr << "Invalid result. Expecting '" << expected_result - << "' but got '" << result << "'\n"; + << "' but got '" << result << "'\n" << std::flush; } template< diff --git a/include/daw/daw_stack_function.h b/include/daw/daw_stack_function.h index 7b72002a6..b8b025cd9 100644 --- a/include/daw/daw_stack_function.h +++ b/include/daw/daw_stack_function.h @@ -188,8 +188,9 @@ namespace daw { return f.empty( ); } else if constexpr( func_impl::is_boolable_v ) { return not static_cast( f ); + } else { + return false; } - return false; } public: diff --git a/tests/cmake/test_compiler_options.cmake b/tests/cmake/test_compiler_options.cmake index c4e195c92..899699819 100644 --- a/tests/cmake/test_compiler_options.cmake +++ b/tests/cmake/test_compiler_options.cmake @@ -219,7 +219,7 @@ elseif( MSVC ) else() add_compile_options( /W4 ) endif() - add_compile_options( /wd4127 /wd4296 /wd4305 /WX ) + add_compile_options( /wd4127 /wd4296 /wd4305 /wd4324 /WX ) add_definitions( -D_CRT_SECURE_NO_WARNINGS ) endif() if( DAW_HEADERLIBS_USE_SANITIZERS ) From 20822762f268e21723e1c178989893a523c98545 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Fri, 11 Jul 2025 12:22:36 -0400 Subject: [PATCH 43/64] Flush `std::cerr` output before calling `std::terminate` in benchmarking utilities. --- include/daw/daw_benchmark.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/daw/daw_benchmark.h b/include/daw/daw_benchmark.h index 1b0cb410f..6cfd876c4 100644 --- a/include/daw/daw_benchmark.h +++ b/include/daw/daw_benchmark.h @@ -352,7 +352,7 @@ namespace daw { daw::do_not_optimize( result ); auto const valid_start = std::chrono::steady_clock::now( ); if( DAW_UNLIKELY( not validator( result ) ) ) { - std::cerr << "Error validating result\n"; + std::cerr << "Error validating result\n" << std::flush; std::terminate( ); } valid_time += benchmark_impl::second_duration( @@ -568,7 +568,7 @@ namespace daw { auto const finish = std::chrono::steady_clock::now( ); daw::do_not_optimize( result ); if( DAW_UNLIKELY( not validator( std::move( result ) ) ) ) { - std::cerr << "Error validating result\n"; + std::cerr << "Error validating result\n" << std::flush; std::terminate( ); } @@ -602,7 +602,7 @@ namespace daw { std::enable_if_t<(not is_streamable_v and not is_streamable_v), std::nullptr_t> = nullptr> DAW_ATTRIB_NOINLINE constexpr void output_expected_error( T &&, U && ) { - std::cerr << "Invalid or unexpected result\n"; + std::cerr << "Invalid or unexpected result\n" << std::flush; } } // namespace benchmark_impl @@ -624,7 +624,7 @@ namespace daw { template DAW_ATTRIB_NOINLINE constexpr void expecting( Bool const &expected_result ) { if( not static_cast( expected_result ) ) { - std::cerr << "Invalid result. Expecting true\n"; + std::cerr << "Invalid result. Expecting true\n" << std::flush; std::terminate( ); } } @@ -634,7 +634,7 @@ namespace daw { String &&message ) { do_not_optimize( expected_result ); if( DAW_UNLIKELY( not( expected_result ) ) ) { - std::cerr << message << '\n'; + std::cerr << message << '\n' << std::flush; std::terminate( ); } (void)message; @@ -667,9 +667,9 @@ namespace daw { if( DAW_FWD( pred )( ex ) ) { return; } - std::cerr << "Failed predicate\n"; + std::cerr << "Failed predicate\n" << std::flush; } catch( ... ) { - std::cerr << "Unexpected exception\n"; + std::cerr << "Unexpected exception\n" << std::flush; throw; } std::terminate( ); From a0e72ffd2de96f243e8e94021ce32bc03fa6790a Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 10:51:54 -0400 Subject: [PATCH 44/64] Refactor `daw_hash_set` to use `not` instead of `!` and adjust logic in `exists` for clarity. --- include/daw/daw_hash_set.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/daw/daw_hash_set.h b/include/daw/daw_hash_set.h index 0d084b584..210ac4af7 100644 --- a/include/daw/daw_hash_set.h +++ b/include/daw/daw_hash_set.h @@ -34,7 +34,7 @@ namespace daw { std::uint64_t const scaled_hash = scale_hash( hash, m_indices.size( ) ); for( std::uint64_t n = scaled_hash; n < m_indices.size( ); ++n ) { - if( !m_indices[n] ) { + if( not m_indices[n] ) { return n; } if( *m_indices[n] == key ) { @@ -42,7 +42,7 @@ namespace daw { } } for( std::uint64_t n = 0; n < scaled_hash; ++n ) { - if( !m_indices[n] ) { + if( not m_indices[n] ) { return n; } if( *m_indices[n] == key ) { @@ -79,8 +79,10 @@ namespace daw { [[nodiscard]] bool exists( Key const &key ) const noexcept { auto const hash = Hash{ }( key ); auto const index = find_index( hash, key ); - return static_cast( index ) and - static_cast( m_indices[*index] ); + if( index ) { + return static_cast( m_indices[*index] ); + } + return false; } [[nodiscard]] bool count( Key const &key ) const noexcept { From 66e57229662d31db59d0d86671c1b1fa02ff581c Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 11:06:15 -0400 Subject: [PATCH 45/64] Update includes in `daw_hash_set` and `daw_cpp_feature_check`, suppress MSVC warnings in `exists` implementation --- include/daw/daw_cpp_feature_check.h | 2 +- include/daw/daw_hash_set.h | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/daw/daw_cpp_feature_check.h b/include/daw/daw_cpp_feature_check.h index 919f034e0..2d2132969 100644 --- a/include/daw/daw_cpp_feature_check.h +++ b/include/daw/daw_cpp_feature_check.h @@ -8,7 +8,7 @@ #pragma once -#include "ciso646.h" +#include "daw/ciso646.h" #if __has_include( ) #include diff --git a/include/daw/daw_hash_set.h b/include/daw/daw_hash_set.h index 210ac4af7..19d2965d0 100644 --- a/include/daw/daw_hash_set.h +++ b/include/daw/daw_hash_set.h @@ -8,9 +8,10 @@ #pragma once -#include "ciso646.h" +#include "daw/ciso646.h" +#include "daw/daw_algorithm.h" +#include "daw/daw_attributes.h" #include "daw/daw_check_exceptions.h" -#include "daw_algorithm.h" #include #include @@ -80,7 +81,14 @@ namespace daw { auto const hash = Hash{ }( key ); auto const index = find_index( hash, key ); if( index ) { +#if defined( DAW_HAS_MSVC ) +#pragma warning( push ) +#pragma warning( disable : 4244 ) +#endif return static_cast( m_indices[*index] ); +#if defined( HAS_HAS_MSVC ) +#pragma warning( pop ) +#endif } return false; } From 2b566293bd9be1593196fcd202b50b421e9ffdd9 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 11:14:33 -0400 Subject: [PATCH 46/64] Add `daw_cxmath::cmp_equal`, refactored `exists` to simplify MSVC-specific warning handling --- include/daw/daw_benchmark.h | 6 ++++-- include/daw/daw_cxmath.h | 11 +++++++++++ include/daw/daw_hash_set.h | 9 +-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/daw/daw_benchmark.h b/include/daw/daw_benchmark.h index 6cfd876c4..d38323bc9 100644 --- a/include/daw/daw_benchmark.h +++ b/include/daw/daw_benchmark.h @@ -10,6 +10,7 @@ #include "daw/ciso646.h" #include "daw/daw_arith_traits.h" +#include "daw/daw_cxmath.h" #include "daw/daw_do_not_optimize.h" #include "daw/daw_expected.h" #include "daw/daw_move.h" @@ -594,7 +595,8 @@ namespace daw { DAW_ATTRIB_NOINLINE void output_expected_error( T &&expected_result, U &&result ) { std::cerr << "Invalid result. Expecting '" << expected_result - << "' but got '" << result << "'\n" << std::flush; + << "' but got '" << result << "'\n" + << std::flush; } template< @@ -609,7 +611,7 @@ namespace daw { template DAW_ATTRIB_NOINLINE constexpr void expecting( T &&expected_result, U &&result ) { - if( not( expected_result == result ) ) { + if( not( daw::cmp_equal( expected_result, result ) ) ) { #ifdef __VERSION__ if constexpr( not daw::string_view( __VERSION__ ) .starts_with( daw::string_view( diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index a8321713c..f39d6a5c6 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -1393,4 +1393,15 @@ namespace daw::cxmath { 1 + a + static_cast( value >= powers_of_ten[a] ) ); } static_assert( count_digits( 1'000'000ULL ) == 7 ); + + template + constexpr bool cmp_equal( T t, U u ) { + if constexpr( std::is_signed_v == std::is_signed_v ) { + return t == u; + } else if constexpr( std::is_signed_v ) { + return t >= 0 and std::make_unsigned_t( t ) == u; + } else { + return u >= 0 and std::make_unsigned_t( u ) == t; + } + } } // namespace daw::cxmath diff --git a/include/daw/daw_hash_set.h b/include/daw/daw_hash_set.h index 19d2965d0..e1bbcfd08 100644 --- a/include/daw/daw_hash_set.h +++ b/include/daw/daw_hash_set.h @@ -81,14 +81,7 @@ namespace daw { auto const hash = Hash{ }( key ); auto const index = find_index( hash, key ); if( index ) { -#if defined( DAW_HAS_MSVC ) -#pragma warning( push ) -#pragma warning( disable : 4244 ) -#endif - return static_cast( m_indices[*index] ); -#if defined( HAS_HAS_MSVC ) -#pragma warning( pop ) -#endif + return m_indices[*index].has_value( ); } return false; } From 46a3929db85c5fc08e9238f09f922f87f8fb6bde Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 11:17:41 -0400 Subject: [PATCH 47/64] Fixed typo --- include/daw/daw_benchmark.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/daw/daw_benchmark.h b/include/daw/daw_benchmark.h index d38323bc9..ca2c65323 100644 --- a/include/daw/daw_benchmark.h +++ b/include/daw/daw_benchmark.h @@ -611,7 +611,7 @@ namespace daw { template DAW_ATTRIB_NOINLINE constexpr void expecting( T &&expected_result, U &&result ) { - if( not( daw::cmp_equal( expected_result, result ) ) ) { + if( not( daw::cxmath::cmp_equal( expected_result, result ) ) ) { #ifdef __VERSION__ if constexpr( not daw::string_view( __VERSION__ ) .starts_with( daw::string_view( From 18edc16164ec921ac8da81402665648e135c5155 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 11:36:50 -0400 Subject: [PATCH 48/64] - Add MSVC-specific warnings handling in `cmp_equal` for better compatibility. --- include/daw/daw_cxmath.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index f39d6a5c6..ff60b7348 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -1396,12 +1396,20 @@ namespace daw::cxmath { template constexpr bool cmp_equal( T t, U u ) { +#if defined( DAW_HAS_MSVC ) +#pragma warning( push ) +#pragma warning( disable : 4389 ) +#endif if constexpr( std::is_signed_v == std::is_signed_v ) { return t == u; } else if constexpr( std::is_signed_v ) { - return t >= 0 and std::make_unsigned_t( t ) == u; + return t >= T{ 0 } and static_cast>( t ) == u; } else { - return u >= 0 and std::make_unsigned_t( u ) == t; + return u >= U{ 0 } and t == static_cast>( u ); } + +#if defined( DAW_HAS_MSVC ) +#pragma warning( pop ) +#endif } } // namespace daw::cxmath From e197d10126a586fe04681a37c5efad890c380281 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 11:48:55 -0400 Subject: [PATCH 49/64] Replace `std::uint64_t` with `std::size_t` in `daw_hash_set` for better consistency with container APIs. --- include/daw/daw_hash_set.h | 43 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/include/daw/daw_hash_set.h b/include/daw/daw_hash_set.h index e1bbcfd08..fc4ce416c 100644 --- a/include/daw/daw_hash_set.h +++ b/include/daw/daw_hash_set.h @@ -13,6 +13,7 @@ #include "daw/daw_attributes.h" #include "daw/daw_check_exceptions.h" +#include #include #include #include @@ -23,18 +24,18 @@ namespace daw { class hash_set_t { std::vector> m_indices; - [[nodiscard]] static constexpr std::uint64_t - scale_hash( std::uint64_t hash, std::uint64_t range_size ) { + [[nodiscard]] static constexpr std::size_t + scale_hash( std::uint64_t hash, std::size_t range_size ) { constexpr std::uint64_t prime_a = 18446744073709551557ull; constexpr std::uint64_t prime_b = 18446744073709551533ull; - return ( hash * prime_a + prime_b ) % range_size; + return static_cast( hash * prime_a + prime_b ) % range_size; } - [[nodiscard]] std::optional + [[nodiscard]] std::optional find_index( std::uint64_t hash, Key const &key ) const { - std::uint64_t const scaled_hash = scale_hash( hash, m_indices.size( ) ); + std::size_t const scaled_hash = scale_hash( hash, m_indices.size( ) ); - for( std::uint64_t n = scaled_hash; n < m_indices.size( ); ++n ) { + for( std::size_t n = scaled_hash; n < m_indices.size( ); ++n ) { if( not m_indices[n] ) { return n; } @@ -42,7 +43,7 @@ namespace daw { return n; } } - for( std::uint64_t n = 0; n < scaled_hash; ++n ) { + for( std::size_t n = 0; n < scaled_hash; ++n ) { if( not m_indices[n] ) { return n; } @@ -54,11 +55,11 @@ namespace daw { } public: - hash_set_t( std::uint64_t range_size ) noexcept + hash_set_t( std::size_t range_size ) noexcept : m_indices( range_size, std::nullopt ) {} std::uint64_t insert( Key const &key ) { - auto const hash = Hash{ }( key ); + std::uint64_t const hash = Hash{ }( key ); auto const index = find_index( hash, key ); if( not index ) { DAW_THROW_OR_TERMINATE( std::out_of_range, "Hash table is full" ); @@ -67,8 +68,8 @@ namespace daw { return *index; } - std::optional erase( Key const &key ) { - auto const hash = Hash{ }( key ); + std::optional erase( Key const &key ) { + std::uint64_t const hash = Hash{ }( key ); auto const index = find_index( hash, key ); if( not index ) { return { }; @@ -78,7 +79,7 @@ namespace daw { } [[nodiscard]] bool exists( Key const &key ) const noexcept { - auto const hash = Hash{ }( key ); + std::uint64_t const hash = Hash{ }( key ); auto const index = find_index( hash, key ); if( index ) { return m_indices[*index].has_value( ); @@ -86,20 +87,20 @@ namespace daw { return false; } - [[nodiscard]] bool count( Key const &key ) const noexcept { - return exists( key ) ? 1 : 0; + [[nodiscard]] std::size_t count( Key const &key ) const noexcept { + return exists( key ) ? 1U : 0U; } - [[nodiscard]] std::uint64_t capacity( ) const noexcept { + [[nodiscard]] std::size_t capacity( ) const noexcept { return m_indices.size( ); } - [[nodiscard]] std::uint64_t size( ) const noexcept { - return daw::algorithm::accumulate( - std::begin( m_indices ), std::end( m_indices ), 0ULL, - []( auto const &opt ) { - return static_cast( opt ) ? 1ULL : 0ULL; - } ); + [[nodiscard]] std::size_t size( ) const noexcept { + return daw::algorithm::accumulate( std::begin( m_indices ), + std::end( m_indices ), std::size_t{ }, + []( auto const &opt ) { + return opt.has_value( ) ? 1U : 0U; + } ); } }; } // namespace daw From b188881387be0b915701458591fdd153b45b3bc7 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 11:52:51 -0400 Subject: [PATCH 50/64] Replace `std::uint64_t` with `std::size_t` in tests for consistency with container APIs. --- tests/daw_hash_set_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/daw_hash_set_test.cpp b/tests/daw_hash_set_test.cpp index 557498527..9916dc925 100644 --- a/tests/daw_hash_set_test.cpp +++ b/tests/daw_hash_set_test.cpp @@ -13,17 +13,17 @@ #include void test_001( ) { - std::uint64_t count = 1024ULL; + std::size_t count = 1024ULL; daw::hash_set_t adapt( count ); - for( std::uint64_t n = 0; n < count; ++n ) { + for( std::size_t n = 0; n < count; ++n ) { adapt.insert( n ); } } void test_003( ) { - std::uint64_t count = 1024ULL; + std::size_t count = 1024ULL; daw::hash_set_t adapt( count ); - for( std::uint64_t n = 0; n < count; ++n ) { + for( std::size_t n = 0; n < count; ++n ) { adapt.insert( n ); } for( std::uint64_t n = 0; n < count; ++n ) { From e7e45bd0ec2f93c413267f5426dc83d72aca9284 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 11:55:36 -0400 Subject: [PATCH 51/64] Refactor tests: replace explicit `std::vector` declarations with `auto` and update loop variable type for consistency. --- tests/daw_iterator_circular_iterator_test.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/daw_iterator_circular_iterator_test.cpp b/tests/daw_iterator_circular_iterator_test.cpp index cbd3a986f..639a06c8b 100644 --- a/tests/daw_iterator_circular_iterator_test.cpp +++ b/tests/daw_iterator_circular_iterator_test.cpp @@ -42,7 +42,7 @@ void daw_circular_iterator_003( ) { std::vector numbers = { 1, 2, 3, 4, 5, 6, 7 }; auto first = daw::make_circular_iterator( numbers ); - for( intmax_t n = 0; n < 14; ++n ) { + for( int n = 0; n < 14; ++n ) { first += n * n; std::cout << *first << ' '; } @@ -50,7 +50,7 @@ void daw_circular_iterator_003( ) { } void daw_circular_iterator_004( ) { - std::vector a; + auto a = std::vector{}; auto it = daw::make_circular_iterator( a ); constexpr bool is_move_assignable = std::is_move_assignable::value; @@ -58,7 +58,7 @@ void daw_circular_iterator_004( ) { } void daw_circular_iterator_005( ) { - std::vector a; + auto a = std::vector{}; auto it = daw::make_circular_iterator( a ); constexpr bool is_move_constructible = std::is_move_constructible::value; @@ -66,13 +66,13 @@ void daw_circular_iterator_005( ) { } void daw_circular_iterator_006( ) { - std::vector a; + auto a = std::vector{}; auto it = daw::make_circular_iterator( a ); static_assert( std::is_nothrow_move_assignable_v ); } void daw_circular_iterator_007( ) { - std::vector a; + auto a = std::vector{}; auto it = daw::make_circular_iterator( a ); static_assert( std::is_nothrow_move_constructible_v ); } From 5fdc7bce596fec77b19ae94409c9fe945e6a4442 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 12:35:35 -0400 Subject: [PATCH 52/64] Expand `daw_cxmath` with additional comparison utilities (`cmp_not_equal`, `cmp_less`, `cmp_greater`, `cmp_less_equal`, `cmp_greater_equal`) and improve `cmp_equal` logic for handling integral types. --- include/daw/daw_cxmath.h | 42 ++++++++++++++++++++++++++++++++++++++- include/daw/daw_natural.h | 16 ++++++++++----- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/include/daw/daw_cxmath.h b/include/daw/daw_cxmath.h index ff60b7348..bb284cf44 100644 --- a/include/daw/daw_cxmath.h +++ b/include/daw/daw_cxmath.h @@ -1400,7 +1400,8 @@ namespace daw::cxmath { #pragma warning( push ) #pragma warning( disable : 4389 ) #endif - if constexpr( std::is_signed_v == std::is_signed_v ) { + if constexpr( not( std::is_integral_v and std::is_integral_v ) or + std::is_signed_v == std::is_signed_v ) { return t == u; } else if constexpr( std::is_signed_v ) { return t >= T{ 0 } and static_cast>( t ) == u; @@ -1412,4 +1413,43 @@ namespace daw::cxmath { #pragma warning( pop ) #endif } + + template + constexpr bool cmp_not_equal( T t, U u ) { + return not cmp_equal( t, u ); + } + + template + constexpr bool cmp_less( T t, U u ) { +#if defined( DAW_HAS_MSVC ) +#pragma warning( push ) +#pragma warning( disable : 4389 ) +#endif + if constexpr( not( std::is_integral_v and std::is_integral_v ) or + std::is_signed_v == std::is_signed_v ) { + return t < u; + } else if constexpr( std::is_signed_v ) { + return t < 0 or static_cast>( t ) < u; + } else { + return u >= 0 and t < static_cast>( u ); + } +#if defined( DAW_HAS_MSVC ) +#pragma warning( pop ) +#endif + } + + template + constexpr bool cmp_greater( T t, U u ) { + return cmp_less( u, t ); + } + + template + constexpr bool cmp_less_equal( T t, U u ) { + return not cmp_less( u, t ); + } + + template + constexpr bool cmp_greater_equal( T t, U u ) { + return not cmp_less( t, u ); + } } // namespace daw::cxmath diff --git a/include/daw/daw_natural.h b/include/daw/daw_natural.h index be9d3b3ed..6d0a8039d 100644 --- a/include/daw/daw_natural.h +++ b/include/daw/daw_natural.h @@ -8,9 +8,10 @@ #pragma once -#include "ciso646.h" -#include "daw_exception.h" -#include "daw_traits.h" +#include "daw/ciso646.h" +#include "daw/daw_cxmath.h" +#include "daw/daw_exception.h" +#include "daw/daw_traits.h" namespace daw { struct invalid_natural_number : public daw::exception::arithmetic_exception { @@ -20,7 +21,7 @@ namespace daw { // An operation that causes overflow is undefined template> = nullptr> struct natural_t { - using value_type = std::decay_t; + using value_type = daw::remove_cvref_t; private: T m_value; @@ -48,6 +49,10 @@ namespace daw { return *this; } + constexpr value_type value( ) const noexcept { + return m_value; + } + constexpr operator T( ) const noexcept { return m_value; } @@ -214,7 +219,8 @@ namespace daw { } namespace literals { - constexpr size_t operator""_N( unsigned long long val ) noexcept { + constexpr unsigned long long + operator""_N( unsigned long long val ) noexcept { return daw::natural_t{ val }; } } // namespace literals From d787bc06bec5c6d08bb5f41a549333edc096dd5d Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 12:42:52 -0400 Subject: [PATCH 53/64] Refactor tests: removed potential narrowing conversion --- tests/daw_random_test.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/daw_random_test.cpp b/tests/daw_random_test.cpp index 05d378513..8835e7c38 100644 --- a/tests/daw_random_test.cpp +++ b/tests/daw_random_test.cpp @@ -80,9 +80,9 @@ static_assert( cxrand_test_001( ) ); void cxrand_test_002( ) { auto rng = daw::static_random( ); - for( size_t n = 0; n < 50; ++n ) { - size_t num = rng( ); - num = ( ( num >> 60U ) | ( num & 0xFF ) ) % 100U; + for( std::size_t n = 0U; n < 50U; ++n ) { + auto num = rng( ); + num = ( ( num >> 60U ) | ( num & 0xFFU ) ) % 100U; std::cout << " " << num; } std::cout << '\n'; @@ -155,7 +155,7 @@ void show_dist( std::vector const &v, typename daw::traits::identity::type minimum, typename daw::traits::identity::type maximum ) { auto bins = std::vector{ }; - auto const sz = maximum - minimum + 1; + auto const sz = static_cast( maximum - minimum + 1 ); bins.resize( sz ); for( auto val : v ) { ++bins[val - minimum]; @@ -172,11 +172,11 @@ void daw_make_random_02( ) { using uint_t = std::uint64_t; auto rnd = daw::RandomInteger( ); auto r = std::vector( ); - constexpr auto minimum = 0; - constexpr auto maximum = 128; + constexpr uint_t minimum = 0U; + constexpr uint_t maximum = 128U; constexpr auto sz = maximum - minimum + 1; (void)sz; - r.resize( 1'000'000ULL ); + r.resize( std::size_t{ 1'000'000ULL } ); for( auto &v : r ) { v = rnd( maximum, minimum ); } From eb13fe0278d673903bb2de525e0ccd57ca380d01 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 12:48:15 -0400 Subject: [PATCH 54/64] Refactor tests: cast RNG result to `std::uint64_t` to prevent potential narrowing conversion --- tests/daw_random_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/daw_random_test.cpp b/tests/daw_random_test.cpp index 8835e7c38..9d0df9a14 100644 --- a/tests/daw_random_test.cpp +++ b/tests/daw_random_test.cpp @@ -81,7 +81,7 @@ static_assert( cxrand_test_001( ) ); void cxrand_test_002( ) { auto rng = daw::static_random( ); for( std::size_t n = 0U; n < 50U; ++n ) { - auto num = rng( ); + auto num = static_cast( rng( ) ); num = ( ( num >> 60U ) | ( num & 0xFFU ) ) % 100U; std::cout << " " << num; } From c54433d112ae7f8caacf54b0b1e99c054b8f9e2d Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 13:07:07 -0400 Subject: [PATCH 55/64] Refactor tests: add exception handling in main functions on some failng tests --- tests/daw_benchmark_test.cpp | 14 +++++++++++- tests/daw_cxmath_test.cpp | 17 +++++++++++--- ...w_iterator_sorted_insert_iterator_test.cpp | 22 ++++++++++++++----- tests/daw_random_test.cpp | 2 +- 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/tests/daw_benchmark_test.cpp b/tests/daw_benchmark_test.cpp index 138e52a3d..71fae4f0a 100644 --- a/tests/daw_benchmark_test.cpp +++ b/tests/daw_benchmark_test.cpp @@ -48,9 +48,21 @@ void daw_bench_n_test_test_001( ) { daw::expecting( 3025, *res ); } -int main( ) { +int main( ) +#if defined( DAW_USE_EXCEPTIONS ) + try +#endif +{ daw_benchmark_test_001( ); daw_benchmark_test_002( ); daw_bench_test_test_001( ); daw_bench_n_test_test_001( ); } +#if defined( DAW_USE_EXCEPTIONS ) +catch( std::exception const &ex ) { + std::cerr << "Uncaught Exception: " << ex.what( ) << '\n' << std::flush; +} catch( ... ) { + std::cerr << "Unknown uncaught exception:\n" << std::flush; + throw; +} +#endif \ No newline at end of file diff --git a/tests/daw_cxmath_test.cpp b/tests/daw_cxmath_test.cpp index 19e56ae03..e6f3515e5 100644 --- a/tests/daw_cxmath_test.cpp +++ b/tests/daw_cxmath_test.cpp @@ -132,7 +132,11 @@ void out_sqrt( float f ) { << E2 << ") diff: " << diff << '\n'; } -int main( ) { +int main( ) +#if defined( DAW_USE_EXCEPTIONS ) + try +#endif +{ sqrt_tests( ); std::cout << "pow10( -1 ) -> " << daw::cxmath::dpow10( -1 ) << '\n'; std::cout << "pow10( -2 ) -> " << daw::cxmath::dpow10( -2 ) << '\n'; @@ -191,8 +195,7 @@ int main( ) { return sum; }, daw::make_random_data>( - 1'000, - std::numeric_limits::min_exponent10, + 1'000, std::numeric_limits::min_exponent10, std::numeric_limits::max_exponent10 ) ); daw::bench_n_test( @@ -287,3 +290,11 @@ int main( ) { #endif return 0; } +#if defined( DAW_USE_EXCEPTIONS ) +catch( std::exception const &ex ) { + std::cerr << "Uncaught Exception: " << ex.what( ) << '\n' << std::flush; +} catch( ... ) { + std::cerr << "Unknown uncaught exception:\n" << std::flush; + throw; +} +#endif \ No newline at end of file diff --git a/tests/daw_iterator_sorted_insert_iterator_test.cpp b/tests/daw_iterator_sorted_insert_iterator_test.cpp index ef72fd0b4..4eec27e9a 100644 --- a/tests/daw_iterator_sorted_insert_iterator_test.cpp +++ b/tests/daw_iterator_sorted_insert_iterator_test.cpp @@ -62,18 +62,20 @@ void test_005( std::vector const &data ) { template void test_006( std::vector const &data ) { std::list new_data{ }; - std::copy( - begin( data ), end( data ), std::inserter( new_data, end( new_data ) ) ); + std::copy( begin( data ), end( data ), + std::inserter( new_data, end( new_data ) ) ); new_data.sort( ); daw::do_not_optimize( new_data ); } -int main( ) { +int main( ) +#if defined( DAW_USE_EXCEPTIONS ) + try +#endif +{ for( size_t sz = 10ULL; sz < 1'000ULL; sz *= 10 ) { std::vector test_data( sz, 0ULL ); - daw::random_fill( begin( test_data ), - end( test_data ), - 0ULL, + daw::random_fill( begin( test_data ), end( test_data ), 0ULL, std::numeric_limits::max( ) ); std::cout << "Data size: " << sz << '\n'; daw::bench_n_test<100>( @@ -117,3 +119,11 @@ int main( ) { std::cout << "####################\n"; } } +#if defined( DAW_USE_EXCEPTIONS ) +catch( std::exception const &ex ) { + std::cerr << "Uncaught Exception: " << ex.what( ) << '\n' << std::flush; +} catch( ... ) { + std::cerr << "Unknown uncaught exception:\n" << std::flush; + throw; +} +#endif \ No newline at end of file diff --git a/tests/daw_random_test.cpp b/tests/daw_random_test.cpp index 9d0df9a14..2a5ee18fd 100644 --- a/tests/daw_random_test.cpp +++ b/tests/daw_random_test.cpp @@ -158,7 +158,7 @@ void show_dist( std::vector const &v, auto const sz = static_cast( maximum - minimum + 1 ); bins.resize( sz ); for( auto val : v ) { - ++bins[val - minimum]; + ++bins[static_cast( val - minimum )]; } for( std::size_t n = 0; n < bins.size( ); ++n ) { std::cout << ( static_cast( n ) + minimum ) << ": " << bins[n] From f498dc5c23d74e3efe3f622b4d8472a014f526df Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 13:13:43 -0400 Subject: [PATCH 56/64] Refactor tests: add `return 1` for exception handling and replace `std::uint64_t` with `std::size_t` in `daw_uninitialized_storage_test` for consistency. --- tests/daw_benchmark_test.cpp | 1 + tests/daw_cxmath_test.cpp | 1 + tests/daw_iterator_sorted_insert_iterator_test.cpp | 1 + tests/daw_string_view2_test.cpp | 2 +- tests/daw_uninitialized_storage_test.cpp | 4 ++-- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/daw_benchmark_test.cpp b/tests/daw_benchmark_test.cpp index 71fae4f0a..0918ff950 100644 --- a/tests/daw_benchmark_test.cpp +++ b/tests/daw_benchmark_test.cpp @@ -61,6 +61,7 @@ int main( ) #if defined( DAW_USE_EXCEPTIONS ) catch( std::exception const &ex ) { std::cerr << "Uncaught Exception: " << ex.what( ) << '\n' << std::flush; + return 1; } catch( ... ) { std::cerr << "Unknown uncaught exception:\n" << std::flush; throw; diff --git a/tests/daw_cxmath_test.cpp b/tests/daw_cxmath_test.cpp index e6f3515e5..aa6115d46 100644 --- a/tests/daw_cxmath_test.cpp +++ b/tests/daw_cxmath_test.cpp @@ -293,6 +293,7 @@ int main( ) #if defined( DAW_USE_EXCEPTIONS ) catch( std::exception const &ex ) { std::cerr << "Uncaught Exception: " << ex.what( ) << '\n' << std::flush; + return 1; } catch( ... ) { std::cerr << "Unknown uncaught exception:\n" << std::flush; throw; diff --git a/tests/daw_iterator_sorted_insert_iterator_test.cpp b/tests/daw_iterator_sorted_insert_iterator_test.cpp index 4eec27e9a..d5ff16f6e 100644 --- a/tests/daw_iterator_sorted_insert_iterator_test.cpp +++ b/tests/daw_iterator_sorted_insert_iterator_test.cpp @@ -122,6 +122,7 @@ int main( ) #if defined( DAW_USE_EXCEPTIONS ) catch( std::exception const &ex ) { std::cerr << "Uncaught Exception: " << ex.what( ) << '\n' << std::flush; + return 1; } catch( ... ) { std::cerr << "Unknown uncaught exception:\n" << std::flush; throw; diff --git a/tests/daw_string_view2_test.cpp b/tests/daw_string_view2_test.cpp index a63906136..773e9ca4a 100644 --- a/tests/daw_string_view2_test.cpp +++ b/tests/daw_string_view2_test.cpp @@ -1857,7 +1857,7 @@ catch( std::exception const &ex ) { << '\n' << ex.what( ) << '\n' << std::flush; - exit( 1 ); + return 1; } catch( ... ) { std::cerr << "An unknown exception was thrown\n" << std::flush; throw; diff --git a/tests/daw_uninitialized_storage_test.cpp b/tests/daw_uninitialized_storage_test.cpp index 44981eef2..0508fe263 100644 --- a/tests/daw_uninitialized_storage_test.cpp +++ b/tests/daw_uninitialized_storage_test.cpp @@ -16,11 +16,11 @@ #include void test_001( ) { - daw::uninitialized_storage> str; + daw::uninitialized_storage> str; str.construct( ); auto result = str->size( ); str.destruct( ); - str.construct( 100ULL ); + str.construct( std::size_t{ 100U } ); result -= ( *str )[0]; daw::expecting( result == 0ULL ); } From 8ecc67953e90920134b3e178c3704dcaccc27477 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 13:42:15 -0400 Subject: [PATCH 57/64] Refactor `daw_traits`: improve type traits utilities with consistent naming, `std::bool_constant`, simplified logic, and alignment to `std::size_t`. --- include/daw/daw_parser_helper.h | 5 +-- include/daw/daw_traits.h | 60 +++++++++++++-------------------- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/include/daw/daw_parser_helper.h b/include/daw/daw_parser_helper.h index 5a4c049c5..812b88091 100644 --- a/include/daw/daw_parser_helper.h +++ b/include/daw/daw_parser_helper.h @@ -289,8 +289,9 @@ namespace daw::parser { template [[nodiscard]] constexpr bool in_range( T value, Min minimum_value, Max maximum_value ) noexcept { - using val_t = typename daw::traits::max_sizeof::type; - return static_cast( minimum_value ) <= static_cast( value ) && + using val_t = daw::traits::max_sizeof_t; + return static_cast( minimum_value ) <= + static_cast( value ) and static_cast( value ) <= static_cast( maximum_value ); } diff --git a/include/daw/daw_traits.h b/include/daw/daw_traits.h index 22f3878d3..1c8484cea 100644 --- a/include/daw/daw_traits.h +++ b/include/daw/daw_traits.h @@ -47,24 +47,29 @@ namespace daw::traits { template struct max_sizeof { using type = First; - static const size_t value = sizeof( type ); + static const std::size_t value = sizeof( type ); + }; + + template + struct max_sizeof { + using type = std::conditional_t<( sizeof( First ) >= sizeof( Second ) ), + First, Second>; + static constexpr std::size_t value = sizeof( type ); }; // the biggest of everything in Args and First - template - struct max_sizeof { - using next = typename max_sizeof::type; - using type = - typename daw::conditional_t<( sizeof( First ) >= sizeof( next ) ), First, - next>; - static const size_t value = sizeof( type ); + template + struct max_sizeof { + using next = typename max_sizeof::type; + using type = typename max_sizeof::type; + static constexpr std::size_t value = sizeof( type ); }; template using max_sizeof_t = typename max_sizeof::type; template - constexpr size_t max_sizeof_v = max_sizeof::value; + inline constexpr std::size_t max_sizeof_v = max_sizeof::value; ////////////////////////////////////////////////////////////////////////// /// Summary: Returns true if all values passed are true @@ -89,19 +94,11 @@ namespace daw::traits { ////////////////////////////////////////////////////////////////////////// /// Summary: Are all template parameters the same type /// - template - struct are_same_types : std::false_type {}; - - template - struct are_same_types : std::is_same {}; - - template - struct are_same_types - : std::integral_constant or - are_same_types::value> {}; + template + inline constexpr bool are_same_types_v = ( std::is_same_v and ... ); - template - inline constexpr bool are_same_types_v = are_same_types::value; + template + using are_same_types = std::bool_constant>; ////////////////////////////////////////////////////////////////////////// /// Summary: A sequence of bool values @@ -140,23 +137,12 @@ namespace daw::traits { template using enable_if_all = std::enable_if, R>; - template - struct can_convert_from : std::false_type {}; - - template - struct can_convert_from : std::is_convertible {}; - - template - struct can_convert_from - : daw::disjunction, - can_convert_from> {}; - template - using can_convert_from_t = typename can_convert_from::type; + inline constexpr bool can_convert_from_v = + true or ( std::is_convertible_v or ... ); template - inline constexpr bool can_convert_from_v = - can_convert_from::value; + using can_convert_from = std::bool_constant>; namespace traits_details { template @@ -331,7 +317,7 @@ namespace daw::traits { has_append_memberfn_v and is_container_like_v and has_integer_subscript_v; - template + template inline constexpr bool is_value_size_equal_v = sizeof( *std::cbegin( std::declval( ) ) ) == ExpectedSize; @@ -554,7 +540,7 @@ namespace daw::traits { struct func_traits : public func_traits {}; - template + template using func_arg_t = typename func_traits::template argument::type; template From ea389ba465d539ef61189f540e6efb75fb79ff06 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 13:54:35 -0400 Subject: [PATCH 58/64] Refactor tests: replace `max_sizeof` with `max_sizeof_v` and update largest item check to use `std::uint64_t`. --- tests/daw_traits_test.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/daw_traits_test.cpp b/tests/daw_traits_test.cpp index d37c50625..9c3579cc5 100644 --- a/tests/daw_traits_test.cpp +++ b/tests/daw_traits_test.cpp @@ -78,10 +78,11 @@ namespace daw_traits_is_regular { } // namespace daw_traits_is_regular namespace daw_traits_max_sizeof { - static_assert( daw::traits::max_sizeof::value == - sizeof( size_t ), - "1. Max sizeof did not report the size of the largest item" ); + static_assert( + daw::traits::max_sizeof_v == + sizeof( std::uint64_t ), + "1. Max sizeof did not report the size of the largest item" ); } namespace daw_traits_are_true { From 0dcd2d3e901ead6909cc23cb2de958183d08ab93 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 14:13:37 -0400 Subject: [PATCH 59/64] Standardize `std::size_t` usage and improve type consistency in static hash table operations. --- include/daw/daw_hash_set.h | 3 +- include/daw/static_hash_table.h | 56 ++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/include/daw/daw_hash_set.h b/include/daw/daw_hash_set.h index fc4ce416c..9aa39cf27 100644 --- a/include/daw/daw_hash_set.h +++ b/include/daw/daw_hash_set.h @@ -28,7 +28,8 @@ namespace daw { scale_hash( std::uint64_t hash, std::size_t range_size ) { constexpr std::uint64_t prime_a = 18446744073709551557ull; constexpr std::uint64_t prime_b = 18446744073709551533ull; - return static_cast( hash * prime_a + prime_b ) % range_size; + return static_cast( ( hash * prime_a + prime_b ) % + range_size ); } [[nodiscard]] std::optional diff --git a/include/daw/static_hash_table.h b/include/daw/static_hash_table.h index f79661e7b..5b95b7761 100644 --- a/include/daw/static_hash_table.h +++ b/include/daw/static_hash_table.h @@ -12,27 +12,29 @@ #include "daw/daw_algorithm.h" #include "daw/daw_arith_traits.h" #include "daw/daw_fnv1a_hash.h" -#include "daw/daw_move.h" +#include "daw/daw_remove_cvref.h" #include namespace daw { - template + template struct static_hash_t { - using value_type = std::decay_t; + using value_type = daw::remove_cvref_t; using reference = value_type &; using const_reference = value_type const &; - enum class hash_sentinals : size_t { empty, Size }; + enum class hash_sentinals : std::size_t { empty, Size }; struct hash_item { - size_t hash_value; - value_type value; - constexpr hash_item( ) - : hash_value{ } - , value{ } {} - - constexpr hash_item( size_t h, value_type v ) - : hash_value{ std::move( h ) } + std::uint64_t hash_value = 0; + value_type value = value_type{ }; + hash_item( ) = default; + + constexpr hash_item( std::uint64_t h, value_type const &v ) + : hash_value{ h } + , value{ v } {} + + constexpr hash_item( std::uint64_t h, value_type &&v ) + : hash_value{ h } , value{ std::move( v ) } {} }; // hash_item @@ -42,30 +44,33 @@ namespace daw { private: values_type m_values; - [[nodiscard]] static constexpr size_t scale_hash( size_t hash_value ) { - const size_t prime_a = 18446744073709551557u; - const size_t prime_b = 18446744073709551533u; - return ( hash_value * prime_a + prime_b ) % Capacity; + [[nodiscard]] static constexpr std::size_t + scale_hash( std::uint64_t hash_value ) { + constexpr auto prime_a = 18446744073709551557ULL; + constexpr auto prime_b = 18446744073709551533ULL; + return static_cast( ( hash_value * prime_a + prime_b ) % + Capacity ); } template - [[nodiscard]] static constexpr size_t hash_fn( K const &key ) { + [[nodiscard]] static constexpr std::size_t hash_fn( K const &key ) { return ( daw::fnv1a_hash( key ) % ( max_value - static_cast( hash_sentinals::Size ) ) ) + static_cast( hash_sentinals::Size ); } - [[nodiscard]] static constexpr size_t hash_fn( char const *const key ) { + [[nodiscard]] static constexpr std::size_t + hash_fn( char const *const key ) { return ( daw::fnv1a_hash( key ) % ( max_value - static_cast( hash_sentinals::Size ) ) ) + static_cast( hash_sentinals::Size ); } - [[nodiscard]] constexpr size_t find_impl( size_t const hash ) const { + [[nodiscard]] constexpr std::size_t find_impl( std::uint64_t hash ) const { auto const scaled_hash = scale_hash( hash ); - for( size_t n = scaled_hash; n < Capacity; ++n ) { + for( std::size_t n = scaled_hash; n < Capacity; ++n ) { if( m_values[n].hash_value == static_cast( hash_sentinals::empty ) ) { return n; @@ -73,7 +78,7 @@ namespace daw { return n; } } - for( size_t n = 0; n < scaled_hash; ++n ) { + for( std::size_t n = 0; n < scaled_hash; ++n ) { if( m_values[n].hash_value == static_cast( hash_sentinals::empty ) ) { return n; @@ -84,14 +89,15 @@ namespace daw { return Capacity; } - [[nodiscard]] constexpr size_t find_next_empty( size_t const pos ) const { - for( size_t n = pos; n < Capacity; ++n ) { + [[nodiscard]] constexpr std::size_t + find_next_empty( std::size_t const pos ) const { + for( std::size_t n = pos; n < Capacity; ++n ) { if( m_values[n].hash_value == static_cast( hash_sentinals::empty ) ) { return n; } } - for( size_t n = 0; n < pos; ++n ) { + for( std::size_t n = 0; n < pos; ++n ) { if( m_values[n].hash_value == static_cast( hash_sentinals::empty ) ) { return n; @@ -128,7 +134,7 @@ namespace daw { } template - [[nodiscard]] constexpr size_t find( K const &key ) const { + [[nodiscard]] constexpr std::size_t find( K const &key ) const { auto const hash = hash_fn( key ); return find_impl( hash ); } From 8dfad599652cc0e29e3b0b4846c9ad421474638e Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 14:30:57 -0400 Subject: [PATCH 60/64] Ensured NDEBUG is not set for string_view2 test --- tests/daw_string_view2_test.cpp | 50 ++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/tests/daw_string_view2_test.cpp b/tests/daw_string_view2_test.cpp index 773e9ca4a..1878321f0 100644 --- a/tests/daw_string_view2_test.cpp +++ b/tests/daw_string_view2_test.cpp @@ -6,6 +6,14 @@ // Official repository: https://github.com/beached/string_view // +#ifdef NDEBUG +#undef NDEBUG +#endif + +#ifndef DEBUG +#define DEBUG 1 +#endif + #include #include #include @@ -47,7 +55,7 @@ static_assert( std::is_trivially_copyable_v ); std::cerr << "Invalid result. Expecting '" #Lhs << " == " #Rhs << "'\n" \ << "File: " << __FILE__ << "\nLine: " << __LINE__ \ << std::endl; \ - std::abort( ); \ + std::terminate( ); \ } \ while( false ) #endif @@ -71,7 +79,7 @@ static_assert( std::is_trivially_copyable_v ); std::cerr << "Invalid result. Expecting '" #Bool << "' to be true\n" \ << "Message: " #Message << "File: " << __FILE__ \ << "\nLine: " << __LINE__ << std::endl; \ - std::abort( ); \ + std::terminate( ); \ } \ while( false ) #endif @@ -107,7 +115,7 @@ namespace daw { throw std::runtime_error( "unknown http request method" ); #else std::cerr << "Unknown http request method\n"; - std::abort( ); + std::terminate( ); #endif } @@ -595,11 +603,16 @@ namespace daw { bool good = false; try { (void)view.at( 11 ); - } catch( std::out_of_range const & ) { good = true; } catch( ... ) { + } catch( std::out_of_range const & ) { + good = true; + } catch( std::exception const &ex ) { + std::cerr << "Unexpected exception: " << ex.what( ) << '\n' << std::flush; + } catch( ... ) { + std::cerr << "Unexpected exception of unknown type\n" << std::flush; } if( not good ) { - puts( "Expected out of range exception" ); - std::abort( ); + std::cerr << "Expected out_of_range_exception\n" << std::flush; + std::terminate( ); } #endif } @@ -706,16 +719,22 @@ namespace daw { puts( "Throws std::out_of_range if pos >= view.size()" ); { - char result[12]; + char result[12]{}; bool good = false; try { view.copy( result, 12, 12 ); - } catch( std::out_of_range const & ) { good = true; } catch( ... ) { + } catch( std::out_of_range const & ) { + good = true; + } catch( std::exception const &ex ) { + std::cerr << "Unexpected exception: " << ex.what( ) << '\n' + << std::flush; + } catch( ... ) { + std::cerr << "Unexpected exception of unknown type\n" << std::flush; } if( not good ) { - puts( "Expected out_of_range_exception" ); - std::abort( ); + std::cerr << "Expected out_of_range_exception\n" << std::flush; + std::terminate( ); } } @@ -795,11 +814,16 @@ namespace daw { bool good = false; try { (void)view.substr( 15 ); - } catch( std::out_of_range const & ) { good = true; } catch( ... ) { + } catch( std::out_of_range const & ) { + good = true; + } catch( std::exception const &ex ) { + std::cerr << "Unexpected exception: " << ex.what( ) << '\n' << std::flush; + } catch( ... ) { + std::cerr << "Unexpected exception of unknown type\n" << std::flush; } if( not good ) { - puts( "Expected out_of_range_exception" ); - std::abort( ); + std::cerr << "Expected out_of_range_exception\n" << std::flush; + std::terminate( ); } #endif } From de0dc6d8214ab69f0a6c6bb03dfaccae5785f9d1 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 14:48:05 -0400 Subject: [PATCH 61/64] - Addressed potential compiler warnings and compatibility issues for MSVC by adding specific `#pragma` directives and warning suppression. - Applied consistent formatting across CMake files for clarity and maintainability. --- include/daw/daw_string_view.h | 8 + tests/CMakeLists.txt | 474 ++++++++++++------------ tests/cmake/test_compiler_options.cmake | 469 +++++++++++------------ 3 files changed, 480 insertions(+), 471 deletions(-) diff --git a/include/daw/daw_string_view.h b/include/daw/daw_string_view.h index b78110e75..ebcc6428b 100644 --- a/include/daw/daw_string_view.h +++ b/include/daw/daw_string_view.h @@ -1913,6 +1913,7 @@ namespace daw { [[nodiscard]] constexpr size_type find( CharT c, size_type pos = 0 ) const { + assert( pos <= size( ) ); auto first = data( ) + pos; auto const sz = static_cast( data_end( ) - first ); @@ -1938,6 +1939,10 @@ namespace daw { reinterpret_cast( r ) - first ); } } +#endif +#if defined( DAW_HAS_MSVC ) +#pragma warning( push ) +#pragma warning( disable :4702 ) #endif for( std::size_t n = pos; n < sz; ++n ) { if( first[n] == c ) { @@ -1945,6 +1950,9 @@ namespace daw { } } return npos; +#if defined( DAW_HAS_MSVC ) +#pragma warning( pop ) +#endif } [[nodiscard]] DAW_ATTRIB_FLATTEN constexpr size_type diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 35408eedf..91c764301 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,250 +5,250 @@ # #Official repository : https: // github.com/beached/header_libraries # -cmake_policy( SET CMP0065 NEW ) - -set( CMAKE_CXX_STANDARD_REQUIRED ON ) -set( CMAKE_CXX_EXTENSIONS OFF ) - -if( CMAKE_BUILD_TYPE EQUAL "Debug" ) - add_compile_definitions( DEBUG=1 ) -endif() - -set( TEST_SOURCES - InputIterator_test.cpp - cpp_17_test.cpp - daw_algorithm_test.cpp - daw_arith_traits_test.cpp - daw_array_compare_test.cpp - daw_array_test.cpp - daw_ascii_test.cpp - daw_assume_test.cpp - daw_attributes_test.cpp - daw_benchmark_test.cpp - daw_bounded_vector_test.cpp - daw_constant_test.cpp - daw_container_algorithm_test.cpp - daw_cx_offset_of_test.cpp - daw_cxmath_test.cpp - daw_endian_test.cpp - daw_exception_test.cpp - daw_expected_test.cpp - daw_fnv1a_hash_test.cpp - daw_function_ref_test.cpp - daw_function_table_test.cpp - daw_function_test.cpp - daw_function_view_test.cpp - daw_fwd_pack_apply_test.cpp - daw_generic_hash_test.cpp - daw_graph_algorithm_test.cpp - daw_graph_test.cpp - daw_hash_set_test.cpp - daw_is_any_of_test.cpp - daw_iterator_argument_iterator_test.cpp - daw_iterator_back_inserter_test.cpp - daw_iterator_checked_iterator_proxy_test.cpp - daw_iterator_chunk_iterator_test.cpp - daw_iterator_circular_iterator_test.cpp - daw_iterator_counting_iterators_test.cpp - daw_iterator_end_inserter_test.cpp - daw_iterator_find_iterator_test.cpp - daw_iterator_indexed_iterator_test.cpp - daw_iterator_inserter_test.cpp - daw_iterator_integer_iterator_test.cpp - daw_iterator_iota_iterator_test.cpp - daw_iterator_output_stream_iterator_test.cpp - daw_iterator_random_iterator_test.cpp - daw_iterator_repeat_n_char_iterator_test.cpp - daw_iterator_reverse_iterator_test.cpp - daw_iterator_sorted_insert_iterator_test.cpp - daw_iterator_zipiter_test.cpp - daw_keep_n_test.cpp - daw_lift_test.cpp - daw_logic_test.cpp - daw_math_test.cpp - daw_memory_mapped_file_test.cpp - daw_metro_hash_test.cpp - daw_natural_test.cpp - daw_not_null_test.cpp - daw_nth_pack_element_test.cpp - daw_optional_test.cpp - daw_ordered_map_test.cpp - daw_overload_test.cpp - daw_parse_args_test.cpp - daw_parse_to_test.cpp - daw_parser_helper_sv_test.cpp - daw_poly_var_test.cpp - daw_prop_const_ptr_test.cpp - daw_random_test.cpp - daw_read_file_test.cpp - daw_read_only_test.cpp - daw_ref_counted_pointer_test.cpp - daw_ring_adaptor_test.cpp - daw_scope_guard_test.cpp - daw_simple_array_test.cpp - daw_sip_hash_test.cpp - daw_size_literals_test.cpp - daw_span_test.cpp - daw_stack_function_test.cpp - daw_string_concat_test.cpp - daw_string_view2_test.cpp - daw_take_test.cpp - daw_traits_test.cpp - daw_tuple_helper_test.cpp - daw_tuple_test.cpp - daw_uint_buffer_test.cpp - daw_uninitialized_storage_test.cpp - daw_union_pair_test.cpp - daw_unique_array_test.cpp - daw_unique_ptr_test.cpp - daw_utility_test.cpp - daw_validated_test.cpp - daw_value_ptr_test.cpp - daw_variant_cast_test.cpp - daw_view_test.cpp - daw_virtual_base_test.cpp - daw_visit_test.cpp - daw_zipcontainer_test.cpp - sbo_test.cpp - static_hash_table_test.cpp - ) - -set( DEPRECATED_TEST_SOURCES - daw_cstring_test.cpp - daw_bounded_graph_test.cpp - daw_bounded_hash_map_test.cpp - daw_bounded_hash_set_test.cpp - daw_bounded_string_test.cpp - daw_carray_test.cpp - daw_checked_expected_test.cpp - daw_clumpy_sparsy_test.cpp - daw_copiable_unique_ptr_test.cpp - daw_fixed_array_test.cpp - daw_fixed_lookup_test.cpp - daw_heap_array_test.cpp - daw_heap_value_test.cpp - daw_optional_poly_test.cpp - daw_poly_vector_test.cpp - daw_range_collection_test.cpp - daw_range_test.cpp - daw_safe_string_test.cpp - daw_stack_quick_sort_test.cpp - daw_string_split_range_test.cpp - daw_string_test.cpp - daw_string_view1_test.cpp - daw_vector_test.cpp - ) - -set( CPP20_TEST_SOURCES - daw_atomic_wait_test.cpp - daw_any_if_test.cpp - daw_concepts_test.cpp - daw_contiguous_view_test.cpp - daw_formatters_test.cpp - daw_iter_view_test.cpp - daw_move_only_test.cpp - daw_named_params_test.cpp - daw_observer_ptr_test.cpp - daw_poly_value_test.cpp - ) - -set( CPP20_NOT_MSVC_TEST_SOURCES - daw_contract_test.cpp - daw_pipelines_test.cpp - vector_test.cpp - ) +cmake_policy(SET CMP0065 NEW) + +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +if (CMAKE_BUILD_TYPE EQUAL "Debug") + add_compile_definitions(DEBUG=1) +endif () + +set(TEST_SOURCES + InputIterator_test.cpp + cpp_17_test.cpp + daw_algorithm_test.cpp + daw_arith_traits_test.cpp + daw_array_compare_test.cpp + daw_array_test.cpp + daw_ascii_test.cpp + daw_assume_test.cpp + daw_attributes_test.cpp + daw_benchmark_test.cpp + daw_bounded_vector_test.cpp + daw_constant_test.cpp + daw_container_algorithm_test.cpp + daw_cx_offset_of_test.cpp + daw_cxmath_test.cpp + daw_endian_test.cpp + daw_exception_test.cpp + daw_expected_test.cpp + daw_fnv1a_hash_test.cpp + daw_function_ref_test.cpp + daw_function_table_test.cpp + daw_function_test.cpp + daw_function_view_test.cpp + daw_fwd_pack_apply_test.cpp + daw_generic_hash_test.cpp + daw_graph_algorithm_test.cpp + daw_graph_test.cpp + daw_hash_set_test.cpp + daw_is_any_of_test.cpp + daw_iterator_argument_iterator_test.cpp + daw_iterator_back_inserter_test.cpp + daw_iterator_checked_iterator_proxy_test.cpp + daw_iterator_chunk_iterator_test.cpp + daw_iterator_circular_iterator_test.cpp + daw_iterator_counting_iterators_test.cpp + daw_iterator_end_inserter_test.cpp + daw_iterator_find_iterator_test.cpp + daw_iterator_indexed_iterator_test.cpp + daw_iterator_inserter_test.cpp + daw_iterator_integer_iterator_test.cpp + daw_iterator_iota_iterator_test.cpp + daw_iterator_output_stream_iterator_test.cpp + daw_iterator_random_iterator_test.cpp + daw_iterator_repeat_n_char_iterator_test.cpp + daw_iterator_reverse_iterator_test.cpp + daw_iterator_sorted_insert_iterator_test.cpp + daw_iterator_zipiter_test.cpp + daw_keep_n_test.cpp + daw_lift_test.cpp + daw_logic_test.cpp + daw_math_test.cpp + daw_memory_mapped_file_test.cpp + daw_metro_hash_test.cpp + daw_natural_test.cpp + daw_not_null_test.cpp + daw_nth_pack_element_test.cpp + daw_optional_test.cpp + daw_ordered_map_test.cpp + daw_overload_test.cpp + daw_parse_args_test.cpp + daw_parse_to_test.cpp + daw_parser_helper_sv_test.cpp + daw_poly_var_test.cpp + daw_prop_const_ptr_test.cpp + daw_random_test.cpp + daw_read_file_test.cpp + daw_read_only_test.cpp + daw_ref_counted_pointer_test.cpp + daw_ring_adaptor_test.cpp + daw_scope_guard_test.cpp + daw_simple_array_test.cpp + daw_sip_hash_test.cpp + daw_size_literals_test.cpp + daw_span_test.cpp + daw_stack_function_test.cpp + daw_string_concat_test.cpp + daw_string_view2_test.cpp + daw_take_test.cpp + daw_traits_test.cpp + daw_tuple_helper_test.cpp + daw_tuple_test.cpp + daw_uint_buffer_test.cpp + daw_uninitialized_storage_test.cpp + daw_union_pair_test.cpp + daw_unique_array_test.cpp + daw_unique_ptr_test.cpp + daw_utility_test.cpp + daw_validated_test.cpp + daw_value_ptr_test.cpp + daw_variant_cast_test.cpp + daw_view_test.cpp + daw_virtual_base_test.cpp + daw_visit_test.cpp + daw_zipcontainer_test.cpp + sbo_test.cpp + static_hash_table_test.cpp +) + +set(DEPRECATED_TEST_SOURCES + daw_cstring_test.cpp + daw_bounded_graph_test.cpp + daw_bounded_hash_map_test.cpp + daw_bounded_hash_set_test.cpp + daw_bounded_string_test.cpp + daw_carray_test.cpp + daw_checked_expected_test.cpp + daw_clumpy_sparsy_test.cpp + daw_copiable_unique_ptr_test.cpp + daw_fixed_array_test.cpp + daw_fixed_lookup_test.cpp + daw_heap_array_test.cpp + daw_heap_value_test.cpp + daw_optional_poly_test.cpp + daw_poly_vector_test.cpp + daw_range_collection_test.cpp + daw_range_test.cpp + daw_safe_string_test.cpp + daw_stack_quick_sort_test.cpp + daw_string_split_range_test.cpp + daw_string_test.cpp + daw_string_view1_test.cpp + daw_vector_test.cpp +) + +set(CPP20_TEST_SOURCES + daw_atomic_wait_test.cpp + daw_any_if_test.cpp + daw_concepts_test.cpp + daw_contiguous_view_test.cpp + daw_formatters_test.cpp + daw_iter_view_test.cpp + daw_move_only_test.cpp + daw_named_params_test.cpp + daw_observer_ptr_test.cpp + daw_poly_value_test.cpp +) + +set(CPP20_NOT_MSVC_TEST_SOURCES + daw_contract_test.cpp + daw_pipelines_test.cpp + vector_test.cpp +) #NOT COMPLETED daw_iterator_split_iterator_test.cpp #NOT COMPLETED daw_static_bitset_test.cpp #NOT COMPLETED daw_string_fmt_test.cpp -set( NOT_MSVC_TEST_SOURCES - daw_can_constant_evaluate_test.cpp - daw_parser_helper_test.cpp - daw_piecewise_factory_test.cpp - daw_tuple2_test.cpp - ) +set(NOT_MSVC_TEST_SOURCES + daw_can_constant_evaluate_test.cpp + daw_parser_helper_test.cpp + daw_piecewise_factory_test.cpp + daw_tuple2_test.cpp +) #not included in CI as they are not ready -set( DEV_TEST_SOURCES - daw_bind_args_at_test.cpp - daw_container_help_test.cpp - daw_bit_queues_test.cpp - daw_bit_test.cpp - daw_min_perfect_hash_test.cpp - daw_range_algorithm_test.cpp - daw_sort_n_test.cpp - daw_tracked_allocator_test.cpp - ) +set(DEV_TEST_SOURCES + daw_bind_args_at_test.cpp + daw_container_help_test.cpp + daw_bit_queues_test.cpp + daw_bit_test.cpp + daw_min_perfect_hash_test.cpp + daw_range_algorithm_test.cpp + daw_sort_n_test.cpp + daw_tracked_allocator_test.cpp +) -include( cmake/test_compiler_options.cmake ) +include(cmake/test_compiler_options.cmake) -find_package( Threads REQUIRED ) +find_package(Threads REQUIRED) #Allows building all in some IDE's -add_custom_target( ${PROJECT_NAME}_full ) - -add_library( daw_test INTERFACE ) -target_link_libraries( daw_test INTERFACE daw::header_libraries ) -target_compile_options( daw_test INTERFACE $<$:/permissive-> ) - -set( all_tests ${TEST_SOURCES} ) - -if( NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC" ) - list( APPEND all_tests ${NOT_MSVC_TEST_SOURCES} ) -endif() - -foreach( CUR_TEST IN LISTS all_tests ) - string( REPLACE ".cpp" "" CUR_TEST_NAME ${CUR_TEST} ) - add_executable( "${CUR_TEST_NAME}" "${CUR_TEST}" ) - target_link_libraries( ${CUR_TEST_NAME} PRIVATE daw_test ) - add_test( ${CUR_TEST_NAME}_test ${CUR_TEST_NAME} ) - add_dependencies( ${PROJECT_NAME}_full ${CUR_TEST_NAME} ) -endforeach() - -option( DAW_ENABLE_DEPRECATED_TESTING "Build unit tests still for deprecated libraries" OFF ) -foreach( CUR_TEST IN LISTS DEPRECATED_TEST_SOURCES ) - string( REPLACE ".cpp" "" CUR_TEST_NAME ${CUR_TEST} ) - if( DAW_ENABLE_DEPRECATED_TESTING ) - add_executable( "${CUR_TEST_NAME}" "deprecated/${CUR_TEST}" ) - add_test( ${CUR_TEST_NAME}_test ${CUR_TEST_NAME} ) - add_dependencies( ${PROJECT_NAME}_full ${CUR_TEST_NAME} ) - else() - add_executable( "${CUR_TEST_NAME}" EXCLUDE_FROM_ALL "deprecated/${CUR_TEST}" ) - endif() - target_link_libraries( ${CUR_TEST_NAME} PRIVATE daw_test ) -endforeach() - -if( CMAKE_CXX_STANDARD STRGREATER_EQUAL "20" ) - foreach( CUR_TEST IN LISTS CPP20_TEST_SOURCES ) - string( REPLACE ".cpp" "" CUR_TEST_NAME ${CUR_TEST} ) - add_executable( "${CUR_TEST_NAME}" "${CUR_TEST}" ) - target_link_libraries( ${CUR_TEST_NAME} PRIVATE daw_test ) - target_compile_features( ${CUR_TEST_NAME} PUBLIC cxx_std_20 ) - add_test( ${CUR_TEST_NAME}_test ${CUR_TEST_NAME} ) - add_dependencies( ${PROJECT_NAME}_full ${CUR_TEST_NAME} ) - endforeach() - if( NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC" ) - foreach( CUR_TEST IN LISTS CPP20_NOT_MSVC_TEST_SOURCES ) - string( REPLACE ".cpp" "" CUR_TEST_NAME ${CUR_TEST} ) - add_executable( "${CUR_TEST_NAME}" "${CUR_TEST}" ) - target_link_libraries( ${CUR_TEST_NAME} PRIVATE daw_test ) - target_compile_features( ${CUR_TEST_NAME} PUBLIC cxx_std_20 ) - add_test( ${CUR_TEST_NAME}_test ${CUR_TEST_NAME} ) - add_dependencies( ${PROJECT_NAME}_full ${CUR_TEST_NAME} ) - endforeach() - endif() -else() - message( STATUS "Disabling C++20 tests" ) -endif() - -option( DAW_ENABLE_DEV_TESTING "Build unit tests still in development" OFF ) -foreach( CUR_TEST IN LISTS DEV_TEST_SOURCES ) - string( REPLACE ".cpp" "" CUR_TEST_NAME ${CUR_TEST} ) - if( DAW_ENABLE_DEV_TESTING ) - add_executable( ${CUR_TEST_NAME} ${CUR_TEST} ) - add_dependencies( ${PROJECT_NAME}_full ${CUR_TEST_NAME} ) - else() - add_executable( ${CUR_TEST_NAME} EXCLUDE_FROM_ALL ${CUR_TEST} ) - endif() - target_link_libraries( ${CUR_TEST_NAME} PRIVATE daw_test ) -endforeach() +add_custom_target(${PROJECT_NAME}_full) + +add_library(daw_test INTERFACE) +target_link_libraries(daw_test INTERFACE daw::header_libraries) +target_compile_options(daw_test INTERFACE $<$:/permissive->) + +set(all_tests ${TEST_SOURCES}) + +if (NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + list(APPEND all_tests ${NOT_MSVC_TEST_SOURCES}) +endif () + +foreach (CUR_TEST IN LISTS all_tests) + string(REPLACE ".cpp" "" CUR_TEST_NAME ${CUR_TEST}) + add_executable("${CUR_TEST_NAME}" "${CUR_TEST}") + target_link_libraries(${CUR_TEST_NAME} PRIVATE daw_test) + add_test(${CUR_TEST_NAME}_test ${CUR_TEST_NAME}) + add_dependencies(${PROJECT_NAME}_full ${CUR_TEST_NAME}) +endforeach () + +option(DAW_ENABLE_DEPRECATED_TESTING "Build unit tests still for deprecated libraries" OFF) +foreach (CUR_TEST IN LISTS DEPRECATED_TEST_SOURCES) + string(REPLACE ".cpp" "" CUR_TEST_NAME ${CUR_TEST}) + if (DAW_ENABLE_DEPRECATED_TESTING) + add_executable("${CUR_TEST_NAME}" "deprecated/${CUR_TEST}") + add_test(${CUR_TEST_NAME}_test ${CUR_TEST_NAME}) + add_dependencies(${PROJECT_NAME}_full ${CUR_TEST_NAME}) + else () + add_executable("${CUR_TEST_NAME}" EXCLUDE_FROM_ALL "deprecated/${CUR_TEST}") + endif () + target_link_libraries(${CUR_TEST_NAME} PRIVATE daw_test) +endforeach () + +if (CMAKE_CXX_STANDARD STRGREATER_EQUAL "20") + foreach (CUR_TEST IN LISTS CPP20_TEST_SOURCES) + string(REPLACE ".cpp" "" CUR_TEST_NAME ${CUR_TEST}) + add_executable("${CUR_TEST_NAME}" "${CUR_TEST}") + target_link_libraries(${CUR_TEST_NAME} PRIVATE daw_test) + target_compile_features(${CUR_TEST_NAME} PUBLIC cxx_std_20) + add_test(${CUR_TEST_NAME}_test ${CUR_TEST_NAME}) + add_dependencies(${PROJECT_NAME}_full ${CUR_TEST_NAME}) + endforeach () + if (NOT MSVC) + foreach (CUR_TEST IN LISTS CPP20_NOT_MSVC_TEST_SOURCES) + string(REPLACE ".cpp" "" CUR_TEST_NAME ${CUR_TEST}) + add_executable("${CUR_TEST_NAME}" "${CUR_TEST}") + target_link_libraries(${CUR_TEST_NAME} PRIVATE daw_test) + target_compile_features(${CUR_TEST_NAME} PUBLIC cxx_std_20) + add_test(${CUR_TEST_NAME}_test ${CUR_TEST_NAME}) + add_dependencies(${PROJECT_NAME}_full ${CUR_TEST_NAME}) + endforeach () + endif () +else () + message(STATUS "Disabling C++20 tests") +endif () + +option(DAW_ENABLE_DEV_TESTING "Build unit tests still in development" OFF) +foreach (CUR_TEST IN LISTS DEV_TEST_SOURCES) + string(REPLACE ".cpp" "" CUR_TEST_NAME ${CUR_TEST}) + if (DAW_ENABLE_DEV_TESTING) + add_executable(${CUR_TEST_NAME} ${CUR_TEST}) + add_dependencies(${PROJECT_NAME}_full ${CUR_TEST_NAME}) + else () + add_executable(${CUR_TEST_NAME} EXCLUDE_FROM_ALL ${CUR_TEST}) + endif () + target_link_libraries(${CUR_TEST_NAME} PRIVATE daw_test) +endforeach () diff --git a/tests/cmake/test_compiler_options.cmake b/tests/cmake/test_compiler_options.cmake index 899699819..30d05421d 100644 --- a/tests/cmake/test_compiler_options.cmake +++ b/tests/cmake/test_compiler_options.cmake @@ -1,242 +1,243 @@ -option( DAW_HEADERLIBS_USE_SANITIZERS "Enable address and undefined sanitizers" OFF ) -option( DAW_WERROR "Enable WError for test builds" OFF ) -option( DAW_HEADERLIBS_COVERAGE "Enable code coverage(gcc/clang)" OFF ) +option(DAW_HEADERLIBS_USE_SANITIZERS "Enable address and undefined sanitizers" OFF) +option(DAW_WERROR "Enable WError for test builds" OFF) +option(DAW_HEADERLIBS_COVERAGE "Enable code coverage(gcc/clang)" OFF) -if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" ) - if( DAW_HEADERLIBS_COVERAGE ) - add_compile_options( -fprofile-instr-generate -fcoverage-mapping ) - add_link_options( -fprofile-instr-generate -fcoverage-mapping ) - endif() - if( MSVC ) - message( STATUS "Clang-CL ${CMAKE_CXX_COMPILER_VERSION} detected" ) - add_definitions( -DNOMINMAX -DD_WIN32_WINNT=0x0601 ) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG /permissive- /EHsc" ) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 -DNDEBUG /permissive- /EHsc" ) - if( DAW_WERROR ) - add_compile_options( /WX ) - endif() - add_compile_options( -Wno-missing-braces ) - else() - message( STATUS "Clang ${CMAKE_CXX_COMPILER_VERSION} detected" ) - add_compile_options( - -pedantic - -pedantic-errors - -Weverything - -ftemplate-backtrace-limit=0 - -Wno-c++98-compat - -Wno-covered-switch-default - -Wno-double-promotion - -Wno-padded - -Wno-exit-time-destructors - -Wno-c++98-compat-pedantic - -Wno-missing-prototypes - -Wno-float-equal - -Wno-documentation - -Wno-newline-eof - -Wno-weak-vtables - # This is for when specializing things like tuple_size and each implementer gets to choose struct/class - -Wno-mismatched-tags - -Wno-global-constructors - -Wno-unused-template - -Wno-missing-braces - -Wno-date-time - -Wno-unneeded-member-function - -Wno-switch-default - ) - if( DAW_HEADERLIBS_USE_STDEXCEPT ) - # When std::exception is the parent, this warning is emitted because the destructor is defined inline - add_compile_options( -Wno-weak-vtables ) - endif() - if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" ) - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL "12.0.0" ) - add_compile_options( - -Wno-c++20-extensions - ) - endif() - if( CMAKE_CXX_COMPILER_VERSION LESS "13.1.6" ) - # This was removed in clang-13 - add_compile_options( -Wno-return-std-move-in-c++11 ) - endif() - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL "14.0.0" ) - add_compile_options( - -Wno-c++20-attribute-extensions - ) - endif() - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL "15.0.0" ) - add_compile_options( - -Wno-c++2b-extensions - -Wno-c++20-compat - -Wno-undefined-func-template - ) - endif() +if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang") + if (DAW_HEADERLIBS_COVERAGE) + add_compile_options(-fprofile-instr-generate -fcoverage-mapping) + add_link_options(-fprofile-instr-generate -fcoverage-mapping) + endif () + if (MSVC) + message(STATUS "Clang-CL ${CMAKE_CXX_COMPILER_VERSION} detected") + add_definitions(-DNOMINMAX -DD_WIN32_WINNT=0x0601) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG /permissive- /EHsc") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 -DNDEBUG /permissive- /EHsc") + if (DAW_WERROR) + add_compile_options(/WX) + endif () + add_compile_options(-Wno-missing-braces) + else () + message(STATUS "Clang ${CMAKE_CXX_COMPILER_VERSION} detected") + add_compile_options( + -pedantic + -pedantic-errors + -Weverything + -ftemplate-backtrace-limit=0 + -Wno-c++98-compat + -Wno-covered-switch-default + -Wno-double-promotion + -Wno-padded + -Wno-exit-time-destructors + -Wno-c++98-compat-pedantic + -Wno-missing-prototypes + -Wno-float-equal + -Wno-documentation + -Wno-newline-eof + -Wno-weak-vtables + # This is for when specializing things like tuple_size and each implementer gets to choose struct/class + -Wno-mismatched-tags + -Wno-global-constructors + -Wno-unused-template + -Wno-missing-braces + -Wno-date-time + -Wno-unneeded-member-function + -Wno-switch-default + ) + if (DAW_HEADERLIBS_USE_STDEXCEPT) + # When std::exception is the parent, this warning is emitted because the destructor is defined inline + add_compile_options(-Wno-weak-vtables) + endif () + if (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang") + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL "12.0.0") + add_compile_options( + -Wno-c++20-extensions + ) + endif () + if (CMAKE_CXX_COMPILER_VERSION LESS "13.1.6") + # This was removed in clang-13 + add_compile_options(-Wno-return-std-move-in-c++11) + endif () + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL "14.0.0") + add_compile_options( + -Wno-c++20-attribute-extensions + ) + endif () + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL "15.0.0") + add_compile_options( + -Wno-c++2b-extensions + -Wno-c++20-compat + -Wno-undefined-func-template + ) + endif () - add_compile_options( -Wno-poison-system-directories ) - if( DAW_WERROR ) - add_compile_options( -Werror -pedantic-errors ) - # Cannot add trapv for testing, it breaks 128bit processing on clang/libc++ - # https://bugs.llvm.org/show_bug.cgi?id=16404 - string( FIND "$ENV{CXXFLAGS}" "-stdlib=libc++" HAS_LIBCXX ) - if( HAS_LIBCXX EQUAL -1 ) - add_compile_options( -ftrapv ) - endif() - endif() - else() # Not Apple Clang Clang - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 10.0.0 ) - add_compile_options( - -Wno-poison-system-directories - -Wno-c++20-extensions - ) - endif() - if( CMAKE_CXX_COMPILER_VERSION LESS 13.0.0 ) - # This was removed in clang-13 - add_compile_options( -Wno-return-std-move-in-c++11 ) - endif() - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 14.0.0 ) - add_compile_options( - -Wno-c++20-attribute-extensions - -Wno-bitwise-instead-of-logical - -Wno-c++20-compat - ) - endif() - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 16.0.0 ) - add_compile_options( - -Wno-unsafe-buffer-usage - -Wno-c++2b-extensions - ) - if( CMAKE_CXX_COMPILER_VERSION LESS 17.0.0 ) - add_compile_options( - -Wno-undefined-func-template - ) - endif() - endif() - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 17.0.0 ) - add_compile_options( - -Wno-c++2b-compat - -Wno-c++23-extensions - ) - endif() - if( DAW_WERROR ) - if( CMAKE_CXX_COMPILER_VERSION LESS 13.0.0 ) - add_compile_options( -Werror -pedantic-errors ) - endif() - # Cannot add trapv for testing, it breaks 128bit processing on clang/libc++ - # https://bugs.llvm.org/show_bug.cgi?id=16404 - string( FIND "$ENV{CXXFLAGS}" "-stdlib=libc++" HAS_LIBCXX ) - if( HAS_LIBCXX EQUAL -1 ) - add_compile_options( -ftrapv ) - endif() - endif() - endif() + add_compile_options(-Wno-poison-system-directories) + if (DAW_WERROR) + add_compile_options(-Werror -pedantic-errors) + # Cannot add trapv for testing, it breaks 128bit processing on clang/libc++ + # https://bugs.llvm.org/show_bug.cgi?id=16404 + string(FIND "$ENV{CXXFLAGS}" "-stdlib=libc++" HAS_LIBCXX) + if (HAS_LIBCXX EQUAL -1) + add_compile_options(-ftrapv) + endif () + endif () + else () # Not Apple Clang Clang + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 10.0.0) + add_compile_options( + -Wno-poison-system-directories + -Wno-c++20-extensions + ) + endif () + if (CMAKE_CXX_COMPILER_VERSION LESS 13.0.0) + # This was removed in clang-13 + add_compile_options(-Wno-return-std-move-in-c++11) + endif () + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 14.0.0) + add_compile_options( + -Wno-c++20-attribute-extensions + -Wno-bitwise-instead-of-logical + -Wno-c++20-compat + ) + endif () + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 16.0.0) + add_compile_options( + -Wno-unsafe-buffer-usage + -Wno-c++2b-extensions + ) + if (CMAKE_CXX_COMPILER_VERSION LESS 17.0.0) + add_compile_options( + -Wno-undefined-func-template + ) + endif () + endif () + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 17.0.0) + add_compile_options( + -Wno-c++2b-compat + -Wno-c++23-extensions + ) + endif () + if (DAW_WERROR) + if (CMAKE_CXX_COMPILER_VERSION LESS 13.0.0) + add_compile_options(-Werror -pedantic-errors) + endif () + # Cannot add trapv for testing, it breaks 128bit processing on clang/libc++ + # https://bugs.llvm.org/show_bug.cgi?id=16404 + string(FIND "$ENV{CXXFLAGS}" "-stdlib=libc++" HAS_LIBCXX) + if (HAS_LIBCXX EQUAL -1) + add_compile_options(-ftrapv) + endif () + endif () + endif () - if( CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)" ) - if( NOT CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" ) - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 10.0.0 ) - message( STATUS "Adding Intel JCC bugfix" ) - add_compile_options( -mbranches-within-32B-boundaries ) - endif() - endif() - endif() - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -DDEBUG" ) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g -DDEBUG" ) + if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") + if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 10.0.0) + message(STATUS "Adding Intel JCC bugfix") + add_compile_options(-mbranches-within-32B-boundaries) + endif () + endif () + endif () + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -DDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g -DDEBUG") - if( DAW_HEADERLIBS_USE_SANITIZERS ) - message( STATUS "Using sanitizers" ) - #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=null") - #set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=null") - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=undefined" ) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=address" ) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined" ) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address" ) - endif() - if( CMAKE_BUILD_TYPE STREQUAL "coverage" OR CODE_COVERAGE ) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-instr-generate -fcoverage-mapping" ) - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-instr-generate -fcoverage-mapping" ) - endif() - endif() -elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" ) - if( DAW_HEADERLIBS_COVERAGE ) - add_compile_options( -fprofile-instr-generate -fcoverage-mapping ) - add_compile_options( -fconcepts-diagnostics-depth=3 ) - endif() - message( STATUS "g++ ${CMAKE_CXX_COMPILER_VERSION} detected" ) - add_compile_options( --param max-gcse-memory=260000000 - -Wall - -Wextra - -pedantic - -pedantic-errors - -Wpedantic - -Wconversion - -Wduplicated-cond - -Wlogical-op - -Wold-style-cast - -Wshadow - -Wzero-as-null-pointer-constant - -Wconversion - ) - #-Wno-deprecated-declarations - if( DAW_WERROR ) - add_compile_options( -Werror -pedantic-errors -ftrapv ) - endif() - #-Wdisabled-optimization) - if( CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)" ) - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 9.0.0 ) - if( LINUX ) - message( STATUS "Adding Intel JCC bugfix" ) - add_compile_options( -Wa,-mbranches-within-32B-boundaries ) - endif() - endif() - endif() - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -DDEBUG" ) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g -DDEBUG" ) - if( CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 14.0.0 ) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wnull-dereference" ) - endif() + if (DAW_HEADERLIBS_USE_SANITIZERS) + message(STATUS "Using sanitizers") + #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=null") + #set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=null") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=undefined") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=address") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address") + endif () + if (CMAKE_BUILD_TYPE STREQUAL "coverage" OR CODE_COVERAGE) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-instr-generate -fcoverage-mapping") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-instr-generate -fcoverage-mapping") + endif () + endif () +elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + if (DAW_HEADERLIBS_COVERAGE) + add_compile_options(-fprofile-instr-generate -fcoverage-mapping) + add_compile_options(-fconcepts-diagnostics-depth=3) + endif () + message(STATUS "g++ ${CMAKE_CXX_COMPILER_VERSION} detected") + add_compile_options(--param max-gcse-memory=260000000 + -Wall + -Wextra + -pedantic + -pedantic-errors + -Wpedantic + -Wconversion + -Wduplicated-cond + -Wlogical-op + -Wold-style-cast + -Wshadow + -Wzero-as-null-pointer-constant + -Wconversion + ) + #-Wno-deprecated-declarations + if (DAW_WERROR) + add_compile_options(-Werror -pedantic-errors -ftrapv) + endif () + #-Wdisabled-optimization) + if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 9.0.0) + if (LINUX) + message(STATUS "Adding Intel JCC bugfix") + add_compile_options(-Wa,-mbranches-within-32B-boundaries) + endif () + endif () + endif () + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -DDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g -DDEBUG") + if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 14.0.0) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wnull-dereference") + endif () - if( DAW_HEADERLIBS_USE_SANITIZERS ) - message( STATUS "Using sanitizers" ) - #UBSAN makes constexpr code paths not constexpr on gcc9-11 - #set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=undefined") - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=address" ) - #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined") - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address" ) - endif() -elseif( MSVC ) - message( STATUS "MSVC detected" ) - add_definitions( -DNOMINMAX -DD_WIN32_WINNT=0x0601 ) - add_compile_options( "/permissive-" ) - add_compile_options( "/wd4146" ) - add_compile_options( "/bigobj" ) - add_compile_options( "/w14868" ) - add_compile_options( "/w14296" ) - # Ensure that string pooling is enabled. Otherwise it breaks constexpr string literals. - # This affects debug modes by default, but optionally Release - # https://developercommunity.visualstudio.com/t/codegen:-constexpr-pointer-to-trailing-z/900648 - # shouldn't be needed any longer add_compile_options( "/GF" ) - if( DAW_WERROR ) - if( CMAKE_CXX_FLAGS MATCHES "/W[0-4]" ) - string( REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" ) - else() - add_compile_options( /W4 ) - endif() - add_compile_options( /wd4127 /wd4296 /wd4305 /wd4324 /WX ) - add_definitions( -D_CRT_SECURE_NO_WARNINGS ) - endif() - if( DAW_HEADERLIBS_USE_SANITIZERS ) - add_compile_options( /fsanitize=address ) - endif() -else() - message( STATUS "Unknown compiler id ${CMAKE_CXX_COMPILER_ID}" ) -endif() + if (DAW_HEADERLIBS_USE_SANITIZERS) + message(STATUS "Using sanitizers") + #UBSAN makes constexpr code paths not constexpr on gcc9-11 + #set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=undefined") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=address") + #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address") + endif () +elseif (MSVC) + message(STATUS "MSVC detected") + add_definitions(-DNOMINMAX -DD_WIN32_WINNT=0x0601) + add_compile_options("/permissive-") + add_compile_options("/wd4146") + add_compile_options("/bigobj") + add_compile_options("/w14868") + add_compile_options("/w14296") + add_compile_options("/wd4702") + # Ensure that string pooling is enabled. Otherwise it breaks constexpr string literals. + # This affects debug modes by default, but optionally Release + # https://developercommunity.visualstudio.com/t/codegen:-constexpr-pointer-to-trailing-z/900648 + # shouldn't be needed any longer add_compile_options( "/GF" ) + if (DAW_WERROR) + if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + else () + add_compile_options(/W4) + endif () + add_compile_options(/wd4127 /wd4296 /wd4305 /wd4324 /WX) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + endif () + if (DAW_HEADERLIBS_USE_SANITIZERS) + add_compile_options(/fsanitize=address) + endif () +else () + message(STATUS "Unknown compiler id ${CMAKE_CXX_COMPILER_ID}") +endif () -if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - option( FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." ON ) - if( ${FORCE_COLORED_OUTPUT} ) - if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) - add_compile_options( -fdiagnostics-color=always ) - elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - add_compile_options( -fcolor-diagnostics ) - endif() - endif() -endif() +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." ON) + if (${FORCE_COLORED_OUTPUT}) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + add_compile_options(-fdiagnostics-color=always) + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_compile_options(-fcolor-diagnostics) + endif () + endif () +endif () From ccbc25aecfe206e81451b5207a348b81a3a3b18d Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 16:35:51 -0400 Subject: [PATCH 62/64] Add `expected_failure` type and exception handling for `expecting` functions if exceptions are enabled. --- include/daw/daw_benchmark.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/daw/daw_benchmark.h b/include/daw/daw_benchmark.h index ca2c65323..48685c43a 100644 --- a/include/daw/daw_benchmark.h +++ b/include/daw/daw_benchmark.h @@ -608,6 +608,12 @@ namespace daw { } } // namespace benchmark_impl +#if defined( DAW_USE_EXCEPTIONS ) + struct expected_failure { + expected_failure( ) = default; + }; +#endif + template DAW_ATTRIB_NOINLINE constexpr void expecting( T &&expected_result, U &&result ) { @@ -619,7 +625,11 @@ namespace daw { benchmark_impl::output_expected_error( expected_result, result ); } #endif +#if defined( DAW_USE_EXCEPTIONS ) + throw expected_failure( ); +#else std::terminate( ); +#endif } } @@ -627,7 +637,11 @@ namespace daw { DAW_ATTRIB_NOINLINE constexpr void expecting( Bool const &expected_result ) { if( not static_cast( expected_result ) ) { std::cerr << "Invalid result. Expecting true\n" << std::flush; +#if defined( DAW_USE_EXCEPTIONS ) + throw expected_failure( ); +#else std::terminate( ); +#endif } } @@ -637,7 +651,11 @@ namespace daw { do_not_optimize( expected_result ); if( DAW_UNLIKELY( not( expected_result ) ) ) { std::cerr << message << '\n' << std::flush; +#if defined( DAW_USE_EXCEPTIONS ) + throw expected_failure( ); +#else std::terminate( ); +#endif } (void)message; } From 4268e128f563e4f4cb103d764c3d52a94a02386e Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 16:53:06 -0400 Subject: [PATCH 63/64] Add `expected_failure` handling to benchmark functions, enabling conditional exception support. --- include/daw/daw_benchmark.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/include/daw/daw_benchmark.h b/include/daw/daw_benchmark.h index 48685c43a..aec691c29 100644 --- a/include/daw/daw_benchmark.h +++ b/include/daw/daw_benchmark.h @@ -10,6 +10,7 @@ #include "daw/ciso646.h" #include "daw/daw_arith_traits.h" +#include "daw/daw_check_exceptions.h" #include "daw/daw_cxmath.h" #include "daw/daw_do_not_optimize.h" #include "daw/daw_expected.h" @@ -28,6 +29,12 @@ #include namespace daw { +#if defined( DAW_USE_EXCEPTIONS ) + struct expected_failure { + expected_failure( ) = default; + }; +#endif + namespace benchmark_impl { using second_duration = std::chrono::duration; } // namespace benchmark_impl @@ -354,7 +361,11 @@ namespace daw { auto const valid_start = std::chrono::steady_clock::now( ); if( DAW_UNLIKELY( not validator( result ) ) ) { std::cerr << "Error validating result\n" << std::flush; +#if defined( DAW_USE_EXCEPTIONS ) + throw expected_failure( ); +#else std::terminate( ); +#endif } valid_time += benchmark_impl::second_duration( std::chrono::steady_clock::now( ) - valid_start ); @@ -570,7 +581,11 @@ namespace daw { daw::do_not_optimize( result ); if( DAW_UNLIKELY( not validator( std::move( result ) ) ) ) { std::cerr << "Error validating result\n" << std::flush; +#if defined( DAW_USE_EXCEPTIONS ) + throw expected_failure( ); +#else std::terminate( ); +#endif } auto const duration = @@ -608,12 +623,6 @@ namespace daw { } } // namespace benchmark_impl -#if defined( DAW_USE_EXCEPTIONS ) - struct expected_failure { - expected_failure( ) = default; - }; -#endif - template DAW_ATTRIB_NOINLINE constexpr void expecting( T &&expected_result, U &&result ) { @@ -692,7 +701,11 @@ namespace daw { std::cerr << "Unexpected exception\n" << std::flush; throw; } +#if defined( DAW_USE_EXCEPTIONS ) + throw expected_failure( ); +#else std::terminate( ); +#endif #endif } } // namespace daw From 5f5645efa22feae4481866d2dbe4aa11ae926b70 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sat, 12 Jul 2025 16:56:41 -0400 Subject: [PATCH 64/64] Remove `noexcept` specifier from benchmark templates for broader use cases. --- include/daw/daw_benchmark.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/daw/daw_benchmark.h b/include/daw/daw_benchmark.h index aec691c29..35de69259 100644 --- a/include/daw/daw_benchmark.h +++ b/include/daw/daw_benchmark.h @@ -213,7 +213,7 @@ namespace daw { template DAW_ATTRIB_NOINLINE auto bench_n_test( std::string const &title, Test &&test_callable, - Args const &...args ) noexcept { + Args const &...args ) { static_assert( Runs > 0 ); static_assert( std::is_invocable_v, "Unable to call Test with provided Args" ); @@ -321,7 +321,7 @@ namespace daw { typename Function, typename... Args> [[nodiscard]] DAW_ATTRIB_NOINLINE std::array bench_n_test_mbs2( std::string const &, size_t, Validator &&validator, - Function &&func, Args const &...args ) noexcept { + Function &&func, Args const &...args ) { static_assert( Runs > 0 ); static_assert( std::is_invocable_v, "Unable to call Function with provided Args" ); @@ -380,7 +380,7 @@ namespace daw { template [[nodiscard]] DAW_ATTRIB_NOINLINE auto bench_n_test_mbs( std::string const &title, size_t bytes, - Test &&test_callable, Args const &...args ) noexcept { + Test &&test_callable, Args const &...args ) { static_assert( Runs > 0 ); static_assert( std::is_invocable_v, "Unable to call Test with provided Args" ); @@ -489,7 +489,7 @@ namespace daw { /// @return last result timing counts of runs template [[nodiscard]] DAW_ATTRIB_NOINLINE std::vector - bench_n_test_json( Function &&func, Args &&...args ) noexcept { + bench_n_test_json( Function &&func, Args &&...args ) { static_assert( Runs > 0 ); static_assert( std::is_invocable_v, "Unable to call Test with provided Args" ); @@ -542,7 +542,7 @@ namespace daw { template DAW_ATTRIB_NOINLINE std::vector bench_n_test_json_val( Validator &&validator, Function &&func, - Args &&...args ) noexcept { + Args &&...args ) { static_assert( Runs > 0 ); static_assert( std::is_invocable_v, "Unable to call Test with provided Args" );