Files
swift-mirror/test/Interop/Cxx/stdlib/Inputs/std-pair.h
Egor Zhdan e9dd9109e7 [cxx-interop] Update the std::pair safety test
The test was passing by accident: we didn't properly check `std::pair` type for completeness, and assumed that it is incomplete.

This updates the test to actually verify the behavior that is specified in the vision document.
2024-01-12 16:21:43 +00:00

42 lines
916 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 __attribute__((swift_attr("import_owned"))) HasMethodThatReturnsUnsafePair {
PairUnsafeStructInt getUnsafePair() const { return {}; }
PairIteratorInt getIteratorPair() const { return {}; }
};