I just noticed, that in N3291 a change is marked (5.2.1 Subscripting [expr.sub]):
Before, it was ok to overload operator[] with the new braced-init-list:
struct X {
Z operator[](std::initializer_list<int>);
};
X x;
x[{1,2,3}] = 7; // OK: meaning x.operator[]({1,2,3})
Now that is removed and replaced with:
A braced-init-list shall not be used with the built-in subscript operator.
What was the problem?
x[{1,2,3}] is not the built-in [] operator. It invokes a user defined operator function. So take a deep breath and go on using this fun syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With