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 // class map 13 14 // mapped_type& operator[](key_type&& k); 15 16 #include <map> 17 #include <cassert> 18 19 #include "test_macros.h" 20 #include "MoveOnly.h" 21 #include "min_allocator.h" 22 main()23int main() 24 { 25 #if TEST_STD_VER >= 11 26 { 27 std::map<MoveOnly, double> m; 28 assert(m.size() == 0); 29 assert(m[1] == 0.0); 30 assert(m.size() == 1); 31 m[1] = -1.5; 32 assert(m[1] == -1.5); 33 assert(m.size() == 1); 34 assert(m[6] == 0); 35 assert(m.size() == 2); 36 m[6] = 6.5; 37 assert(m[6] == 6.5); 38 assert(m.size() == 2); 39 } 40 { 41 typedef std::pair<MoveOnly, double> V; 42 std::map<MoveOnly, double, std::less<MoveOnly>, min_allocator<V>> m; 43 assert(m.size() == 0); 44 assert(m[1] == 0.0); 45 assert(m.size() == 1); 46 m[1] = -1.5; 47 assert(m[1] == -1.5); 48 assert(m.size() == 1); 49 assert(m[6] == 0); 50 assert(m.size() == 2); 51 m[6] = 6.5; 52 assert(m[6] == 6.5); 53 assert(m.size() == 2); 54 } 55 #endif 56 } 57