mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
In libc++, `pair()` and `pair(_T1 const& __t1, _T2 const& __t2)` are templated with `enable_if`, so these initializers are not imported into Swift. There should be a way to call `std.pair.init` from Swift, so this change makes sure Swift synthesizes a memberwise initializer for `std.pair`. rdar://113135110
42 lines
872 B
C++
42 lines
872 B
C++
#pragma once
|
|
|
|
#include <utility>
|
|
#include <string>
|
|
|
|
using PairInts = std::pair<int, int>;
|
|
using PairStrings = std::pair<std::string, std::string>;
|
|
|
|
inline const PairInts &getIntPairPointer() {
|
|
static PairInts value = { 4, 9 };
|
|
return value;
|
|
}
|
|
|
|
inline PairInts getIntPair() {
|
|
return { -5, 12 };
|
|
}
|
|
|
|
struct StructInPair {
|
|
int x;
|
|
int y;
|
|
};
|
|
|
|
using PairStructInt = std::pair<StructInPair, int>;
|
|
|
|
inline PairStructInt getPairStructInt(int x) {
|
|
return { { x * 2, -x}, x };
|
|
}
|
|
|
|
struct UnsafeStruct {
|
|
int *ptr;
|
|
};
|
|
|
|
struct __attribute__((swift_attr("import_iterator"))) Iterator {};
|
|
|
|
using PairUnsafeStructInt = std::pair<UnsafeStruct, int>;
|
|
using PairIteratorInt = std::pair<Iterator, int>;
|
|
|
|
struct HasMethodThatReturnsUnsafePair {
|
|
PairUnsafeStructInt getUnsafePair() const { return {}; }
|
|
PairIteratorInt getIteratorPair() const { return {}; }
|
|
};
|