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// <unordered_map>
11
12// unordered_map(unordered_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 <unordered_map>
21#include <cassert>
22
23#include "test_macros.h"
24#include "MoveOnly.h"
25#include "test_allocator.h"
26
27template <class T>
28struct 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
35template <class T>
36struct some_hash
37{
38    typedef T value_type;
39    some_hash();
40    some_hash(const some_hash&);
41
42    std::size_t operator()(T const&) const;
43};
44
45int main()
46{
47#if defined(_LIBCPP_VERSION)
48    {
49        typedef std::unordered_map<MoveOnly, MoveOnly> C;
50        static_assert(std::is_nothrow_move_constructible<C>::value, "");
51    }
52    {
53        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
54                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
55        static_assert(std::is_nothrow_move_constructible<C>::value, "");
56    }
57    {
58        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
59                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
60        static_assert(std::is_nothrow_move_constructible<C>::value, "");
61    }
62#endif // _LIBCPP_VERSION
63    {
64        typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
65        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
66    }
67    {
68        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
69                                                         some_comp<MoveOnly>> C;
70        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
71    }
72}
73