brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 88a76d3 Raw
61 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// UNSUPPORTED: c++03, c++11, c++14, c++17, c++2010 11// <flat_set>12 13// [[nodiscard]] bool empty() const noexcept;14 15#include <flat_set>16#include <cassert>17#include <deque>18#include <functional>19#include <utility>20#include <vector>21 22#include "MinSequenceContainer.h"23#include "test_macros.h"24#include "min_allocator.h"25 26template <class KeyContainer>27constexpr void test_one() {28  using Key = typename KeyContainer::value_type;29  using M   = std::flat_multiset<Key, std::less<int>, KeyContainer>;30  M m;31  ASSERT_SAME_TYPE(decltype(m.empty()), bool);32  ASSERT_NOEXCEPT(m.empty());33  assert(m.empty());34  assert(std::as_const(m).empty());35  m = {1};36  assert(!m.empty());37  m.clear();38  assert(m.empty());39}40 41constexpr bool test() {42  test_one<std::vector<int>>();43#ifndef __cpp_lib_constexpr_deque44  if (!TEST_IS_CONSTANT_EVALUATED)45#endif46    test_one<std::deque<int>>();47  test_one<MinSequenceContainer<int>>();48  test_one<std::vector<int, min_allocator<int>>>();49 50  return true;51}52 53int main(int, char**) {54  test();55#if TEST_STD_VER >= 2656  static_assert(test());57#endif58 59  return 0;60}61