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 "../../../MoveOnly.h" 20 #include "min_allocator.h" 21 22 int main() 23 { 24 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 25 { 26 typedef std::pair<MoveOnly, double> V; 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 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 41 #if __cplusplus >= 201103L 42 { 43 typedef std::pair<MoveOnly, double> V; 44 std::map<MoveOnly, double, std::less<MoveOnly>, min_allocator<V>> m; 45 assert(m.size() == 0); 46 assert(m[1] == 0.0); 47 assert(m.size() == 1); 48 m[1] = -1.5; 49 assert(m[1] == -1.5); 50 assert(m.size() == 1); 51 assert(m[6] == 0); 52 assert(m.size() == 2); 53 m[6] = 6.5; 54 assert(m[6] == 6.5); 55 assert(m.size() == 2); 56 } 57 #endif 58 } 59