53 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// <map>10 11// ~map() // implied noexcept;12 13// UNSUPPORTED: c++0314 15#include <cassert>16#include <map>17#include <type_traits>18 19#include "test_macros.h"20#include "MoveOnly.h"21#include "test_allocator.h"22 23template <class T>24struct some_comp {25 typedef T value_type;26 ~some_comp() noexcept(false);27 bool operator()(const T&, const T&) const noexcept { return false; }28};29 30int main(int, char**) {31 typedef std::pair<const MoveOnly, MoveOnly> V;32 {33 typedef std::map<MoveOnly, MoveOnly> C;34 static_assert(std::is_nothrow_destructible<C>::value, "");35 }36 {37 typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;38 static_assert(std::is_nothrow_destructible<C>::value, "");39 }40 {41 typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;42 static_assert(std::is_nothrow_destructible<C>::value, "");43 }44#if defined(_LIBCPP_VERSION)45 {46 typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;47 static_assert(!std::is_nothrow_destructible<C>::value, "");48 }49#endif // _LIBCPP_VERSION50 51 return 0;52}53