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// UNSUPPORTED: c++03
10
11// <unordered_set>
12
13// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
14// class Alloc = allocator<Value>>
15// class unordered_set
16
17// template <class... Args>
18// iterator emplace_hint(const_iterator p, Args&&... args);
19
20
21#include <unordered_set>
22#include <cassert>
23
24#include "test_macros.h"
25#include "../../Emplaceable.h"
26#include "min_allocator.h"
27
28int main(int, char**)
29{
30 {
31 typedef std::unordered_set<Emplaceable> C;
32 typedef C::iterator R;
33 C c;
34 R r = c.emplace_hint(c.end());
35 assert(c.size() == 1);
36 assert(*r == Emplaceable());
37
38 r = c.emplace_hint(c.end(), Emplaceable(5, 6));
39 assert(c.size() == 2);
40 assert(*r == Emplaceable(5, 6));
41
42 r = c.emplace_hint(r, 5, 6);
43 assert(c.size() == 2);
44 assert(*r == Emplaceable(5, 6));
45 }
46 {
47 typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
48 std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
49 typedef C::iterator R;
50 C c;
51 R r = c.emplace_hint(c.end());
52 assert(c.size() == 1);
53 assert(*r == Emplaceable());
54
55 r = c.emplace_hint(c.end(), Emplaceable(5, 6));
56 assert(c.size() == 2);
57 assert(*r == Emplaceable(5, 6));
58
59 r = c.emplace_hint(r, 5, 6);
60 assert(c.size() == 2);
61 assert(*r == Emplaceable(5, 6));
62 }
63
64 return 0;
65}
66

source code of libcxx/test/std/containers/unord/unord.set/emplace_hint.pass.cpp