Skip to content

Conversation

@ksil
Copy link
Contributor

@ksil ksil commented Aug 30, 2025

Love this project so much! This PR:

  • Adds a default implementation for struct utest_type_deducer<T, false> so that custom structs in C++ with proper overloaded operators can still enjoy all the UTEST macros without error. Previously, one could not use macros like EXPECT_LT without custom template specializations of utest_type_deducer.
  • Removed an unnecessary const_cast
  • Changed the printing function to pass by reference. This may have some very small performance overhead for small primitives if C++ if the compiler doesn't optimize it away, but consistency for all types is probably nice.
  • Changed UTEST_AUTO to be a const auto reference. This not only accepts both lvalues and rvalues (temporaries) but it also now allows utest macros to work for structs that are not copy constructible.

Discussion:
In a future PR, it could be nice to check if a struct is forgettable via the concept std::formattable available in C++23. Then one could call std::format on the provided struct instead of printing (object [pointer]) as I do by default for now for max compatibility.

@sheredom
Copy link
Owner

Thanks! PR looks ok assuming green CI.

@ksil
Copy link
Contributor Author

ksil commented Aug 31, 2025

Awesome! Let me know if you need anything else to merge

@sheredom sheredom merged commit fb622dc into sheredom:master Aug 31, 2025
53 checks passed
@sheredom
Copy link
Owner

Not against adding support for std::formattable, just would want a before/after compile time cost of including that header from C++23 onwards!

@ksil ksil deleted the ksil/generic-types branch August 31, 2025 19:29
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.

2 participants