add methods to extract memory usage
@@ -528,6 +528,13 @@ public:
void reserve(size_type newCapacity) {
reserveBytes(newCapacity + 1);
}
+
+ size_t count_allocated_memory() const {
+ return sizeof(small_string) + isAllocated() ? _bufferSize : 0;
+ }
+ size_t count_used_memory() const {
+ return sizeof(small_string) - StackSize + size();
+ }
private:
void assign_slower(const void * s, size_type sz) __attribute((noinline));
void init_slower(const void *s) noexcept __attribute((noinline));
