Skip to content

Conversation

@egorzhdan
Copy link
Contributor

This adds func remove(at index: Int) to all instantiations of std::vector via an extension for protocol CxxVector.

The original C++ method std::vector::erase is not visible in Swift because all of its overloads return unsafe iterators.

rdar://113704853

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Oct 26, 2023
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

The test is failing on Windows because std::vector::iterator is not conformed to the UnsafeCxxRandomAccessIterator protocol:

template <class _Myvec>
class _Vector_iterator : public _Vector_const_iterator<_Myvec> {
public:
    using _Mybase = _Vector_const_iterator<_Myvec>;
// ...
    using _Mybase::operator-; // <-- this is the overload Swift needs

operator- takes _Vector_const_iterator instead of _Vector_iterator as a parameter, preventing the automatic conformance.

@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-vector-remove branch from c3ffea2 to 3b19e59 Compare November 14, 2023 14:55
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test Linux

@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-vector-remove branch from 6eb70df to 487e8e5 Compare January 2, 2024 19:46
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-vector-remove branch from 487e8e5 to 288a0d6 Compare July 9, 2024 18:29
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-vector-remove branch from 288a0d6 to 88dca49 Compare July 10, 2024 17:26
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

This adds `func remove(at index: Int)` to all instantiations of `std::vector` via an extension for `protocol CxxVector`.

The original C++ method `std::vector::erase` is not visible in Swift because all of its overloads return unsafe iterators.

rdar://113704853
@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-vector-remove branch from 88dca49 to fcbfc49 Compare September 2, 2024 14:17
@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

2 similar comments
@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

@egorzhdan
Copy link
Contributor Author

@swift-ci please test Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ interop Feature: Interoperability with C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants