In C++, we have square brackets in different places and I think it's sometimes important to distinguish them when talking to other developers. While I can call all of them "square brackets", I think they have better names, depending on what they do.
I am thinking of
- array declaration, like
int arr[1024]; - array assignment, like
arr[13] = 17; - array access, like
int x = arr[13]; - map (and other container) access, like
int y = map["key"]; - captures in lambdas, like
auto lambda = [&](){return 23 + arr[13];}; - the ones in
delete[] - those of attributes like
[[deprecated("for reasons")]] - the separation of a pair into its parts like
auto [x, y] = std::make_pair(1, 2);
IMHO, the array assignment and array access brackets are called subscript operator. What about all the others? Do they have good names?