Vector indexing for short

Suppose I have a vector

std::vector<a> A;

I can access my function members using an operator ., and I can index it using an operator []. If I have a pointer to a vector, for example

std::vector<a> *A;

I can get its members using a short operator ->, but indexing is very inconvenient, i.e. (*A)[i]. How can it be written more accurately? Note: I am not satisfied A->at()because it performs border checks that are slow and speed is important to me.

+3
source share
1 answer

Linking it to a link is easiest if the problem is (*A)[i]:

std::vector<a>& ref = *A;
ref[i] = 0; //use reference

, NULL.

+16

Source: https://habr.com/ru/post/1792023/


All Articles