Back Access Container

Category: containers
Component type: concept


A Back Access Container is a Forward Container where it is possible to access, pop or destroy the last element in amortized constant time. Back Access Containers have special member functions as a shorthand for those operations.

Refinement of

Forward Container

Associated types

None, except for those of Forward Container.


X A type that is a model of Back Access Container
a Object of type X
T The value type of X
t Object of type T


Valid expressions

In addition to the expressions defined in Forward Container, the following expressions must be valid.

Name Expression Type requirements Return type
Back a.back()   reference if a is mutable, otherwise const_reference.
Pop back a.pop_back() a is mutable. void
Destroy back a.destroy_back() a is mutable. void

Expression semantics

Name Expression Precondition Semantics Postcondition
Back a.back() !a.empty() Equivalent to *(--a.end()).  
Pop back a.pop_back() !a.empty() Equivalent to a.erase(--a.end()) a.size() is decremented by 1.
Destroy back a.destroy_back() !a.empty() Equivalent to delete *(--a.end()); a.erase(--a.end()); a.size() is decremented by 1.

Complexity guarantees

Back, pop back and destroy back are amortized constant time. [1]



[1] This complexity guarantee is the only reason that back(), pop_back(), and destroy_back() are defined: they provide no additional functionality. Not every sequence must define these operations, but it is guaranteed that they are efficient if they exist at all.

See also

Container, Forward Container, Front Access Container, Front Access Container LOGN, Back Access Container LOGN.

 All Classes Files Functions Variables Typedefs