Home | History | Annotate | Download | only in map.modifiers
      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 // template <class P>
     15 //   pair<iterator, bool> insert(P&& p);
     16 
     17 #include <map>
     18 #include <cassert>
     19 
     20 #include "../../../MoveOnly.h"
     21 
     22 int main()
     23 {
     24 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     25     {
     26         typedef std::map<int, MoveOnly> M;
     27         typedef std::pair<M::iterator, bool> R;
     28         M m;
     29         R r = m.insert(M::value_type(2, 2));
     30         assert(r.second);
     31         assert(r.first == m.begin());
     32         assert(m.size() == 1);
     33         assert(r.first->first == 2);
     34         assert(r.first->second == 2);
     35 
     36         r = m.insert(M::value_type(1, 1));
     37         assert(r.second);
     38         assert(r.first == m.begin());
     39         assert(m.size() == 2);
     40         assert(r.first->first == 1);
     41         assert(r.first->second == 1);
     42 
     43         r = m.insert(M::value_type(3, 3));
     44         assert(r.second);
     45         assert(r.first == prev(m.end()));
     46         assert(m.size() == 3);
     47         assert(r.first->first == 3);
     48         assert(r.first->second == 3);
     49 
     50         r = m.insert(M::value_type(3, 3));
     51         assert(!r.second);
     52         assert(r.first == prev(m.end()));
     53         assert(m.size() == 3);
     54         assert(r.first->first == 3);
     55         assert(r.first->second == 3);
     56     }
     57 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     58 }
     59