Update max_size() implementation and tests

This commit is contained in:
Glen Fernandes committed 2019-04-25 13:05:06 -04:00
1 parent e859d01186
commit 5a549b8b22
2 files changed
+17 -5

No files matched your search

+9
View File
@@ -135,11 +135,20 @@ void test_construct_other()
(void)a5;
}
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX)
template<class T>
std::size_t max_size()
{
return PTRDIFF_MAX < SIZE_MAX / sizeof(T)
? PTRDIFF_MAX : SIZE_MAX / sizeof(T);
}
#else
template<class T>
std::size_t max_size()
{
return ~static_cast<std::size_t>(0) / sizeof(T);
}
#endif
void test_max_size()
{