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// UNSUPPORTED: c++03, c++11, c++14, c++17, c++2010 11// <flat_map>12 13// class flat_multimap14 15// [[nodiscard]] bool empty() const noexcept;16 17#include <flat_map>18#include <cassert>19#include <deque>20#include <functional>21#include <utility>22#include <vector>23 24#include "MinSequenceContainer.h"25#include "test_macros.h"26#include "min_allocator.h"27 28template <class KeyContainer, class ValueContainer>29constexpr void test() {30 using Key = typename KeyContainer::value_type;31 using Value = typename ValueContainer::value_type;32 using M = std::flat_multimap<Key, Value, std::less<int>, KeyContainer, ValueContainer>;33 M m;34 ASSERT_SAME_TYPE(decltype(m.empty()), bool);35 ASSERT_NOEXCEPT(m.empty());36 assert(m.empty());37 assert(std::as_const(m).empty());38 m = {{1, 1.0}, {1, 2.0}};39 assert(!m.empty());40 m.clear();41 assert(m.empty());42}43 44constexpr bool test() {45 test<std::vector<int>, std::vector<double>>();46#ifndef __cpp_lib_constexpr_deque47 if (!TEST_IS_CONSTANT_EVALUATED)48#endif49 test<std::deque<int>, std::vector<double>>();50 test<MinSequenceContainer<int>, MinSequenceContainer<double>>();51 test<std::vector<int, min_allocator<int>>, std::vector<double, min_allocator<double>>>();52 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