Audio Processing Framework (APF)  version 0.3.0
Public Member Functions | List of all members
apf::fixed_vector< T, Allocator > Class Template Reference

Derived from std::vector, but without memory re-allocations. More...

#include <apf/container.h>

Inheritance diagram for apf::fixed_vector< T, Allocator >:
Inheritance graph
[legend]

Public Member Functions

 fixed_vector (fixed_vector &&)=default
 
 fixed_vector (const fixed_vector &)=delete
 
fixed_vectoroperator= (const fixed_vector &)=delete
 
fixed_vectoroperator= (fixed_vector &&)=delete
 
template<typename... Args, typename = internal::if_first_not_integral<Args...>>
 fixed_vector (Args &&...args)
 Constructor that forwards everything except if first type is integral. More...
 
 fixed_vector (size_type n)
 
template<typename Size , typename Arg , typename = internal::if_integral<Size>>
 fixed_vector (Size n, Arg &&arg, const Allocator &a)
 
template<typename Size , typename... Args, typename = internal::if_integral<Size>, typename = internal::if_last_not_convertible<Allocator, Args...>>
 fixed_vector (Size n, Args &&...args)
 Constructor from size and initialization arguments. More...
 
 fixed_vector (std::initializer_list< value_type > il, const Allocator &a=Allocator())
 
void resize (size_type n)
 Reserve space for new elements and default-construct them. More...
 
void reserve (size_type n)
 Reserve space for new elements. More...
 
template<typename... Args>
void emplace_back (Args &&...args)
 Construct element at the end. More...
 

Detailed Description

template<typename T, typename Allocator = std::allocator<T>>
class apf::fixed_vector< T, Allocator >

Derived from std::vector, but without memory re-allocations.

Non-copyable types can be used as long as they are movable. Normally, the size is specified in the constructor and doesn't change ever. If you need to initialize the fixed_vector before you know its final size, there is one exception: You can initialize the fixed_vector with the default constructor, at a later time you can call reserve() and afterwards emplace_back(). In this case the size grows, but the memory is still never re-allocated.

Differences to std::vector:
  • There are slightly different constructors, especially one with a size-argument and further arbitrary arguments which are forwarded to the constructor of each element.
  • reserve() and emplace_back() have different semantics.
  • all other functions which (potentially) change size are disabled.

Definition at line 82 of file container.h.

Constructor & Destructor Documentation

template<typename T, typename Allocator = std::allocator<T>>
template<typename... Args, typename = internal::if_first_not_integral<Args...>>
apf::fixed_vector< T, Allocator >::fixed_vector ( Args &&...  args)
inlineexplicit

Constructor that forwards everything except if first type is integral.

Definition at line 110 of file container.h.

template<typename T, typename Allocator = std::allocator<T>>
template<typename Size , typename... Args, typename = internal::if_integral<Size>, typename = internal::if_last_not_convertible<Allocator, Args...>>
apf::fixed_vector< T, Allocator >::fixed_vector ( Size  n,
Args &&...  args 
)
inlineexplicit

Constructor from size and initialization arguments.

This can be used for initializing nested containers, for example.

Definition at line 136 of file container.h.

Member Function Documentation

template<typename T, typename Allocator = std::allocator<T>>
void apf::fixed_vector< T, Allocator >::resize ( size_type  n)
inline

Reserve space for new elements and default-construct them.

In contrast to std::vector::resize(), this can only be called once and only on an empty fixed_vector (i.e. iff capacity == 0). Thus, resize() will allocate memory, but never re-allocate.

Exceptions
std::logic_errorif capacity != 0

Definition at line 159 of file container.h.

template<typename T, typename Allocator = std::allocator<T>>
void apf::fixed_vector< T, Allocator >::reserve ( size_type  n)
inline

Reserve space for new elements.

In contrast to std::vector::reserve(), this can only be called once and only on an empty fixed_vector (i.e. iff capacity == 0). Thus, reserve() will allocate memory, but never re-allocate.

Exceptions
std::logic_errorif capacity != 0

Definition at line 178 of file container.h.

Referenced by apf::MimoProcessor< Derived, interface_policy, thread_policy, query_policy >::MimoProcessor().

template<typename T, typename Allocator = std::allocator<T>>
template<typename... Args>
void apf::fixed_vector< T, Allocator >::emplace_back ( Args &&...  args)
inline

Construct element at the end.

In contrast to std::vector::emplace_back() this can only be called after reserve() and at most as many times as specified in reserve() (and is typically called exactly as many times). Thus, memory will never be allocated.

Exceptions
std::logic_errorif capacity would be exceeded

Definition at line 199 of file container.h.

Referenced by apf::MimoProcessor< Derived, interface_policy, thread_policy, query_policy >::MimoProcessor().


The documentation for this class was generated from the following file: