brintos

brintos / llvm-project-archived public Read only

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