1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // size_type max_size() const;
15 #include <forward_list>
17 #include <type_traits>
19 #include "test_allocator.h"
20 #include "test_macros.h"
25 typedef limited_allocator<int, 10> A;
26 typedef std::forward_list<int, A> C;
28 assert(c.max_size() <= 10);
29 LIBCPP_ASSERT(c.max_size() == 10);
32 typedef limited_allocator<int, (size_t)-1> A;
33 typedef std::forward_list<int, A> C;
34 const C::size_type max_dist =
35 static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
37 assert(c.max_size() <= max_dist);
38 LIBCPP_ASSERT(c.max_size() == max_dist);
41 typedef std::forward_list<char> C;
42 const C::size_type max_dist =
43 static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
45 assert(c.max_size() <= max_dist);
46 assert(c.max_size() <= alloc_max_size(c.get_allocator()));