سؤال

When one thread manages an std::map adding and removing things, may another thread safely call size() on the map?

Since there are no iterators involved, invalidation is not an issue.

In this case, I suppose the map is always alive. No object-destruction-at-a-bad-moment issues.

هل كانت مفيدة؟

المحلول

No. Size may involve traversal as it is not guaranteed to be O(1).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top