llvm-project
83 строки · 2.3 Кб
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// <set>
12
13// class multiset
14
15// template <class... Args>
16// iterator emplace_hint(const_iterator position, Args&&... args);
17
18#include <set>19#include <cassert>20
21#include "test_macros.h"22#include "../../Emplaceable.h"23#include "DefaultOnly.h"24#include "min_allocator.h"25
26int main(int, char**)27{
28{29typedef std::multiset<DefaultOnly> M;30typedef M::iterator R;31M m;32assert(DefaultOnly::count == 0);33R r = m.emplace_hint(m.cend());34assert(r == m.begin());35assert(m.size() == 1);36assert(*m.begin() == DefaultOnly());37assert(DefaultOnly::count == 1);38
39r = m.emplace_hint(m.cbegin());40assert(r == m.begin());41assert(m.size() == 2);42assert(*m.begin() == DefaultOnly());43assert(DefaultOnly::count == 2);44}45assert(DefaultOnly::count == 0);46{47typedef std::multiset<Emplaceable> M;48typedef M::iterator R;49M m;50R r = m.emplace_hint(m.cend());51assert(r == m.begin());52assert(m.size() == 1);53assert(*m.begin() == Emplaceable());54r = m.emplace_hint(m.cend(), 2, 3.5);55assert(r == std::next(m.begin()));56assert(m.size() == 2);57assert(*r == Emplaceable(2, 3.5));58r = m.emplace_hint(m.cbegin(), 2, 3.5);59assert(r == std::next(m.begin()));60assert(m.size() == 3);61assert(*r == Emplaceable(2, 3.5));62}63{64typedef std::multiset<int> M;65typedef M::iterator R;66M m;67R r = m.emplace_hint(m.cend(), M::value_type(2));68assert(r == m.begin());69assert(m.size() == 1);70assert(*r == 2);71}72{73typedef std::multiset<int, std::less<int>, min_allocator<int>> M;74typedef M::iterator R;75M m;76R r = m.emplace_hint(m.cend(), M::value_type(2));77assert(r == m.begin());78assert(m.size() == 1);79assert(*r == 2);80}81
82return 0;83}
84