brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 08dfcea 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// <map>10 11// class multimap12 13// void clear() noexcept;14 15#include <map>16#include <cassert>17 18#include "test_macros.h"19#include "min_allocator.h"20 21int main(int, char**) {22  {23    typedef std::multimap<int, double> M;24    typedef std::pair<int, double> P;25    P ar[] = {26        P(1, 1.5),27        P(2, 2.5),28        P(3, 3.5),29        P(4, 4.5),30        P(5, 5.5),31        P(6, 6.5),32        P(7, 7.5),33        P(8, 8.5),34    };35    M m(ar, ar + sizeof(ar) / sizeof(ar[0]));36    assert(m.size() == 8);37    ASSERT_NOEXCEPT(m.clear());38    m.clear();39    assert(m.size() == 0);40  }41#if TEST_STD_VER >= 1142  {43    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;44    typedef std::pair<int, double> P;45    P ar[] = {46        P(1, 1.5),47        P(2, 2.5),48        P(3, 3.5),49        P(4, 4.5),50        P(5, 5.5),51        P(6, 6.5),52        P(7, 7.5),53        P(8, 8.5),54    };55    M m(ar, ar + sizeof(ar) / sizeof(ar[0]));56    assert(m.size() == 8);57    ASSERT_NOEXCEPT(m.clear());58    m.clear();59    assert(m.size() == 0);60  }61#endif62 63  return 0;64}65