diff --git a/include/EASTL/deque.h b/include/EASTL/deque.h index c8da31c0..e6182334 100644 --- a/include/EASTL/deque.h +++ b/include/EASTL/deque.h @@ -423,6 +423,7 @@ namespace eastl bool empty() const EA_NOEXCEPT; size_type size() const EA_NOEXCEPT; + size_type max_size() const EA_NOEXCEPT; void resize(size_type n, const value_type& value); void resize(size_type n); @@ -1476,6 +1477,14 @@ namespace eastl } + template + typename deque::size_type + inline deque::max_size() const EA_NOEXCEPT + { + return base_type::kMaxSize; + } + + template inline void deque::resize(size_type n, const value_type& value) { diff --git a/include/EASTL/vector.h b/include/EASTL/vector.h index 509ab31e..27376181 100644 --- a/include/EASTL/vector.h +++ b/include/EASTL/vector.h @@ -261,6 +261,7 @@ namespace eastl bool empty() const EA_NOEXCEPT; size_type size() const EA_NOEXCEPT; size_type capacity() const EA_NOEXCEPT; + size_type max_size() const EA_NOEXCEPT; void resize(size_type n, const value_type& value); void resize(size_type n); @@ -813,6 +814,14 @@ namespace eastl } + template + inline typename vector::size_type + vector::max_size() const EA_NOEXCEPT + { + return base_type::kMaxSize; + } + + template inline void vector::resize(size_type n, const value_type& value) { diff --git a/test/source/TestDeque.cpp b/test/source/TestDeque.cpp index cf324cbf..588106e4 100644 --- a/test/source/TestDeque.cpp +++ b/test/source/TestDeque.cpp @@ -112,6 +112,9 @@ int TestDequeConstruction() dB.clear(); EATEST_VERIFY(dB.size() == 0); EATEST_VERIFY(dB.empty()); + + // max_size + EATEST_VERIFY(dB.max_size() == std::numeric_limits::max() - 1u); } EATEST_VERIFY(TestObject::sTOCount == 0); diff --git a/test/source/TestVector.cpp b/test/source/TestVector.cpp index 05f72e89..0fe7bceb 100644 --- a/test/source/TestVector.cpp +++ b/test/source/TestVector.cpp @@ -1077,8 +1077,12 @@ int TestVector() { using namespace eastl; - // reserve / resize / capacity / clear vector v(10, 17); + + // max_size + EATEST_VERIFY(v.max_size() == std::numeric_limits::max() - 1u); + + // reserve / resize / capacity / clear v.reserve(20); EATEST_VERIFY(v.validate()); EATEST_VERIFY(v.size() == 10);