Skip to content

Use generic get<N> for pair, array and tuple_element - #572

Open
lucic71 wants to merge 10 commits into
Cpp2Rust:masterfrom
lucic71:get
Open

lucic71 wants to merge 10 commits into
Cpp2Rust:masterfrom
lucic71:get

Conversation

@lucic71

@lucic71 lucic71 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

std::pair::get is defined as:

template< std::size_t I, class T1, class T2 >
typename std::tuple_element<I, std::pair<T1,T2> >::type&
    get( std::pair<T1, T2>& p ) noexcept;

Our rules wrote individual versions for get<0> and get<1>. This PR adds the generic version get<N> as declared by the standard.

This PR also adds get for array and translates tuple_element.


Rust does not allow writing a rule as get<N>(a0: (T1, T2)) { return a.N } with N = {0, 1}. So we need libcc2rs support for this. TupleElement is the translation of std::tuple_element and TupleGet uses TupleElement to translate std::get.

@nunoplopes

Copy link
Copy Markdown
Contributor

(conflict)

This branch has not been deployed

No deployments
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