Skip to content

GH-50250: [C++] Remove call_traits::argument_type in favor of <type_traits> - #51328

Open
taepper wants to merge 1 commit into
apache:mainfrom
taepper:remove-argument-type
Open

GH-50250: [C++] Remove call_traits::argument_type in favor of <type_traits>#51328
taepper wants to merge 1 commit into
apache:mainfrom
taepper:remove-argument-type

Conversation

@taepper

@taepper taepper commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

This is the last change for #50250. The remaining FnOnce does not have corresponding utilities in the C++20 standard library according to my knowledge.

What changes are included in this PR?

This removes the custom meta-programming facility call_traits::argument_type. We instead use the provided type_traits header which allows us to check invocability (and thus indirectly the argument type) with e.g. std::is_invocable.

It needs to be mentioned that none of std::is_invocable_v, std::invoke_result_t, .. is a drop-in replacement for the removed argument_type. I instead migrated all users of the old facility to the standard constructs. Some call-sites needed changing by supplying template parameters explicitly, but in my opinion all changes are defendable or even improvements.

Are these changes tested?

Yes, this refactoring commit still passes all test cases

Are there any user-facing changes?

No

std::make_shared<Memoizer>(std::forward<Func>(func), cache_capacity)};

return shared_memoized;
return std::function<RetType(const Key&)>(std::move(shared_memoized));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wrapping the result in a std::function adds a layer of indirection when calling operator() that might be expensive. Can we avoid this?

@pitrou

pitrou commented Sep 14, 2026

Copy link
Copy Markdown
Member

Unfortunately we'll have to wait for #51326 before we can ensure that this doesn't break on some C++ compilers on our CI platforms.

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants