Skip to content

Feature | cpp20 compatibility - #46

Merged
arximboldi merged 3 commits into
arximboldi:masterfrom
BenLeadbetter:feature/cpp20-compatibility
Nov 10, 2025
Merged

arximboldi merged 3 commits into
arximboldi:masterfrom
BenLeadbetter:feature/cpp20-compatibility

Conversation

@BenLeadbetter

Copy link
Copy Markdown
  • Can be configured with a custom C++ standard
  • The tests compile and pass against C++20

Ben Leadbetter added 2 commits November 5, 2025 17:45
* can be configured with a custom C++ standard
* the tests compile and pass against C++20

struct deterministic_engine
{
using result_type = std::uint64_t;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hit a compile error in a custom compilation environment (not the dev nix env) here when it seems that this result type alias is expected for the rng to conform with UniformRandomBitGenerator

@arximboldi arximboldi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Thank you for picking this up! There is a question about one of the changes.

Comment on lines +123 to +128
#if __cplusplus < 202002L
friend bool operator!=(const DerivedT& lhs, const DerivedT& rhs)
{
return !access_t::equal(derived(), rhs);
return !access_t::equal(lhs, rhs);
}
#endif

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you need to do this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In C++20 operator!= is automatically generated by the compiler when there's a corresponding operator==.

It's not strictly necessary to compile it out in C++20 builds. I guess it's a tradeoff in complexity: cpp20 builds would technically need to compile less code but at the price of this compile time switch.

I'd leave it up to you of course! Let me know and I'll remove the ifdefs

Comment thread zug/sequence.hpp
#if __cplusplus >= 201703L
empty_reductor<std::decay_t<std::invoke_result_t<XformT, step_t>>, state_t>;
#else
empty_reductor<std::decay_t<std::result_of_t<XformT(step_t)>>, state_t>;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::result_of was deprecated in C++17 and removed in C++20.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! thank you!

std::result_of was deprecated in C++17 and removed in C++20.
@BenLeadbetter
BenLeadbetter force-pushed the feature/cpp20-compatibility branch from 9f3ccd1 to 035a352 Compare November 9, 2025 11:56
@arximboldi
arximboldi merged commit b102498 into arximboldi:master Nov 10, 2025
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