brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 49df556 Raw
71 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// flat_multimap()14//    noexcept(15//        is_nothrow_default_constructible_v<key_container_type> &&16//        is_nothrow_default_constructible_v<mapped_container_type> &&17//        is_nothrow_default_constructible_v<key_compare>);18 19// This tests a conforming extension20 21#include <cassert>22#include <flat_map>23#include <functional>24#include <vector>25 26#include "test_macros.h"27#include "MoveOnly.h"28#include "test_allocator.h"29 30struct ThrowingCtorComp {31  constexpr ThrowingCtorComp() noexcept(false) {}32  constexpr bool operator()(const auto&, const auto&) const { return false; }33};34 35constexpr bool test() {36#if defined(_LIBCPP_VERSION)37  {38    using C = std::flat_multimap<MoveOnly, MoveOnly>;39    static_assert(std::is_nothrow_default_constructible_v<C>);40    C c;41  }42  {43    using C =44        std::flat_multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, test_allocator<MoveOnly>>>;45    static_assert(std::is_nothrow_default_constructible_v<C>);46    C c;47  }48#endif // _LIBCPP_VERSION49  {50    using C =51        std::flat_multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, other_allocator<MoveOnly>>>;52    static_assert(!std::is_nothrow_default_constructible_v<C>);53    C c;54  }55  {56    using C = std::flat_multimap<MoveOnly, MoveOnly, ThrowingCtorComp>;57    static_assert(!std::is_nothrow_default_constructible_v<C>);58    C c;59  }60  return true;61}62 63int main(int, char**) {64  test();65#if TEST_STD_VER >= 2666  static_assert(test());67#endif68 69  return 0;70}71