insert_const_lvalue.pass.cpp (1478B)
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_set> 11 12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, 13 // class Alloc = allocator<Value>> 14 // class unordered_multiset 15 16 // iterator insert(const value_type& x); 17 18 #include <unordered_set> 19 #include <cassert> 20 21 #include "min_allocator.h" 22 23 template<class Container> 24 void do_insert_const_lvalue_test() 25 { 26 typedef Container C; 27 typedef typename C::iterator R; 28 typedef typename C::value_type VT; 29 C c; 30 const VT v1(3.5); 31 R r = c.insert(v1); 32 assert(c.size() == 1); 33 assert(*r == 3.5); 34 35 r = c.insert(v1); 36 assert(c.size() == 2); 37 assert(*r == 3.5); 38 39 const VT v2(4.5); 40 r = c.insert(v2); 41 assert(c.size() == 3); 42 assert(*r == 4.5); 43 44 const VT v3(5.5); 45 r = c.insert(v3); 46 assert(c.size() == 4); 47 assert(*r == 5.5); 48 } 49 50 int main() 51 { 52 do_insert_const_lvalue_test<std::unordered_multiset<double> >(); 53 #if TEST_STD_VER >= 11 54 { 55 typedef std::unordered_multiset<double, std::hash<double>, 56 std::equal_to<double>, min_allocator<double>> C; 57 do_insert_const_lvalue_test<C>(); 58 } 59 #endif 60 }