mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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.
41 lines
841 B
C++
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];
|
|
} |