forked from boostorg/container
Changes during Git migration:
- Added Extended Allocator support for Boost.Container. - Improved Doxygen generated reference - Fixed ticket #9338 ("VS2005 compiler errors in swap() definition after including container/memory_util.hpp")
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
|
||||
namespace boost { namespace container {
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
namespace container_detail {
|
||||
|
||||
template<class T, std::size_t N>
|
||||
@@ -61,46 +63,46 @@ class static_storage_allocator
|
||||
|
||||
} //namespace container_detail {
|
||||
|
||||
/**
|
||||
* @defgroup static_vector_non_member static_vector non-member functions
|
||||
*/
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
/**
|
||||
* @brief A variable-size array container with fixed capacity.
|
||||
*
|
||||
* static_vector is a sequence container like boost::container::vector with contiguous storage that can
|
||||
* change in size, along with the static allocation, low overhead, and fixed capacity of boost::array.
|
||||
*
|
||||
* A static_vector is a sequence that supports random access to elements, constant time insertion and
|
||||
* removal of elements at the end, and linear time insertion and removal of elements at the beginning or
|
||||
* in the middle. The number of elements in a static_vector may vary dynamically up to a fixed capacity
|
||||
* because elements are stored within the object itself similarly to an array. However, objects are
|
||||
* initialized as they are inserted into static_vector unlike C arrays or std::array which must construct
|
||||
* all elements on instantiation. The behavior of static_vector enables the use of statically allocated
|
||||
* elements in cases with complex object lifetime requirements that would otherwise not be trivially
|
||||
* possible.
|
||||
*
|
||||
* @par Error Handling
|
||||
* Insertion beyond the capacity result in throwing std::bad_alloc() if exceptions are enabled or
|
||||
* calling throw_bad_alloc() if not enabled.
|
||||
*
|
||||
* std::out_of_range is thrown if out of bound access is performed in `at()` if exceptions are
|
||||
* enabled, throw_out_of_range() if not enabled.
|
||||
*
|
||||
* @tparam Value The type of element that will be stored.
|
||||
* @tparam Capacity The maximum number of elements static_vector can store, fixed at compile time.
|
||||
*/
|
||||
//!
|
||||
//!@brief A variable-size array container with fixed capacity.
|
||||
//!
|
||||
//!static_vector is a sequence container like boost::container::vector with contiguous storage that can
|
||||
//!change in size, along with the static allocation, low overhead, and fixed capacity of boost::array.
|
||||
//!
|
||||
//!A static_vector is a sequence that supports random access to elements, constant time insertion and
|
||||
//!removal of elements at the end, and linear time insertion and removal of elements at the beginning or
|
||||
//!in the middle. The number of elements in a static_vector may vary dynamically up to a fixed capacity
|
||||
//!because elements are stored within the object itself similarly to an array. However, objects are
|
||||
//!initialized as they are inserted into static_vector unlike C arrays or std::array which must construct
|
||||
//!all elements on instantiation. The behavior of static_vector enables the use of statically allocated
|
||||
//!elements in cases with complex object lifetime requirements that would otherwise not be trivially
|
||||
//!possible.
|
||||
//!
|
||||
//!@par Error Handling
|
||||
//! Insertion beyond the capacity result in throwing std::bad_alloc() if exceptions are enabled or
|
||||
//! calling throw_bad_alloc() if not enabled.
|
||||
//!
|
||||
//! std::out_of_range is thrown if out of bound access is performed in <code>at()</code> if exceptions are
|
||||
//! enabled, throw_out_of_range() if not enabled.
|
||||
//!
|
||||
//!@tparam Value The type of element that will be stored.
|
||||
//!@tparam Capacity The maximum number of elements static_vector can store, fixed at compile time.
|
||||
template <typename Value, std::size_t Capacity>
|
||||
class static_vector
|
||||
: public vector<Value, container_detail::static_storage_allocator<Value, Capacity> >
|
||||
{
|
||||
typedef vector<Value, container_detail::static_storage_allocator<Value, Capacity> > base_t;
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
typedef vector<Value, container_detail::static_storage_allocator<Value, Capacity> > base_t;
|
||||
|
||||
BOOST_COPYABLE_AND_MOVABLE(static_vector)
|
||||
BOOST_COPYABLE_AND_MOVABLE(static_vector)
|
||||
|
||||
template<class U, std::size_t OtherCapacity>
|
||||
friend class static_vector;
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
public:
|
||||
//! @brief The type of elements stored in the container.
|
||||
typedef typename base_t::value_type value_type;
|
||||
|
||||
Reference in New Issue
Block a user