llvm-project
51 строка · 1.4 Кб
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <set>
10
11// class set
12
13// size_type max_size() const;
14
15#include <cassert>16#include <limits>17#include <set>18#include <type_traits>19
20#include "test_allocator.h"21#include "test_macros.h"22
23int main(int, char**)24{
25{26typedef limited_allocator<int, 10> A;27typedef std::set<int, std::less<int>, A> C;28C c;29assert(c.max_size() <= 10);30LIBCPP_ASSERT(c.max_size() == 10);31}32{33typedef limited_allocator<int, (std::size_t)-1> A;34typedef std::set<int, std::less<int>, A> C;35const C::size_type max_dist =36static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());37C c;38assert(c.max_size() <= max_dist);39LIBCPP_ASSERT(c.max_size() == max_dist);40}41{42typedef std::set<char> C;43const C::size_type max_dist =44static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());45C c;46assert(c.max_size() <= max_dist);47assert(c.max_size() <= alloc_max_size(c.get_allocator()));48}49
50return 0;51}
52