Born 2 Code/C, C++
[STL] c++ container max_size() 구현
yechoi
2021. 5. 4. 17:21
반응형
아래는 deque의 max_size() 구현. (출처 libstdc++)
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _Alloc_traits::max_size(_M_get_Tp_allocator()); }
따라가다보면 결국 std::allocator<T>의 max_size()를 받아쓰는 형식인데, 이는 대부분의 구현에선 아래를 반환한다.
std::numeric_limits<size_type>::max() / sizeof(value_type)
(출처: cppreference)
반응형