Files
swift-mirror/test/Interop/Cxx/reference/Inputs/reference.cpp
Alex Lorenz ebb21d7ec1 [cxx-interop] Import const T& parameters as T.
This change allows Swift code to pass immutable values to const references in C++.
2022-03-03 14:42:27 -08:00

23 lines
806 B
C++

#include "reference.h"
static int staticInt = 42;
int getStaticInt() { return staticInt; }
int &getStaticIntRef() { return staticInt; }
int &&getStaticIntRvalueRef() { return static_cast<int &&>(staticInt); }
const int &getConstStaticIntRef() { return staticInt; }
const int &&getConstStaticIntRvalueRef() { return static_cast<int &&>(staticInt); }
void setStaticInt(int i) { staticInt = i; }
void setStaticIntRef(int &i) { staticInt = i; }
void setStaticIntRvalueRef(int &&i) { staticInt = i; }
void setConstStaticIntRef(const int &i) { staticInt = i; }
void setConstStaticIntRvalueRef(const int &&i) { staticInt = i; }
auto getFuncRef() -> int (&)() { return getStaticInt; }
auto getFuncRvalueRef() -> int (&&)() { return getStaticInt; }
void takeConstRef(const int &value) {
staticInt = value;
}