Files
swift-mirror/test/Interop/Cxx/stdlib/Inputs/std-pair.h
Egor Zhdan 6902041e34 [cxx-interop] Force creating a memberwise init for std::pair
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
2023-08-01 18:59:41 +01:00

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 {}; }
};