brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · a3e510d Raw
64 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// list(const list& c); // constexpr since C++2612 13#include <list>14#include <cassert>15 16#include "test_macros.h"17#include "DefaultOnly.h"18#include "test_allocator.h"19#include "min_allocator.h"20 21TEST_CONSTEXPR_CXX26 bool test() {22  {23    std::list<int> l(3, 2);24    std::list<int> l2 = l;25    assert(l2 == l);26  }27  {28    std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));29    std::list<int, test_allocator<int> > l2 = l;30    assert(l2 == l);31    assert(l2.get_allocator() == l.get_allocator());32  }33#if TEST_STD_VER >= 1134  {35    std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));36    std::list<int, other_allocator<int> > l2 = l;37    assert(l2 == l);38    assert(l2.get_allocator() == other_allocator<int>(-2));39  }40  {41    std::list<int, min_allocator<int>> l(3, 2);42    std::list<int, min_allocator<int>> l2 = l;43    assert(l2 == l);44  }45  {46    std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());47    std::list<int, min_allocator<int> > l2 = l;48    assert(l2 == l);49    assert(l2.get_allocator() == l.get_allocator());50  }51#endif52 53  return true;54}55 56int main(int, char**) {57  test();58#if TEST_STD_VER >= 2659  static_assert(test());60#endif61 62  return 0;63}64