Pre-asserts to ensure no overflow happens
Merge pull request #245 from Dmitry-Me/ensureCapacityPreAsserts

Pre-asserts to ensure no overflow happens