sizeof(x), gives the size of x in bytes.
vector::size(), gives...... not the size of the vector in bytes, but the NUMBER of elements in the vector. so that name feels slightly confusing. why wasnt it instead named vector::length() or something, I sometimes wonder 
As you said in comments, count() is the way to go. Though one could argue that as a getter, it should be get_count(), as “count” implies the function is going to count something, not return a cached value.
-
-
In my Intra library I use both. Length is defined for sequential containers and ranges if it is O(1). Count is defined as Length when Length is defined or as the number of elements for non-sequential container, otherwise it is usually a counting O(N) operation.
Kiitos. Käytämme tätä aikajanasi parantamiseen. KumoaKumoa
-
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.