dimanche 28 mars 2021

Access an index of a map from a pointer

I currently have this

struct test
{
 std::map<int, UINT64> ratio;
}

where pContext is a pointer to test

int group = 1;
auto a = (*pContext).ratio[group]; <---Error

In the above I get the following error

Severity    Code    Description Project File    Line    Suppression State
Error   C2678   binary '[': no operator found which takes a left-hand operand of type 'const std::map<int,UINT64,std::less<int>,std::allocator<std::pair<const int,UINT64>>>' (or there is no acceptable conversion)

Any suggesstion on how I can fix this ?

Aucun commentaire:

Enregistrer un commentaire