This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Create <__invoke> header that generates the __invoke and __invoke_constexpr functions.
AbandonedPublic

Authored by EricWF on May 12 2015, 5:25 PM.

Details

Summary

std::experimental::apply requires a constexpr implementation of INVOKE(...). Simply marking the current implementation of __invoke as constexpr will break existing code due to CWG issue #1581. For this reason we should add a separate function called __invoke_constexpr to be used where constexpr is required.

To supply two almost identical INVOKE(...) we use the <__invoke> header to generate the declarations and definitions by defining the required macros and including the <__invoke> header inline. The <__invoke> header can be included multiple times.

The macros used are:

  • _LIBCPP_INVOKE_NAME: The name of the invoke function to be created.
  • _LIBCPP_INVOKE_CONSTEXPR: The optional constexpr decorator for the invoke function.
  • _LIBCPP_DECLARE_INVOKE: Declare the required invoke function.
  • _LIBCPP_DEFINE_INVOKE: Define the required invoke function.

I chose not to generate invoke functions using macros because of the amount of code that would have to be within a macro block. It also is likely to yield bad error messages.

This patch also re-enables constexpr support for std::experimental::apply.

Also See:
https://llvm.org/bugs/show_bug.cgi?id=23141
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1581

Diff Detail

Event Timeline

EricWF updated this revision to Diff 25651.May 12 2015, 5:25 PM
EricWF retitled this revision from to [libcxx] Create <__invoke> header that generates the __invoke and __invoke_constexpr functions..
EricWF updated this object.
EricWF edited the test plan for this revision. (Show Details)
EricWF added reviewers: mclow.lists, danalbert, jroelofs.
EricWF added a subscriber: Unknown Object (MLST).
EricWF updated this object.May 12 2015, 5:39 PM
EricWF added a subscriber: rsmith.

@rsmith Could you please look at the latest reproducer on the following bug (https://llvm.org/bugs/show_bug.cgi?id=23141). Is there a way to work around that code while having a constexpr __invoke?

EricWF abandoned this revision.Jul 21 2015, 9:32 PM

Abandoning in favor of D11329. That patch will help me fix the __invoke implementation in C++03.