Skip to content

Conversation

@Yaraslaut
Copy link
Member

Some test and requires for provided functions

///
/// @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<>>

}

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.

3 participants