You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rules that convert between type parameters need overload resolution #700
f101 vector<T>::insert(pos, InputIt first, InputIt last) and similar rules (std::copy) build or assign a T from *first. C++ picks the conversion from the type of *first to T by overload resolution:
longs.insert(longs.end(), ratios.begin(), ratios.end()) with only Ratio::operator int() uses operator int(), then int -> long
ints.insert(ints.end(), ratios.begin(), ratios.end()) with operator short() and operator long() picks operator short, because short -> int is a promotion and beats the conversion long -> int
Rust traits can't express these: an intermediate type can't be chained, and overlapping impls can't be ranked. Not even nightly specialization can fully cover overload resolution.
I think the solution is to do overload resolution at runtime in libcc2rs. Each type generates a hidden table with all the needed information and the runtime overload resolution algorithm uses it to choose the right constructor.
Activity
lucic71 commentedon Dec 3, 2026
This is related to the ConstructibleFrom and ConvertibleTo work. Depends on #699
Add ConstructibleFrom and ConvertibleTo traits (Cpp2Rust#701)