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// UNSUPPORTED: c++03, c++11, c++14, c++1710 11#include <cassert>12#include <set>13 14// <set>15 16// bool contains(const key_type& x) const;17 18template <typename T, typename V, typename B, typename... Vals>19void test(B bad, Vals... args) {20 T set;21 V vals[] = {args...};22 23 for (auto& v : vals)24 set.insert(v);25 for (auto& v : vals)26 assert(set.contains(v));27 28 assert(!set.contains(bad));29}30 31struct E {32 int a = 1;33 double b = 1;34 char c = 1;35};36 37int main(int, char**) {38 {39 test<std::set<int>, int>(14, 10, 11, 12, 13);40 test<std::set<char>, char>('e', 'a', 'b', 'c', 'd');41 }42 {43 test<std::multiset<int>, int>(14, 10, 11, 12, 13);44 test<std::multiset<char>, char>('e', 'a', 'b', 'c', 'd');45 }46 47 return 0;48}49