]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / containers / associative / map / map.cons / move_noexcept.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <map>
11
12 // map(map&&)
13 //        noexcept(is_nothrow_move_constructible<allocator_type>::value &&
14 //                 is_nothrow_move_constructible<key_compare>::value);
15
16 // This tests a conforming extension
17
18 // UNSUPPORTED: c++98, c++03
19
20 #include <map>
21 #include <cassert>
22
23 #include "test_macros.h"
24 #include "MoveOnly.h"
25 #include "test_allocator.h"
26
27 template <class T>
28 struct some_comp
29 {
30     typedef T value_type;
31     some_comp(const some_comp&);
32     bool operator()(const T&, const T&) const { return false; }
33 };
34
35 int main()
36 {
37     typedef std::pair<const MoveOnly, MoveOnly> V;
38     {
39         typedef std::map<MoveOnly, MoveOnly> C;
40         LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
41     }
42     {
43         typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C;
44         LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
45     }
46     {
47         typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C;
48         LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, "");
49     }
50     {
51         typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
52         static_assert(!std::is_nothrow_move_constructible<C>::value, "");
53     }
54 }