template <typename T>
class myvector
{
...
/**
* @brief Returns the number of elements that the container has currently
* allocated space for.
* @return Capacity of the currently allocated storage.
*/
size_type capacity(void) const noexcept
{
return capacity_;
}
...
private:
pointer heap_ = nullptr;
size_type size_ = 0;
size_type capacity_ = 0;
};
前回のsize()と同じ形の関数で、メンバ変数 capacity_ を返します。
全ソースコード: https://github.com/suomesta/myvector/tree/master/005
0 件のコメント:
コメントを投稿