Howard Hinnant | 7686add | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 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 | #include <map> |
| 19 | #include <cassert> |
| 20 | |
Marshall Clow | df00d5e | 2015-01-28 21:22:53 +0000 | [diff] [blame] | 21 | #include "MoveOnly.h" |
Marshall Clow | 1b92188 | 2013-12-03 00:18:10 +0000 | [diff] [blame] | 22 | #include "test_allocator.h" |
Howard Hinnant | 7686add | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 23 | |
| 24 | template <class T> |
| 25 | struct some_comp |
| 26 | { |
| 27 | typedef T value_type; |
| 28 | some_comp(const some_comp&); |
| 29 | }; |
| 30 | |
| 31 | int main() |
| 32 | { |
| 33 | #if __has_feature(cxx_noexcept) |
Marshall Clow | eefcf82 | 2015-11-24 22:10:51 +0000 | [diff] [blame] | 34 | typedef std::pair<const MoveOnly, MoveOnly> V; |
Howard Hinnant | 7686add | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 35 | { |
| 36 | typedef std::map<MoveOnly, MoveOnly> C; |
| 37 | static_assert(std::is_nothrow_move_constructible<C>::value, ""); |
| 38 | } |
| 39 | { |
Marshall Clow | eefcf82 | 2015-11-24 22:10:51 +0000 | [diff] [blame] | 40 | typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; |
Howard Hinnant | 7686add | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 41 | static_assert(std::is_nothrow_move_constructible<C>::value, ""); |
| 42 | } |
| 43 | { |
Marshall Clow | eefcf82 | 2015-11-24 22:10:51 +0000 | [diff] [blame] | 44 | typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; |
Howard Hinnant | 7686add | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 45 | static_assert(std::is_nothrow_move_constructible<C>::value, ""); |
| 46 | } |
| 47 | { |
| 48 | typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; |
| 49 | static_assert(!std::is_nothrow_move_constructible<C>::value, ""); |
| 50 | } |
| 51 | #endif |
| 52 | } |