////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2025-2025. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_CONTAINER_DEQUE_HPP #define BOOST_CONTAINER_DEQUE_HPP #ifndef BOOST_CONFIG_HPP # include #endif #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include //move #include // container #include #include #include #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #include #endif namespace boost { namespace container { #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED //! A double-ended queue is a sequence that supports random access to elements, constant time insertion //! and removal of elements at the end of the sequence, and linear time insertion and removal of elements in the middle. //! //! \tparam T The type of object that is stored in the deque //! \tparam A The allocator used for all internal memory management, use void //! for the default allocator //! \tparam Options A type produced from \c boost::container::deque_options. template #else template #endif class deque : public deque_impl { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED BOOST_COPYABLE_AND_MOVABLE(deque) private: typedef deque_impl base_type; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: ////////////////////////////////////////////// // // types // ////////////////////////////////////////////// typedef T value_type; typedef typename base_type::allocator_type allocator_type; typedef typename base_type::pointer pointer; typedef typename base_type::const_pointer const_pointer; typedef typename base_type::reference reference; typedef typename base_type::const_reference const_reference; typedef typename base_type::size_type size_type; typedef typename base_type::difference_type difference_type; typedef typename base_type::stored_allocator_type stored_allocator_type; typedef typename base_type::iterator iterator; typedef typename base_type::const_iterator const_iterator; typedef typename base_type::reverse_iterator reverse_iterator; typedef typename base_type::const_reverse_iterator const_reverse_iterator; #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED using base_type::get_block_size; using base_type::get_segment_size; using base_type::is_reservable; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED ////////////////////////////////////////////// // // construct/copy/destroy // ////////////////////////////////////////////// //! Effects: Default constructors a deque. //! //! Throws: If allocator_type's default constructor throws. //! //! Complexity: Constant. inline deque() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible::value) : base_type() {} //! Effects: Constructs a deque taking the allocator as parameter. //! //! Throws: Nothing //! //! Complexity: Constant. inline explicit deque(const allocator_type& a) BOOST_NOEXCEPT_OR_NOTHROW : base_type(a) {} //! Effects: Constructs a deque //! and inserts n value initialized values. //! //! Throws: If allocator_type's default constructor //! throws or T's value initialization throws. //! //! Complexity: Linear to n. inline explicit deque(size_type n) : base_type(n) {} //! Effects: Constructs a deque //! and inserts n default initialized values. //! //! Throws: If allocator_type's default constructor //! throws or T's default initialization or copy constructor throws. //! //! Complexity: Linear to n. //! //! Note: Non-standard extension inline deque(size_type n, default_init_t) : base_type(n, default_init) {} //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts n value initialized values. //! //! Throws: If allocator_type's default constructor //! throws or T's value initialization throws. //! //! Complexity: Linear to n. inline explicit deque(size_type n, const allocator_type &a) : base_type(n, a) {} //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts n default initialized values. //! //! Throws: If allocator_type's default constructor //! throws or T's default initialization or copy constructor throws. //! //! Complexity: Linear to n. //! //! Note: Non-standard extension inline deque(size_type n, default_init_t, const allocator_type &a) : base_type(n, default_init, a) {} //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts n copies of value. //! //! Throws: If allocator_type's default constructor //! throws or T's copy constructor throws. //! //! Complexity: Linear to n. inline deque(size_type n, const value_type& value) : base_type(n, value) {} //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts n copies of value. //! //! Throws: If allocator_type's default constructor //! throws or T's copy constructor throws. //! //! Complexity: Linear to n. inline deque(size_type n, const value_type& value, const allocator_type& a) : base_type(n, value, a) {} //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts a copy of the range [first, last) in the deque. //! //! Throws: If allocator_type's default constructor //! throws or T's constructor taking a dereferenced InIt throws. //! //! Complexity: Linear to the range [first, last). template inline deque(InIt first, InIt last #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) , typename dtl::disable_if_convertible ::type * = 0 #endif ) : base_type(first, last) {} //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts a copy of the range [first, last) in the deque. //! //! Throws: If allocator_type's default constructor //! throws or T's constructor taking a dereferenced InIt throws. //! //! Complexity: Linear to the range [first, last). template inline deque(InIt first, InIt last, const allocator_type& a #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) , typename dtl::disable_if_convertible ::type * = 0 #endif ) : base_type(first, last, a) {} #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts a copy of the range [il.begin(), il.end()) in the deque. //! //! Throws: If allocator_type's default constructor //! throws or T's constructor taking a dereferenced std::initializer_list iterator throws. //! //! Complexity: Linear to the range [il.begin(), il.end()). inline deque(std::initializer_list il, const allocator_type& a = allocator_type()) : base_type(il, a) {} #endif //! Effects: Copy constructs a deque. //! //! Postcondition: x == *this. //! //! Complexity: Linear to the elements x contains. inline deque(const deque& x) : base_type(x) {} //! Effects: Move constructor. Moves x's resources to *this. //! //! Throws: If allocator_type's copy constructor throws. //! //! Complexity: Constant. inline deque(BOOST_RV_REF(deque) x) BOOST_NOEXCEPT_OR_NOTHROW : base_type(boost::move(static_cast(x))) {} //! Effects: Copy constructs a vector using the specified allocator. //! //! Postcondition: x == *this. //! //! Throws: If allocation //! throws or T's copy constructor throws. //! //! Complexity: Linear to the elements x contains. deque(const deque& x, const allocator_type &a) : base_type(x, a) {} //! Effects: Move constructor using the specified allocator. //! Moves x's resources to *this if a == allocator_type(). //! Otherwise copies values from x to *this. //! //! Throws: If allocation or T's copy constructor throws. //! //! Complexity: Constant if a == x.get_allocator(), linear otherwise. deque(BOOST_RV_REF(deque) x, const allocator_type &a) : base_type(boost::move(static_cast(x)), a) {} //! Effects: Destroys the deque. All stored values are destroyed //! and used memory is deallocated. //! //! Throws: Nothing. //! //! Complexity: Linear to the number of elements. inline ~deque() BOOST_NOEXCEPT_OR_NOTHROW {} //! Effects: Makes *this contain the same elements as x. //! //! Postcondition: this->size() == x.size(). *this contains a copy //! of each of x's elements. //! //! Throws: If memory allocation throws or T's copy constructor throws. //! //! Complexity: Linear to the number of elements in x. deque& operator= (BOOST_COPY_ASSIGN_REF(deque) x) { base_type::operator=(static_cast(x)); return *this; } //! Effects: Move assignment. All x's values are transferred to *this. //! //! Throws: If allocator_traits_type::propagate_on_container_move_assignment //! is false and (allocation throws or value_type's move constructor throws) //! //! Complexity: Constant if allocator_traits_type:: //! propagate_on_container_move_assignment is true or //! this->get_allocator() == x.get_allocator(). Linear otherwise. deque& operator= (BOOST_RV_REF(deque) x) BOOST_NOEXCEPT_IF(allocator_traits::propagate_on_container_move_assignment::value || allocator_traits::is_always_equal::value) { base_type::operator=(BOOST_MOVE_BASE(base_type, x)); return *this; } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! Effects: Makes *this contain the same elements as il. //! //! Postcondition: this->size() == il.size(). *this contains a copy //! of each of il's elements. //! //! Throws: If memory allocation throws or T's copy constructor throws. //! //! Complexity: Linear to the number of elements in il. inline deque& operator=(std::initializer_list il) { base_type::operator=(il); return *this; } #endif #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED //! Effects: Returns the number of continguous elements per segment/block. //! Same as get_block_size(). //! //! Throws: Nothing. //! //! Complexity: Constant. static size_type get_segment_size() BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns the number of continguous elements per segment/block. //! Same as get_segment_size(). //! //! Throws: Nothing. //! //! Complexity: Constant. static size_type get_block_size() BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Assigns the n copies of val to *this. //! //! Throws: If memory allocation throws or T's copy constructor throws. //! //! Complexity: Linear to n. void assign(size_type n, const value_type& val); //! Effects: Assigns the the range [first, last) to *this. //! //! Throws: If memory allocation throws or //! T's constructor from dereferencing InIt throws. //! //! Complexity: Linear to n. template void assign(InputIterator first, InputIterator last); //! Effects: Assigns the the range [il.begin(), il.end()) to *this. //! //! Throws: If memory allocation throws or //! T's constructor from dereferencing std::initializer_list iterator throws. //! //! Complexity: Linear to il.size(). void assign(std::initializer_list il); //! Effects: Returns a copy of the internal allocator. //! //! Throws: If allocator's copy constructor throws. //! //! Complexity: Constant. allocator_type get_allocator() const; //! Effects: Returns a reference to the internal allocator. //! //! Throws: Nothing //! //! Complexity: Constant. //! //! Note: Non-standard extension. const stored_allocator_type& get_stored_allocator() const; //! Effects: Returns a reference to the internal allocator. //! //! Throws: Nothing //! //! Complexity: Constant. //! //! Note: Non-standard extension. stored_allocator_type& get_stored_allocator(); ////////////////////////////////////////////// // // iterators // ////////////////////////////////////////////// //! Effects: Returns an iterator to the first element contained in the deque. //! //! Throws: Nothing. //! //! Complexity: Constant. iterator begin() noexcept; //! Effects: Returns a const_iterator to the first element contained in the deque. //! //! Throws: Nothing. //! //! Complexity: Constant. const_iterator begin() const noexcept; //! Effects: Returns an iterator to the end of the deque. //! //! Throws: Nothing. //! //! Complexity: Constant. iterator end() noexcept; //! Effects: Returns a const_iterator to the end of the deque. //! //! Throws: Nothing. //! //! Complexity: Constant. const_iterator end() const noexcept; //! Effects: Returns a reverse_iterator pointing to the beginning //! of the reversed deque. //! //! Throws: Nothing. //! //! Complexity: Constant. reverse_iterator rbegin() noexcept; //! Effects: Returns a const_reverse_iterator pointing to the beginning //! of the reversed deque. //! //! Throws: Nothing. //! //! Complexity: Constant. const_reverse_iterator rbegin() const noexcept; //! Effects: Returns a reverse_iterator pointing to the end //! of the reversed deque. //! //! Throws: Nothing. //! //! Complexity: Constant. reverse_iterator rend() noexcept; //! Effects: Returns a const_reverse_iterator pointing to the end //! of the reversed deque. //! //! Throws: Nothing. //! //! Complexity: Constant. const_reverse_iterator rend() const noexcept; //! Effects: Returns a const_iterator to the first element contained in the deque. //! //! Throws: Nothing. //! //! Complexity: Constant. const_iterator cbegin() const noexcept; //! Effects: Returns a const_iterator to the end of the deque. //! //! Throws: Nothing. //! //! Complexity: Constant. const_iterator cend() const noexcept; //! Effects: Returns a const_reverse_iterator pointing to the beginning //! of the reversed deque. //! //! Throws: Nothing. //! //! Complexity: Constant. const_reverse_iterator crbegin() const noexcept; //! Effects: Returns a const_reverse_iterator pointing to the end //! of the reversed deque. //! //! Throws: Nothing. //! //! Complexity: Constant. const_reverse_iterator crend() const noexcept; ////////////////////////////////////////////// // // capacity // ////////////////////////////////////////////// //! Effects: Returns true if the deque contains no elements. //! //! Throws: Nothing. //! //! Complexity: Constant. bool empty() const noexcept; //! Effects: Returns the number of the elements contained in the deque. //! //! Throws: Nothing. //! //! Complexity: Constant. size_type size() const noexcept; //! Effects: Returns the number of the elements that can be inserted //! at the back without allocating additional memory. //! //! Throws: Nothing. //! //! Complexity: Constant. //! //! Note: Non-standard extension. size_type back_capacity() const noexcept; //! Effects: Returns the number of the elements that can be inserted //! at the front without allocating additional memory. //! //! Throws: Nothing. //! //! Complexity: Constant. //! //! Note: Non-standard extension. size_type front_capacity() const noexcept; //! Requires: The container must be "reservable" (is_reservable == true) //! //! Effects: If n is less than or equal to back_capacity() or the container is not reservable, //! this call has no effect. Otherwise, if it is a request for allocation of additional memory. //! If the request is successful, then back_capacity() is greater than or equal to //! n; otherwise, back_capacity() is unchanged. In either case, size() is unchanged. //! //! Throws: If memory allocation throws. //! //! Complexity: Linear to n. //! //! Note: Non-standard extension. void reserve_back(size_type n); //! Requires: The container must be "reservable" (is_reservable == true) //! //! Effects: If n is less than or equal to front_capacity() or the container is not reservable, //! this call has no effect. Otherwise, it is a request for allocation of additional memory. //! If the request is successful, then front_capacity() is greater than or equal to //! n; otherwise, front_capacity() is unchanged. In either case, size() is unchanged. //! //! Throws: If memory allocation throws. //! //! Complexity: Linear to n. //! //! Note: Non-standard extension. void reserve_front(size_type n); //! Effects: Returns the largest possible size of the deque. //! //! Throws: Nothing. //! //! Complexity: Constant. size_type max_size() const noexcept; //! Effects: Inserts or erases elements at the end such that //! the size becomes n. New elements are value initialized. //! //! Throws: If memory allocation throws, or T's constructor throws. //! //! Complexity: Linear to the difference between size() and new_size. void resize(size_type new_size); //! Effects: Inserts or erases elements at the end such that //! the size becomes n. New elements are copy constructed from x. //! //! Throws: If memory allocation throws, or T's copy constructor throws. //! //! Complexity: Linear to the difference between size() and new_size. void resize(size_type new_size, const value_type& x); //! Effects: Tries to deallocate the excess of memory created //! with previous allocations. The size of the deque is unchanged //! //! Throws: If memory allocation throws. //! //! Complexity: Constant. void shrink_to_fit(); ////////////////////////////////////////////// // // element access // ////////////////////////////////////////////// //! Requires: !empty() //! //! Effects: Returns a reference to the first //! element of the container. //! //! Throws: Nothing. //! //! Complexity: Constant. reference front(); //! Requires: !empty() //! //! Effects: Returns a const reference to the first element //! from the beginning of the container. //! //! Throws: Nothing. //! //! Complexity: Constant. const_reference front() const; //! Requires: !empty() //! //! Effects: Returns a reference to the last //! element of the container. //! //! Throws: Nothing. //! //! Complexity: Constant. reference back(); //! Requires: !empty() //! //! Effects: Returns a const reference to the last //! element of the container. //! //! Throws: Nothing. //! //! Complexity: Constant. const_reference back() const; //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element //! from the beginning of the container. //! //! Throws: Nothing. //! //! Complexity: Constant. reference operator[](size_type n); //! Requires: size() > n. //! //! Effects: Returns a const reference to the nth element //! from the beginning of the container. //! //! Throws: Nothing. //! //! Complexity: Constant. const_reference operator[](size_type n) const; //! Requires: size() >= n. //! //! Effects: Returns an iterator to the nth element //! from the beginning of the container. Returns end() //! if n == size(). //! //! Throws: Nothing. //! //! Complexity: Constant. //! //! Note: Non-standard extension iterator nth(size_type n); //! Requires: size() >= n. //! //! Effects: Returns a const_iterator to the nth element //! from the beginning of the container. Returns end() //! if n == size(). //! //! Throws: Nothing. //! //! Complexity: Constant. //! //! Note: Non-standard extension const_iterator nth(size_type n) const; //! Requires: begin() <= p <= end(). //! //! Effects: Returns the index of the element pointed by p //! and size() if p == end(). //! //! Throws: Nothing. //! //! Complexity: Constant. //! //! Note: Non-standard extension size_type index_of(iterator p); //! Requires: begin() <= p <= end(). //! //! Effects: Returns the index of the element pointed by p //! and size() if p == end(). //! //! Throws: Nothing. //! //! Complexity: Constant. //! //! Note: Non-standard extension size_type index_of(const_iterator p) const; //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element //! from the beginning of the container. //! //! Throws: range_error if n >= size() //! //! Complexity: Constant. reference at(size_type n); //! Requires: size() > n. //! //! Effects: Returns a const reference to the nth element //! from the beginning of the container. //! //! Throws: range_error if n >= size() //! //! Complexity: Constant. const_reference at(size_type n) const; ////////////////////////////////////////////// // // modifiers // ////////////////////////////////////////////// //! Effects: Inserts an object of type T constructed with //! std::forward(args)... in the beginning of the deque. //! //! Returns: A reference to the created object. //! //! Throws: If memory allocation throws or the in-place constructor throws. //! //! Complexity: Amortized constant time template reference emplace_front(Args&&... args); //! Effects: Inserts an object of type T constructed with //! std::forward(args)... in the end of the deque. //! //! Returns: A reference to the created object. //! //! Throws: If memory allocation throws or the in-place constructor throws. //! //! Complexity: Amortized constant time template reference emplace_back(Args&&... args); //! Requires: p must be a valid iterator of *this. //! //! Effects: Inserts an object of type T constructed with //! std::forward(args)... before p //! //! Throws: If memory allocation throws or the in-place constructor throws. //! //! Complexity: If p is end() or begin(), amortized constant time //! Linear time otherwise. template iterator emplace(const_iterator p, Args&&... args); //! Effects: Inserts a copy of x at the front of the deque. //! //! Throws: If memory allocation throws or //! T's copy constructor throws. //! //! Complexity: Amortized constant time. void push_front(const value_type& x); //! Effects: Constructs a new element in the front of the deque //! and moves the resources of x to this new element. //! //! Throws: If memory allocation throws. //! //! Complexity: Amortized constant time. void push_front(value_type&& x); //! Effects: Inserts a copy of x at the end of the deque. //! //! Throws: If memory allocation throws or //! T's copy constructor throws. //! //! Complexity: Amortized constant time. void push_back(const value_type& x); //! Effects: Constructs a new element in the end of the deque //! and moves the resources of x to this new element. //! //! Throws: If memory allocation throws. //! //! Complexity: Amortized constant time. void push_back(value_type&& x); //! Requires: p must be a valid iterator of *this. //! //! Effects: Insert a copy of x before p. //! //! Returns: an iterator to the inserted element. //! //! Throws: If memory allocation throws or x's copy constructor throws. //! //! Complexity: If p is end() or begin(), amortized constant time //! Linear time otherwise. iterator insert(const_iterator p, const T &x); //! Requires: p must be a valid iterator of *this. //! //! Effects: Insert a new element before p with x's resources. //! //! Returns: an iterator to the inserted element. //! //! Throws: If memory allocation throws. //! //! Complexity: If p is end() or begin(), amortized constant time //! Linear time otherwise. iterator insert(const_iterator p, T &&x); //! Requires: pos must be a valid iterator of *this. //! //! Effects: Insert n copies of x before pos. //! //! Returns: an iterator to the first inserted element or pos if n is 0. //! //! Throws: If memory allocation throws or T's copy constructor throws. //! //! Complexity: Linear to n. inline iterator insert(const_iterator pos, size_type n, const value_type& x); //! Requires: pos must be a valid iterator of *this. //! //! Effects: Insert a copy of the [first, last) range before pos. //! //! Returns: an iterator to the first inserted element or pos if first == last. //! //! Throws: If memory allocation throws, T's constructor from a //! dereferenced InIt throws or T's copy constructor throws. //! //! Complexity: Linear to distance [first, last). template iterator insert(const_iterator pos, InIt first, InIt last); //! Requires: pos must be a valid iterator of *this. //! //! Effects: Insert a copy of the [il.begin(), il.end()) range before pos. //! //! Returns: an iterator to the first inserted element or pos if il.begin() == il.end(). //! //! Throws: If memory allocation throws, T's constructor from a //! dereferenced std::initializer_list throws or T's copy constructor throws. //! //! Complexity: Linear to distance [il.begin(), il.end()). iterator insert(const_iterator pos, std::initializer_list il); //! Effects: Removes the first element from the deque. //! //! Throws: Nothing. //! //! Complexity: Constant time. void pop_front(); //! Effects: Removes the last element from the deque. //! //! Throws: Nothing. //! //! Complexity: Constant time. void pop_back(); //! Effects: Erases the element at p. //! //! Throws: Nothing. //! //! Complexity: Linear to the elements between pos and the //! last element (if pos is near the end) or the first element //! if(pos is near the beginning). //! Constant if pos is the first or the last element. //! Effects: Erases the elements pointed by [first, last). //! //! Throws: Nothing. //! //! Complexity: Linear to the distance between first and //! last plus the elements between pos and the //! last element (if pos is near the end) or the first element //! if(pos is near the beginning). iterator erase(const_iterator first, const_iterator last); //! Effects: Swaps the contents of *this and x. //! //! Throws: Nothing. //! //! Complexity: Constant. void swap(deque& x); //! Effects: Erases all the elements of the deque. //! //! Throws: Nothing. //! //! Complexity: Linear to the number of elements in the deque. void clear(); #endif // BOOST_CONTAINER_DOXYGEN_INVOKED //! Effects: Returns true if x and y are equal //! //! Complexity: Linear to the number of elements in the container. BOOST_CONTAINER_NODISCARD inline friend bool operator==(const deque& x, const deque& y) { return static_cast(x) == static_cast(y); } //! Effects: Returns true if x and y are unequal //! //! Complexity: Linear to the number of elements in the container. BOOST_CONTAINER_NODISCARD inline friend bool operator!=(const deque& x, const deque& y) { return static_cast(x) != static_cast(y); } //! Effects: Returns true if x is less than y //! //! Complexity: Linear to the number of elements in the container. BOOST_CONTAINER_NODISCARD inline friend bool operator<(const deque& x, const deque& y) { return static_cast(x) < static_cast(y); } //! Effects: Returns true if x is greater than y //! //! Complexity: Linear to the number of elements in the container. BOOST_CONTAINER_NODISCARD inline friend bool operator>(const deque& x, const deque& y) { return static_cast(x) > static_cast(y); } //! Effects: Returns true if x is equal or less than y //! //! Complexity: Linear to the number of elements in the container. BOOST_CONTAINER_NODISCARD inline friend bool operator<=(const deque& x, const deque& y) { return static_cast(x) <= static_cast(y); } //! Effects: Returns true if x is equal or greater than y //! //! Complexity: Linear to the number of elements in the container. BOOST_CONTAINER_NODISCARD inline friend bool operator>=(const deque& x, const deque& y) { return static_cast(x) >= static_cast(y); } //! Effects: x.swap(y) //! //! Complexity: Constant. inline friend void swap(deque& x, deque& y) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT(x.swap(y))) { static_cast(x).swap(static_cast(y)); } }; #ifndef BOOST_CONTAINER_NO_CXX17_CTAD template deque(InputIterator, InputIterator) -> deque::value_type>; template deque(InputIterator, InputIterator, Allocator const&) -> deque::value_type, Allocator>; #endif //! Effects: Erases all elements that compare equal to v from the container c. //! //! Complexity: Linear. template inline typename deque::size_type erase(deque& c, const U& v) { typename deque::size_type old_size = c.size(); c.erase(boost::container::remove(c.begin(), c.end(), v), c.end()); return old_size - c.size(); } //! Effects: Erases all elements that satisfy the predicate pred from the container c. //! //! Complexity: Linear. template inline typename deque::size_type erase_if(deque& c, Pred pred) { typename deque::size_type old_size = c.size(); c.erase(boost::container::remove_if(c.begin(), c.end(), pred), c.end()); return old_size - c.size(); } } //namespace container } //namespace boost #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED namespace boost { template struct has_trivial_destructor_after_move > : has_trivial_destructor_after_move > {}; } //namespace boost { #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #include #endif // #ifndef BOOST_CONTAINER_DEQUE_HPP