Alien-boost-mini

 view release on metacpan or  search on metacpan

include/boost/container/stable_vector.hpp  view on Meta::CPAN

   //!
   //! <b>Complexity</b>: If p is end(), amortized constant time
   //!   Linear time otherwise.
   iterator insert(const_iterator p, T &&x);
   #else
   BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator)
   #endif

   //! <b>Requires</b>: p must be a valid iterator of *this.
   //!
   //! <b>Effects</b>: Insert n copies of x before p.
   //!
   //! <b>Returns</b>: an iterator to the first inserted element or p if n is 0.
   //!
   //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
   //!
   //! <b>Complexity</b>: Linear to n.
   iterator insert(const_iterator p, size_type n, const T& t)
   {
      BOOST_ASSERT(this->priv_in_range_or_end(p));
      STABLE_VECTOR_CHECK_INVARIANT;
      typedef constant_iterator<value_type, difference_type> cvalue_iterator;
      return this->insert(p, cvalue_iterator(t, n), cvalue_iterator());
   }

   //! <b>Requires</b>: p must be a valid iterator of *this.
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
   //! <b>Requires</b>: p must be a valid iterator of *this.
   //!
   //! <b>Effects</b>: Insert a copy of the [il.begin(), il.end()) range before p.
   //!
   //! <b>Returns</b>: an iterator to the first inserted element or p if first == last.
   //!
   //! <b>Complexity</b>: Linear to distance [il.begin(), il.end()).
   iterator insert(const_iterator p, std::initializer_list<value_type> il)
   {
      //Position checks done by insert()
      STABLE_VECTOR_CHECK_INVARIANT;
      return insert(p, il.begin(), il.end());
   }
#endif

   //! <b>Requires</b>: pos must be a valid iterator of *this.
   //!
   //! <b>Effects</b>: Insert a copy of the [first, last) range before p.
   //!
   //! <b>Returns</b>: an iterator to the first inserted element or p if first == last.
   //!
   //! <b>Throws</b>: If memory allocation throws, T's constructor from a
   //!   dereferenced InpIt throws or T's copy constructor throws.
   //!
   //! <b>Complexity</b>: Linear to distance [first, last).
   template <class InputIterator>
   iterator insert(const_iterator p, InputIterator first, InputIterator last
         #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
         //Put this as argument instead of the return type as old GCC's like 3.4
         //detect this and the next disable_if_or as overloads
         ,  typename dtl::disable_if_or
               < void
               , dtl::is_convertible<InputIterator, size_type>
               , dtl::is_not_input_iterator<InputIterator>
               >::type* = 0
         #endif
         )
   {
      BOOST_ASSERT(this->priv_in_range_or_end(p));
      STABLE_VECTOR_CHECK_INVARIANT;
      const size_type pos_n = p - this->cbegin();
      for(; first != last; ++first){
         this->emplace(p, *first);
      }
      return this->begin() + pos_n;
   }

   #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
   template <class FwdIt>
   typename dtl::disable_if_or
      < iterator
      , dtl::is_convertible<FwdIt, size_type>
      , dtl::is_input_iterator<FwdIt>
      >::type
      insert(const_iterator p, FwdIt first, FwdIt last)
   {
      BOOST_ASSERT(this->priv_in_range_or_end(p));
      const size_type num_new = static_cast<size_type>(boost::container::iterator_distance(first, last));
      const size_type idx     = static_cast<size_type>(p - this->cbegin());
      if(num_new){
         //Fills the node pool and inserts num_new null pointers in idx.
         //If a new buffer was needed fixes up pointers up to idx so
         //past-new nodes are not aligned until the end of this function
         //or in a rollback in case of exception
         index_iterator it_past_newly_constructed(this->priv_insert_forward_non_templated(idx, num_new));
         const index_iterator it_past_new(it_past_newly_constructed + num_new);
         {
            //Prepare rollback
            insert_rollback rollback(*this, it_past_newly_constructed, it_past_new);
            while(first != last){
               const node_ptr n = this->priv_get_from_pool();
               BOOST_ASSERT(!!n);
               //Put it in the index so rollback can return it in pool if construct_in_place throws
               *it_past_newly_constructed = n;
               //Constructs and fixes up pointers This can throw
               this->priv_build_node_from_it(n, it_past_newly_constructed, first);
               ++first;
               ++it_past_newly_constructed;
            }
            //rollback.~insert_rollback() called in case of exception
         }
         //Fix up pointers for past-new nodes (new nodes were fixed during construction) and
         //nodes before insertion p in priv_insert_forward_non_templated(...)
         index_traits_type::fix_up_pointers_from(this->index, it_past_newly_constructed);
      }
      return this->begin() + idx;
   }
   #endif

   //! <b>Effects</b>: Removes the last element from the stable_vector.
   //!
   //! <b>Throws</b>: Nothing.
   //!
   //! <b>Complexity</b>: Constant time.



( run in 0.498 second using v1.01-cache-2.11-cpan-f6376fbd888 )