49 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <unordered_set>10 11// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,12// class Alloc = allocator<Value>>13// class unordered_set14 15// size_type bucket(const key_type& __k) const;16 17#include <unordered_set>18#include <cassert>19 20#include "test_macros.h"21#include "min_allocator.h"22 23int main(int, char**) {24 {25 typedef std::unordered_set<int> C;26 typedef int P;27 P a[] = {P(1), P(2), P(3), P(4), P(1), P(2)};28 const C c(std::begin(a), std::end(a));29 std::size_t bc = c.bucket_count();30 assert(bc >= 5);31 for (std::size_t i = 0; i < 13; ++i)32 LIBCPP_ASSERT(c.bucket(i) == i % bc);33 }34#if TEST_STD_VER >= 1135 {36 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;37 typedef int P;38 P a[] = {P(1), P(2), P(3), P(4), P(1), P(2)};39 const C c(std::begin(a), std::end(a));40 std::size_t bc = c.bucket_count();41 assert(bc >= 5);42 for (std::size_t i = 0; i < 13; ++i)43 LIBCPP_ASSERT(c.bucket(i) == i % bc);44 }45#endif46 47 return 0;48}49