Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests and concepts for some functions #13

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

Yaraslaut
Copy link
Member

Some test and requires for provided functions

@@ -751,6 +752,7 @@ constexpr ResultType FoldMembers(ResultType initialValue, Callable const& callab
///
/// @return The result of the fold
template <typename Object, typename Callable, typename ResultType>
requires std::same_as<ResultType, std::invoke_result_t<Callable, std::string, MemberTypeOf<1, Object>, ResultType>>
Copy link
Member

Choose a reason for hiding this comment

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

why std::string as first parameter? Shouldn't that be ResultType?

Copy link
Member Author

Choose a reason for hiding this comment

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

callable is called in the following way:

result = callable(MemberNameOf<I, Object>, value, result);

so it must take MemberNameOf<I, Object> (std::string) as first argument and return result type which is ResultType
In the requires statement we first check that we can invoke callable with the required arguments
std::invoke_result_t<Callable, std::string, MemberTypeOf<1, Object>, ResultType>
and then check that returned type is ResultType in std::same_as<ResultType, std::invoke_result_t<>>

@@ -715,6 +715,7 @@ constexpr void EnumerateMembers(Callable&& callable)
}

template <typename Object, typename Callable>
requires std::same_as<void, std::invoke_result_t<Callable, std::string, MemberTypeOf<1, Object>>>
Copy link
Member

Choose a reason for hiding this comment

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

same question here as I asked below (sorry) :-)

@Yaraslaut Yaraslaut force-pushed the improvement/tests_and_concepts_for_callable branch from b6e6ba3 to 665a4b5 Compare November 7, 2024 13:04
Copy link
Member

@christianparpart christianparpart left a comment

Choose a reason for hiding this comment

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

sorry for the delay :)

@Yaraslaut Yaraslaut merged commit 74a6181 into master Nov 12, 2024
5 checks passed
@christianparpart christianparpart deleted the improvement/tests_and_concepts_for_callable branch January 21, 2025 21:44
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