Skip to content

Conversation

@zasdfgbnm
Copy link
Collaborator

This update removes the cartesian_product function and introduces a more efficient any_check function that utilizes C++20 fold expressions. The new implementation checks if any elements in one or more tuples satisfy a given predicate, improving code clarity and performance.

This update removes the cartesian_product function and introduces a more efficient any_check function that utilizes C++20 fold expressions. The new implementation checks if any elements in one or more tuples satisfy a given predicate, improving code clarity and performance.
@zasdfgbnm
Copy link
Collaborator Author

!test

This update modernizes the `any_check` function by replacing its previous implementation with a more efficient version that leverages C++20 fold expressions. The new implementation simplifies the checks for predicate satisfaction across tuples, enhancing both clarity and performance. Additionally, several usages of `any_check` throughout the `dynamic_type` module have been updated to reflect this change.
@github-actions
Copy link

github-actions bot commented Jan 29, 2026

Review updated until commit 6b6d622

Description

  • Remove cartesian_product and any_check utility functions from type_traits.h

  • Refactor any_check usages to use C++20 fold expressions with std::apply

  • Convert is_dynamic_type trait to variable template is_dynamic_type_v

  • Introduce DynamicTypeLike concept for improved type constraints

  • Update operator definitions and macros to use modern C++20 features

Changes walkthrough

Relevant files
Enhancement
dynamic_type.h
Modernize type checking with C++20 fold expressions           

lib/dynamic_type/src/dynamic_type/dynamic_type.h

  • Replace any_check calls with std::apply and fold expressions in
    can_cast_to, has_square_bracket, has_any_square_bracket
  • Convert is_dynamic_type trait to variable template is_dynamic_type_v
  • Add DynamicTypeLike concept for type constraints
  • Update DEFINE_UNARY_OP, operator*, operator<< to use fold expressions
  • Refactor DEFINE_LEFT_PPMM and DEFINE_RIGHT_PPMM macros with fold
    expressions
  • Update DEFINE_ASSIGNMENT_OP and has_cross_type_equality to use
    DynamicTypeLike concept
  • +118/-129
    type_traits.h
    Remove deprecated utility functions                                           

    lib/dynamic_type/src/dynamic_type/type_traits.h

  • Remove entire cartesian_product function implementation (lines
    248-318)
  • Remove entire any_check function implementation (lines 320-355)
  • +0/-96   

    PR Reviewer Guide

    Here are some key observations to aid the review process:

    🧪 No relevant tests
    ⚡ Recommended focus areas for review
    Missing Performance Data

    The PR description claims performance improvements but provides no actual performance metrics, benchmarks, or data to substantiate these claims. This makes it difficult to evaluate the effectiveness of the changes.

    static constexpr bool can_cast_to = std::apply(
        [](auto... ts) constexpr {
          return (
              (requires(typename decltype(ts)::type from) { (T)(from); }) || ...);
        },
        type_identities_as_tuple);
    No Tests for New Implementation

    The PR removes the cartesian_product and any_check functions but doesn't include tests for the new fold expression implementations. This creates a risk of regressions and makes it difficult to verify correctness of the new approach.

    template <typename>
    inline constexpr bool is_dynamic_type_v = false;
    
    template <typename Containers, typename... Ts>
    inline constexpr bool is_dynamic_type_v<DynamicType<Containers, Ts...>> = true;
    
    // A DynamicType, allowing cv/ref qualifiers on the deduced type.
    template <typename T>
    concept DynamicTypeLike = is_dynamic_type_v<std::remove_cvref_t<T>>;
    Removed Functionality Without Migration Path

    The cartesian_product and any_check functions are completely removed from type_traits.h. If these functions were part of the public API or used elsewhere, this could break existing code. The PR should verify these functions are not used externally.

    static_assert(!belongs_to<int, float, double, long>);

    @zasdfgbnm
    Copy link
    Collaborator Author

    !test

    @zasdfgbnm zasdfgbnm changed the title Remove cartesian_product from any_check Remove cartesian_product and any_check Jan 29, 2026
    @zasdfgbnm
    Copy link
    Collaborator Author

    !test

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    1 participant