Home | History | Annotate | Download | only in multimap.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 multimap
     13 
     14 // template <class P>
     15 //     iterator insert(const_iterator position, P&& p);
     16 
     17 #include <map>
     18 #include <cassert>
     19 
     20 #include "../../../MoveOnly.h"
     21 #include "min_allocator.h"
     22 
     23 int main()
     24 {
     25 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     26     {
     27         typedef std::multimap<int, MoveOnly> M;
     28         typedef std::pair<int, MoveOnly> P;
     29         typedef M::iterator R;
     30         M m;
     31         R r = m.insert(m.cend(), P(2, 2));
     32         assert(r == m.begin());
     33         assert(m.size() == 1);
     34         assert(r->first == 2);
     35         assert(r->second == 2);
     36 
     37         r = m.insert(m.cend(), P(1, 1));
     38         assert(r == m.begin());
     39         assert(m.size() == 2);
     40         assert(r->first == 1);
     41         assert(r->second == 1);
     42 
     43         r = m.insert(m.cend(), P(3, 3));
     44         assert(r == prev(m.end()));
     45         assert(m.size() == 3);
     46         assert(r->first == 3);
     47         assert(r->second == 3);
     48 
     49         r = m.insert(m.cend(), P(3, 2));
     50         assert(r == prev(m.end()));
     51         assert(m.size() == 4);
     52         assert(r->first == 3);
     53         assert(r->second == 2);
     54     }
     55 #if __cplusplus >= 201103L
     56     {
     57         typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
     58         typedef std::pair<int, MoveOnly> P;
     59         typedef M::iterator R;
     60         M m;
     61         R r = m.insert(m.cend(), P(2, 2));
     62         assert(r == m.begin());
     63         assert(m.size() == 1);
     64         assert(r->first == 2);
     65         assert(r->second == 2);
     66 
     67         r = m.insert(m.cend(), P(1, 1));
     68         assert(r == m.begin());
     69         assert(m.size() == 2);
     70         assert(r->first == 1);
     71         assert(r->second == 1);
     72 
     73         r = m.insert(m.cend(), P(3, 3));
     74         assert(r == prev(m.end()));
     75         assert(m.size() == 3);
     76         assert(r->first == 3);
     77         assert(r->second == 3);
     78 
     79         r = m.insert(m.cend(), P(3, 2));
     80         assert(r == prev(m.end()));
     81         assert(m.size() == 4);
     82         assert(r->first == 3);
     83         assert(r->second == 2);
     84     }
     85 #endif
     86 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     87 }
     88