Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template small_vector

boost::container::small_vector

Synopsis

// In header: <boost/container/small_vector.hpp>

template<typename T,  N, typename Allocator, 
         typename Options> 
class small_vector : public  {
public:

  // public member functions
  () ;
  ();
  ();
  (, );
  (, default_init_t);
  (, default_init_t, );
  (, );
  (, , );
  template<typename InIt> (, );
  template<typename InIt> (, , );
  (small_vector &);
  (small_vector &, );
  ();
  ();
  (small_vector &&) ;
  (small_vector &&, );
  (,  = );
  small_vector & (small_vector &);
  small_vector & 
  (small_vector &&) ;
  small_vector & ();
  small_vector & ();
   (small_vector &);
   ();
};

Description

small_vector is a vector-like container optimized for the case when it contains few elements. It contains some preallocated elements in-place, which can avoid the use of dynamic storage allocation when the actual number of elements is below that preallocated threshold.

small_vector<T, N, Allocator, Options> is convertible to small_vector_base<T, Allocator, Options> that is independent from the preallocated element capacity, so client code does not need to be templated on that N argument.

All boost::container::vector member functions are inherited. See vector documentation for details.

Any change to the capacity of the vector, including decreasing its size such as with the shrink_to_fit method, will cause the vector to permanently switch to dynamically allocated storage.

Template Parameters

  1. typename T

    The type of object that is stored in the small_vector

  2.  N

    The number of preallocated elements stored inside small_vector. It shall be less than Allocator::max_size();

  3. typename Allocator

    The allocator used for memory management when the number of elements exceeds N. Use void for the default allocator

  4. typename Options

    A type produced from boost::container::small_vector_options.

small_vector public member functions

  1. () ;
  2. ( a);
  3. ( n);
  4. ( n,  a);
  5. ( n, default_init_t);
  6. ( n, default_init_t,  a);
  7. ( n,  v);
  8. ( n,  v,  a);
  9. template<typename InIt> 
      ( first,  BOOST_CONTAINER_DOCIGN);
  10. template<typename InIt> 
      ( first,  last, 
                    BOOST_CONTAINER_DOCIGN);
  11. (small_vector & other);
  12. (small_vector & other,  a);
  13. ( other);
  14. ( other);
  15. (small_vector && other) ;
  16. (small_vector && other,  a);
  17. ( il, 
                  a = );
  18. small_vector & (small_vector & other);
  19. small_vector & 
    (small_vector && other) ;
  20. small_vector & ( other);
  21. small_vector & ( other);
  22.  (small_vector & other);
  23.  ();

PrevUpHomeNext