brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 1256433 Raw
79 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// explicit list(const Alloc& = Alloc()); // constexpr since C++2612 13#include <list>14#include <cassert>15#include "test_macros.h"16#include "DefaultOnly.h"17#include "min_allocator.h"18 19TEST_CONSTEXPR_CXX26 bool test() {20  {21    std::list<int> l;22    assert(l.size() == 0);23    assert(std::distance(l.begin(), l.end()) == 0);24  }25  {26    std::list<DefaultOnly> l;27    assert(l.size() == 0);28    assert(std::distance(l.begin(), l.end()) == 0);29  }30  {31    std::list<int> l((std::allocator<int>()));32    assert(l.size() == 0);33    assert(std::distance(l.begin(), l.end()) == 0);34  }35#if TEST_STD_VER >= 1136  {37    std::list<int, min_allocator<int>> l;38    assert(l.size() == 0);39    assert(std::distance(l.begin(), l.end()) == 0);40  }41  {42    std::list<DefaultOnly, min_allocator<DefaultOnly>> l;43    assert(l.size() == 0);44    assert(std::distance(l.begin(), l.end()) == 0);45  }46  {47    std::list<int, min_allocator<int>> l((min_allocator<int>()));48    assert(l.size() == 0);49    assert(std::distance(l.begin(), l.end()) == 0);50  }51  {52    std::list<int> l = {};53    assert(l.size() == 0);54    assert(std::distance(l.begin(), l.end()) == 0);55  }56  {57    std::list<int, explicit_allocator<int>> l;58    assert(l.size() == 0);59    assert(std::distance(l.begin(), l.end()) == 0);60  }61  {62    std::list<int, explicit_allocator<int>> l((explicit_allocator<int>()));63    assert(l.size() == 0);64    assert(std::distance(l.begin(), l.end()) == 0);65  }66#endif67 68  return true;69}70 71int main(int, char**) {72  assert(test());73#if TEST_STD_VER >= 2674  static_assert(test());75#endif76 77  return 0;78}79