Files
swift-mirror/test/Interop/Cxx/operators/Inputs/member-out-of-line.cpp
Puyan Lotfi 864b3a47e3 [cxx-interop] Implement operator[] for value return types (SR-14351).
This builds on top of the work of Egor Zhdan. It implements
`T operator[]` and does so largely by taking a path very much like the
`const T &operator[]` path.
2021-04-08 00:18:27 -04:00

41 lines
841 B
C++

#include "member-out-of-line.h"
LoadableIntWrapper LoadableIntWrapper::operator+(LoadableIntWrapper rhs) const {
return LoadableIntWrapper{.value = value + rhs.value};
}
int LoadableIntWrapper::operator()() const {
return value;
}
int LoadableIntWrapper::operator()(int x) const {
return value + x;
}
int LoadableIntWrapper::operator()(int x, int y) const {
return value + x * y;
}
int AddressOnlyIntWrapper::operator()() const {
return value;
}
int AddressOnlyIntWrapper::operator()(int x) const {
return value + x;
}
int AddressOnlyIntWrapper::operator()(int x, int y) const {
return value + x * y;
}
const int& ReadWriteIntArray::operator[](int x) const {
return values[x];
}
int& ReadWriteIntArray::operator[](int x) {
return values[x];
}
int NonTrivialIntArrayByVal::operator[](int x) {
return values[x];
}