samedi 8 octobre 2022

Is it possible to acces vector items this way vector.back(-n), vector.front(+n)?

I would like to access vector items in this way: I think this should be valid and really useful:

vector.back(-42)
vector.front(+42)

Is it doable in any way?

Update: I was asked "why"?: Just for simplicity and consistency with front() and back() access method.

Perhaps back() and front() were not intended as access methods but rather as a quick solution to first and last, which is often used.

Aucun commentaire:

Enregistrer un commentaire