Home | History | Annotate | Download | only in list.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 // <list>
     11 
     12 // iterator insert(const_iterator position, value_type&& x);
     13 
     14 #if _LIBCPP_DEBUG >= 1
     15 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
     16 #endif
     17 
     18 #include <list>
     19 #include <cassert>
     20 
     21 #include "../../../MoveOnly.h"
     22 #include "min_allocator.h"
     23 
     24 int main()
     25 {
     26 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     27     {
     28     std::list<MoveOnly> l1;
     29     l1.insert(l1.cend(), MoveOnly(1));
     30     assert(l1.size() == 1);
     31     assert(l1.front() == MoveOnly(1));
     32     l1.insert(l1.cbegin(), MoveOnly(2));
     33     assert(l1.size() == 2);
     34     assert(l1.front() == MoveOnly(2));
     35     assert(l1.back() == MoveOnly(1));
     36     }
     37 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     38 #if _LIBCPP_DEBUG >= 1
     39     {
     40         std::list<int> v1(3);
     41         std::list<int> v2(3);
     42         v1.insert(v2.begin(), 4);
     43         assert(false);
     44     }
     45 #endif
     46 #if __cplusplus >= 201103L
     47 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     48     {
     49     std::list<MoveOnly, min_allocator<MoveOnly>> l1;
     50     l1.insert(l1.cend(), MoveOnly(1));
     51     assert(l1.size() == 1);
     52     assert(l1.front() == MoveOnly(1));
     53     l1.insert(l1.cbegin(), MoveOnly(2));
     54     assert(l1.size() == 2);
     55     assert(l1.front() == MoveOnly(2));
     56     assert(l1.back() == MoveOnly(1));
     57     }
     58 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     59 #if _LIBCPP_DEBUG >= 1
     60     {
     61         std::list<int, min_allocator<int>> v1(3);
     62         std::list<int, min_allocator<int>> v2(3);
     63         v1.insert(v2.begin(), 4);
     64         assert(false);
     65     }
     66 #endif
     67 #endif
     68 }
     69