brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 19ea940 Raw
63 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// <list>10 11// void merge(list& x); // constexpr since C++2612// If (addressof(x) == this) does nothing; otherwise ...13 14#include <list>15#include <cassert>16 17#include "test_macros.h"18#include "min_allocator.h"19 20TEST_CONSTEXPR_CXX26 bool test() {21  {22    int a1[] = {1, 3, 7, 9, 10};23    int a2[] = {0, 2, 4, 5, 6, 8, 11};24    int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};25    std::list<int> c1(a1, a1 + sizeof(a1) / sizeof(a1[0]));26    std::list<int> c2(a2, a2 + sizeof(a2) / sizeof(a2[0]));27    c1.merge(c2);28    assert(c1 == std::list<int>(a3, a3 + sizeof(a3) / sizeof(a3[0])));29    assert(c2.empty());30  }31 32  {33    int a1[] = {1, 3, 7, 9, 10};34    std::list<int> c1(a1, a1 + sizeof(a1) / sizeof(a1[0]));35    c1.merge(c1);36    assert((c1 == std::list<int>(a1, a1 + sizeof(a1) / sizeof(a1[0]))));37  }38 39#if TEST_STD_VER >= 1140  {41    int a1[] = {1, 3, 7, 9, 10};42    int a2[] = {0, 2, 4, 5, 6, 8, 11};43    int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};44    std::list<int, min_allocator<int>> c1(a1, a1 + sizeof(a1) / sizeof(a1[0]));45    std::list<int, min_allocator<int>> c2(a2, a2 + sizeof(a2) / sizeof(a2[0]));46    c1.merge(c2);47    assert((c1 == std::list<int, min_allocator<int>>(a3, a3 + sizeof(a3) / sizeof(a3[0]))));48    assert(c2.empty());49  }50#endif51 52  return true;53}54 55int main(int, char**) {56  assert(test());57#if TEST_STD_VER >= 2658  static_assert(test());59#endif60 61  return 0;62}63