Files
swift-mirror/test/Interop/Cxx/class/method/Inputs/ambiguous_methods.h
zoecarver 474a7cd834 [cxx-interop] Only mark projections of self-contained types as unsafe.
Projections of trivial types and view types aren't unsafe. This matches what was described in the vision document.
2023-07-18 17:42:05 -07:00

61 lines
1.3 KiB
C++

#ifndef TEST_INTEROP_CXX_CLASS_AMBIGUOUS_METHOD_METHODS_H
#define TEST_INTEROP_CXX_CLASS_AMBIGUOUS_METHOD_METHODS_H
struct HasAmbiguousMethods {
// One input (const first)
int increment(int a) const {
return a + 1;
}
int increment(int a) {
++mutableMethodsCalledCount;
return a + 1;
}
// Multiple input with out param
void increment(int a, int b, int &c) {
++mutableMethodsCalledCount;
c = a + b;
}
void increment(int a, int b, int &c) const {
c = a + b;
}
// Multiple input with inout param
void increment(int &a, int b) {
++mutableMethodsCalledCount;
a += b;
}
void increment(int &a, int b) const {
a += b;
}
// No input with output (const first)
int numberOfMutableMethodsCalled() const { return mutableMethodsCalledCount; }
int numberOfMutableMethodsCalled() { return ++mutableMethodsCalledCount; }
private:
int mutableMethodsCalledCount = 0;
};
struct HasAmbiguousMethods2 {
int increment(int a) const {
return a + 1;
}
};
struct Unsafe {
int *ptr;
};
struct HasAmbiguousUnsafeMethods {
HasAmbiguousUnsafeMethods(const HasAmbiguousUnsafeMethods&);
Unsafe getUnsafe() const { return Unsafe(); }
Unsafe getUnsafe() { return Unsafe(); }
};
#endif // TEST_INTEROP_CXX_CLASS_AMBIGUOUS_METHOD_METHODS_H