brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · c2fa54f Raw
60 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      unique(); // before C++2012// size_type unique(); // C++20 and later; constexpr since C++2613 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[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};23    int a2[] = {2, 1, 4, 3};24    typedef std::list<int> L;25    L c(a1, a1 + sizeof(a1) / sizeof(a1[0]));26#if TEST_STD_VER > 1727    ASSERT_SAME_TYPE(L::size_type, decltype(c.unique()));28    assert(c.unique() == 5);29#else30    ASSERT_SAME_TYPE(void, decltype(c.unique()));31    c.unique();32#endif33    assert(c == std::list<int>(a2, a2 + 4));34  }35#if TEST_STD_VER >= 1136  {37    int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};38    int a2[] = {2, 1, 4, 3};39    std::list<int, min_allocator<int>> c(a1, a1 + sizeof(a1) / sizeof(a1[0]));40#  if TEST_STD_VER > 1741    assert(c.unique() == 5);42#  else43    c.unique();44#  endif45    assert((c == std::list<int, min_allocator<int>>(a2, a2 + 4)));46  }47#endif48 49  return true;50}51 52int main(int, char**) {53  assert(test());54#if TEST_STD_VER >= 2655  static_assert(test());56#endif57 58  return 0;59}60