...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
deque
is a simple Bidirectional
Sequence that supports constant-time insertion and removal of elements
at both ends. Like the list
and cons
, deque
is more efficient than vector
(especially at compile time)
when the target sequence is constructed piecemeal (a data at a time, e.g.
when constructing expression templates). Like the list
and cons
, runtime cost of access to
each element is peculiarly constant (see Recursive
Inlined Functions).
Element insertion and removal are done by special deque
helper classes front_extended_deque
and back_extended_deque
.
#include <boost/fusion/container/deque.hpp> #include <boost/fusion/include/deque.hpp> #include <boost/fusion/container/list/deque_fwd.hpp> #include <boost/fusion/include/deque_fwd.hpp>
template <typename ...Elements> struct deque;
For C++11 compilers, the variadic class interface has no upper bound.
For C++03 compilers, the variadic class interface accepts 0
to FUSION_MAX_DEQUE_SIZE
elements, where FUSION_MAX_DEQUE_SIZE
is a user definable predefined maximum that defaults to 10
.
Example:
deque<int, char, double>
You may define the preprocessor constant FUSION_MAX_DEQUE_SIZE
before including any Fusion header to change the default. Example:
#define FUSION_MAX_DEQUE_SIZE 20
Parameter |
Description |
Default |
---|---|---|
|
Element types |
Notation
D
A deque
type
d
, d2
Instances of deque
e0
...en
Heterogeneous values
s
N
Semantics of an expression is defined only where it differs from, or is not defined in Bidirectional Sequence.
Expression |
Semantics |
---|---|
|
Creates a deque with default constructed elements. |
|
Creates a deque with elements |
|
Copy constructs a deque from a Forward
Sequence, |
|
Assigns to a deque, |
|
The Nth element from the beginning of the sequence; see |
deque<int, float> d(12, 5.5f); std::cout <<at_c
<0>(d) << std::endl; std::cout <<at_c
<1>(d) << std::endl;