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// <set> 11 12// void swap(multiset& c) 13// noexcept(!allocator_type::propagate_on_container_swap::value || 14// __is_nothrow_swappable<allocator_type>::value); 15 16// This tests a conforming extension 17 18#include <set> 19#include <cassert> 20 21#include "../../../MoveOnly.h" 22#include "test_allocator.h" 23 24template <class T> 25struct some_comp 26{ 27 typedef T value_type; 28 29 some_comp() {} 30 some_comp(const some_comp&) {} 31 void deallocate(void*, unsigned) {} 32 33 typedef std::true_type propagate_on_container_swap; 34}; 35 36int main() 37{ 38#if __has_feature(cxx_noexcept) 39 { 40 typedef std::multiset<MoveOnly> C; 41 C c1, c2; 42 static_assert(noexcept(swap(c1, c2)), ""); 43 } 44 { 45 typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; 46 C c1, c2; 47 static_assert(noexcept(swap(c1, c2)), ""); 48 } 49 { 50 typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; 51 C c1, c2; 52 static_assert(noexcept(swap(c1, c2)), ""); 53 } 54 { 55 typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; 56 C c1, c2; 57 static_assert(!noexcept(swap(c1, c2)), ""); 58 } 59#endif 60} 61