llvm-project
59 строк · 1.7 Кб
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-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <map>
10
11// map& operator=(map&& c)
12// noexcept(
13// allocator_type::propagate_on_container_move_assignment::value &&
14// is_nothrow_move_assignable<allocator_type>::value &&
15// is_nothrow_move_assignable<key_compare>::value);
16
17// This tests a conforming extension
18
19// UNSUPPORTED: c++03
20
21#include <map>22#include <cassert>23
24#include "test_macros.h"25#include "MoveOnly.h"26#include "test_allocator.h"27
28template <class T>29struct some_comp30{
31typedef T value_type;32some_comp& operator=(const some_comp&);33bool operator()(const T&, const T&) const { return false; }34};35
36int main(int, char**)37{
38typedef std::pair<const MoveOnly, MoveOnly> V;39{40typedef std::map<MoveOnly, MoveOnly> C;41static_assert(std::is_nothrow_move_assignable<C>::value, "");42}43{44typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;45static_assert(!std::is_nothrow_move_assignable<C>::value, "");46}47#if defined(_LIBCPP_VERSION)48{49typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;50static_assert(std::is_nothrow_move_assignable<C>::value, "");51}52#endif // _LIBCPP_VERSION53{54typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;55static_assert(!std::is_nothrow_move_assignable<C>::value, "");56}57
58return 0;59}
60