mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This makes it possible to initialize `std::vector` from a Swift Sequence. This also conforms C++ vectors to `ExpressibleByArrayLiteral`, making it possible, for instance, to pass a Swift array to a C++ function that takes a vector of strings as a parameter. rdar://104826995
16 lines
410 B
C++
16 lines
410 B
C++
#ifndef TEST_INTEROP_CXX_STDLIB_INPUTS_STD_VECTOR_H
|
|
#define TEST_INTEROP_CXX_STDLIB_INPUTS_STD_VECTOR_H
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
using Vector = std::vector<int>;
|
|
using VectorOfString = std::vector<std::string>;
|
|
|
|
inline Vector initVector() { return {}; }
|
|
|
|
inline std::string takesVectorOfString(const VectorOfString &v) {
|
|
return v.front();
|
|
}
|
|
|
|
#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_VECTOR_H
|