class MyClass {
int MyArray[10];
public:
int& operator[](std::size_t index) {
return MyArray[index];
}
const int& operator[](std::size_t index) const {
return MyArray[index];
}
};
Does anyone ever add the volatile overload? Does anyone ever add the const and volatile overload? This is as bad as const/non-const references in C++03. Defining these as extensions may be considerably easier.
type MyClass = new type;
MyClass
.add_private_member_variable("MyArray", int.array(10));
MyClass
.add_public_member_function("operator[]",
[](this, index) -> auto.rvalue_reference()
{
return forward(this).MyArray[index];
});
In this format, you can see that we can perfectly forward on this, something which is impossible in C++0x. Our returning of that reference will always respect const-correctness, volatile-correctness, lvalue-rvalue correctness, and any other kind of correctness I can think of that may be forwarded, which may include thread-safety correctness (thread-correctness?) in a single function.
No comments:
Post a Comment