Skip to content

🎨 Make apply work with types that implement the tuple protocol#344

Open
elbeno wants to merge 1 commit intointel:mainfrom
elbeno:apply-array
Open

🎨 Make apply work with types that implement the tuple protocol#344
elbeno wants to merge 1 commit intointel:mainfrom
elbeno:apply-array

Conversation

@elbeno
Copy link
Contributor

@elbeno elbeno commented Mar 18, 2026

Problem:

  • std::apply works with std::array. stdx::apply does not.

Solution:

  • Make stdx::apply work with types that implement the tuple protocol.

Notes:

  • The standard uses the term tuple-like to mean specifically a specialization of std::tuple, std::pair, std::array, std::complex or std::ranges::subrange. (https://eel.is/c++draft/tuple.like)
  • The non-standard term of art "tuple protocol" refers to types that implement:
    • tuple_size
    • tuple_element
    • get
      Which tuple-like types do, but which is a more general constraint.

Problem:
- `std::apply` works with `std::array`. `stdx::apply` does not.

Solution:
- Make `stdx::apply` work with types that implement the tuple protocol.

Notes:
- The standard uses the term *tuple-like* to mean specifically a specialization
  of `std::tuple`, `std::pair`, `std::array`, `std::complex` or
  `std::ranges::subrange`. (https://eel.is/c++draft/tuple.like)
- The non-standard term of art "tuple protocol" refers to types that implement:
  - `tuple_size`
  - `tuple_element`
  - `get`
  Which *tuple-like* type do, but which is a more general constraint.
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.

1 participant