4 ms·
The C++ code could have also just have been `T`. It's a bit odd of a comparison because `RandomAccessIterator` is just a name the author chose for the template
by veilrap 4y ago
The C++ code could have also just have been `T`. It's a bit odd of a comparison because `RandomAccessIterator` is just a name the author chose for the template typename.
- zerocrates 4y agoI think that's what the person you responded to was saying actually, that the author specifically chose a verbose template parameter for the C++ examples.
- ncmncm 4y agoThat author missed the significance of a detail that illustrates a major difference in the expressive power of C++ vs. Rust.
- tialaramex 4y agoYou've confused RandomAccessIterator (a perfectly reasonable name for a Rust trait, but not really in the usual style of the C++ standard library) for std::random_access_iterator an actual concept defined in C++ 20 std::random_access_iterator like most of its fellows in C++ 20 is largely duck typed, there's a semantic "model" provided, but this is not enforced anywhere and your compiler will actually accept completely bogus types so long as the syntax matches. The standard washes its hands of the consequences by saying that if you don't obey the model your program is not valid C++ and the compiler is not expected to detect that and tell you about it.
- ncmncm 4y agoNo, on both counts. No, I did not confuse it, but chose not to quibble over spelling. And, no, C++ concepts are not limited to "duck typing".