A double-ended sequence with efficient insertion and removal at either end.
Standard-style names retain their familiar container meaning. The notes below explain lookup results, mutation, ownership, and Catalyst conveniences; only entirely obvious operations are left as declarations.
Exceptions escaping container operations are translated to CError. Direct iterator operations, element references, and calls through .std() follow the underlying type’s contracts.
CDeque
template <class T, class Alloc = std::allocator<T>> class CDeque
Types, constants & data
using Deque = std::deque<T, Alloc>;
using reference = typename Deque::reference;
using const_reference = typename Deque::const_reference;
using pointer = typename Deque::pointer;
using const_pointer = typename Deque::const_pointer;
using allocator_type = Alloc;
using iterator = typename Deque::iterator;
using const_iterator = typename Deque::const_iterator;
using size_type = typename Deque::size_type;
using difference_type = typename Deque::difference_type;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
Methods
CDeque() noexcept(std::is_nothrow_default_constructible_v<Deque>);
explicit CDeque(const allocator_type& a);
explicit CDeque(size_type n, const Alloc& alloc = cContainerDefault<Alloc>());
CDeque(size_type n, const T& v);
CDeque(size_type n, const T& v, const allocator_type& a);
template<CInputIterator InputIterator> CDeque(InputIterator f, InputIterator l);
template<CInputIterator InputIterator> CDeque(InputIterator f, InputIterator l, const allocator_type& a);
CDeque(const CDeque& c);
CDeque(const Deque& c);
CDeque(CDeque&& c) noexcept(std::is_nothrow_move_constructible_v<Deque>);
CDeque(Deque&& c) noexcept(std::is_nothrow_move_constructible_v<Deque>);
CDeque(std::initializer_list<value_type> il, const Alloc& a = cContainerDefault<allocator_type>());
CDeque(const CDeque& c, const std::type_identity_t<Alloc>& a);
CDeque(CDeque&& c, const std::type_identity_t<Alloc>& a);
CDeque(const Deque& c, const std::type_identity_t<Alloc>& a);
CDeque(Deque&& c, const std::type_identity_t<Alloc>& a);
template<CContainerRange<T> R> CDeque(std::from_range_t, R&& range, const Alloc& alloc = cContainerDefault<Alloc>());
CDeque(CBuffer& b);
Creates an empty sequence, copies a range or initializer list, or creates n elements with an optional repeated value. The count constructor changes size rather than merely reserving capacity; the CBuffer overload restores a typed serialized sequence.
template<class... Args> static CDeque fromArgs(Args&&... args);
Builds a container with one element per argument, in argument order. Arguments are forwarded so move-only values can be supplied as rvalues.
static CDeque range(int64_t a, int64_t b);
static CDeque range(size_t size);
Builds consecutive values in [a, b), or [0, size) for the one-argument form. These overloads require a nonempty range (a < b).
CDeque& operator=(const CDeque& c);
CDeque& operator=(CDeque&& c) noexcept(std::is_nothrow_move_assignable_v<Deque>);
CDeque& operator=(const Deque& c);
CDeque& operator=(Deque&& c) noexcept(std::is_nothrow_move_assignable_v<Deque>);
CDeque& operator=(std::initializer_list<value_type> il);
template<CInputIterator InputIterator> void assign(InputIterator f, InputIterator l);
void assign(size_type n, const T& v);
void assign(std::initializer_list<value_type> il);
Replaces all elements with the supplied count/value, iterator range, or initializer list. Existing element references and iterators may be invalidated.
Replaces the contents with the elements of a C++ range. Each range element must be convertible to the container element type.
iterator begin() noexcept;
const_iterator begin() const noexcept;
const_iterator cbegin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
const_iterator cend() const noexcept;
reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
const_reverse_iterator crbegin() const noexcept;
reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_reverse_iterator crend() const noexcept;
cspan span() const noexcept;
cspan span(size_t start) const noexcept;
cspan span(size_t start, size_t endOffset) const noexcept;
Returns an index range. start skips initial indices; endOffset excludes that many indices at the end.
bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
Requests release of unused capacity. The underlying container may retain capacity, and storage relocation can invalidate existing references and iterators.
T& operator[](size_type i);
const T& operator[](size_type i) const;
Returns the element at a zero-based index. The index must be below size(); this is not a checked, recoverable out-of-range lookup.
T& at(size_type i);
const T& at(size_type i) const;
Returns the element at a zero-based index. An invalid index raises COutOfRangeError.
T& front() noexcept(noexcept(q_.front()));
const T& front() const noexcept(noexcept(q_.front()));
Returns the first element by reference. The container must be nonempty.
T& back() noexcept(noexcept(q_.back()));
const T& back() const noexcept(noexcept(q_.back()));
T& back(size_t i);
const T& back(size_t i) const;
Returns the last element, or the element i positions before it: back(0) is the last element. The container must contain the requested element.
iterator find(const T& v);
Returns an iterator to the first equal element, or end() when absent. The search is linear.
size_t indexOf(const T& v) const;
Returns the matching index, or size() if no element matches.
bool hasIndex(size_t i) const;
Tests whether the index is below size(), without accessing or adding an element.
bool has(const T& v) const;
Reports whether an equal element occurs in the container.
iterator insert(const_iterator p, const T& v);
iterator insert(iterator p, const T& v);
iterator insert(const_iterator p, T&& v);
iterator insert(iterator p, T&& v);
iterator insert(const_iterator p, size_type n, const T& v);
iterator insert(iterator p, size_type n, const T& v);
template<CInputIterator InputIterator> iterator insert(const_iterator p, InputIterator f, InputIterator l);
template<CInputIterator InputIterator> iterator insert(iterator p, InputIterator f, InputIterator l);
iterator insert(const_iterator p, std::initializer_list<value_type> il);
iterator insert(iterator p, std::initializer_list<value_type> il);
iterator insert(size_t index, const T& v);
Inserts before a valid position or index; an index equal to size() appends. Returns the iterator to the inserted element or the first element of an inserted range.
template<CContainerRange<T> R> iterator insert_range(const_iterator position, R&& range);
Inserts the elements of a C++ range before the supplied iterator. Returns an iterator to the first inserted element, or the insertion position for an empty range.
template<class... Args> iterator emplace(const_iterator p, Args&&... args);
Constructs an element before the given position from forwarded constructor arguments. Returns its iterator.
void put(size_t i, const T& v);
void put(size_t i, T&& v);
Assigns an element by index, first growing the container to i + 1 when necessary. Any intervening new elements are value-initialized.
template<class S> CDeque& operator<<(S&& v);
Appends one element and returns this container, allowing chained appends.
void push_back(const T& v);
void push_back(T&& v);
template<class... Args> reference emplace_back(Args&&... args);
Constructs an element at the end from forwarded constructor arguments and returns a reference to it.
Appends the supplied container’s elements in order. The original contents remain at the beginning.
Adds a C++ range at the end, preserving the order of its elements. Existing contents remain at the beginning.
void push_front(const T& v);
void push_front(T&& v);
template<class... Args> reference emplace_front(Args&&... args);
Constructs an element at the beginning from forwarded constructor arguments and returns a reference to it.
Adds a C++ range at the beginning, preserving the range’s order before the existing elements.
iterator erase(const_iterator p);
iterator erase(const_iterator f, const_iterator l);
iterator erase(size_t index);
Removes the indexed element, the element at an iterator, or the half-open iterator range. Returns the iterator following the removed elements; indices and iterators must identify valid positions.
void pop_back() noexcept(noexcept(q_.back()));
Removes the last element without returning it. The container must be nonempty; use popBack() to retain its value.
Removes and returns the last element. The container must be nonempty.
void pop_front() noexcept(noexcept(q_.front()));
Removes the first element without returning it. The container must be nonempty; use popFront() to retain its value.
Removes and returns the first element. The container must be nonempty.
template<class S> void clearExcept(const S& s);
Removes every element for which s.has(element) is false. The surviving elements retain their relative order.
void resize(size_type n);
void resize(size_type n, const T& v);
Changes the number of elements, removing trailing elements or appending default/value-initialized elements. It changes size(), unlike reserve().
void swap(CDeque& c) noexcept(noexcept(q_.swap(c.q_)));
Deque& std() noexcept;
const Deque& std() const noexcept;
Returns a reference to the underlying standard container. Mutations affect this object directly; calls through that reference bypass Catalyst exception translation.
operator Deque&() noexcept;
Borrows the underlying container for interoperability. This does not copy storage; references and iterators follow that container’s lifetime and invalidation rules.
operator const Deque&() const noexcept;
Borrows the underlying container for interoperability. This does not copy storage; references and iterators follow that container’s lifetime and invalidation rules.
allocator_type get_allocator() const noexcept;
Appends the container to a CBuffer; restore it with the buffer-taking constructor.
Returns the stream-formatted representation as a cstr; this is display text rather than the binary storage format.