From 90b3af4229271cf068aed0977afa9e7d2da9ff98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 27 Feb 2015 19:21:58 +0100 Subject: [PATCH] Document small_vector_base --- include/boost/container/detail/workaround.hpp | 2 +- include/boost/container/small_vector.hpp | 57 ++++++++++++++++--- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/include/boost/container/detail/workaround.hpp b/include/boost/container/detail/workaround.hpp index ecdaa9d..026e65d 100644 --- a/include/boost/container/detail/workaround.hpp +++ b/include/boost/container/detail/workaround.hpp @@ -55,7 +55,7 @@ #endif #define BOOST_CONTAINER_DOC1ST(TYPE1, TYPE2) TYPE2 -#define BOOST_MOVE_I , +#define BOOST_CONTAINER_I , #define BOOST_CONTAINER_DOCIGN(T) T #define BOOST_CONTAINER_DOCONLY(T) diff --git a/include/boost/container/small_vector.hpp b/include/boost/container/small_vector.hpp index 8e34a94..6bc3d2f 100644 --- a/include/boost/container/small_vector.hpp +++ b/include/boost/container/small_vector.hpp @@ -48,6 +48,8 @@ namespace boost { namespace container { +#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + template > class small_vector_base; @@ -262,15 +264,39 @@ class small_vector_allocator } }; +#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + ///////////////////////////////////////////////////// // // small_vector_base // ///////////////////////////////////////////////////// + +//! This class consists of common code from all small_vector types that don't depend on the +//! "N" template parameter. This class is non-copyable and non-destructible, so this class tipically +//! used as reference argument to functions that read or write small vectors. Since small_vector +//! derives from small_vector_base, the conversion to small_vector_base is implicit: +//! +//! +//! //Clients can pass any small_vector. +//! void read_any_small_vector_of_foo(const small_vector_base &in_parameter); +//! void modify_any_small_vector_of_foo(small_vector_base &out_parameter); +//! +//! void some_function() +//! { +//! small_vector myvector; +//! read_any_small_vector_of_foo(myvector); // Reads myvector +//! modify_any_small_vector_of_foo(myvector); // Modifies myvector +//! } +//! +//! +//! All `boost::container:vector` member functions are inherited. See `vector` documentation for details. +//! template class small_vector_base : public vector > { + #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED typedef typename allocator_traits::pointer pointer; BOOST_COPYABLE_AND_MOVABLE(small_vector_base) @@ -301,6 +327,16 @@ class small_vector_base ~small_vector_base(){} + using base_type::is_propagable_from; + using base_type::steal_resources; + + private: + //The only member + storage_type m_storage_start; + + #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + + public: small_vector_base& operator=(BOOST_COPY_ASSIGN_REF(small_vector_base) other) { return static_cast(this->base_type::operator=(static_cast(other))); } @@ -309,15 +345,10 @@ class small_vector_base void swap(small_vector_base &other) { return this->base_type::swap(other); } - - using base_type::is_propagable_from; - using base_type::steal_resources; - - private: - //The only member - storage_type m_storage_start; }; +#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + ///////////////////////////////////////////////////// // // small_vector_storage_calculator @@ -376,6 +407,8 @@ struct small_vector_storage_definer typedef small_vector_storage type; }; +#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + //! small_vector a vector-like container optimized for the case when it contains few elements. //! It contains some preallocated elements in-place, which allows it to avoid the use of the small_vector_allocator //! when the actual number of elements is below that preallocated threshold. @@ -383,13 +416,16 @@ struct small_vector_storage_definer //! small_vector is convertible to small_vector_unbounded 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. +//! //! \tparam T The type of object that is stored in the small_vector //! \tparam N The number of preallocated elements stored inside small_vector. It shall be less than Allocator::max_size(); //! \tparam Allocator The small_vector_allocator used for memory management when the number of elements exceeds N. template ) > class small_vector : public small_vector_base - , private small_vector_storage_definer::type + BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I private small_vector_storage_definer::type) { + #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED typedef small_vector_base base_type; typedef typename small_vector_storage_definer::type remaining_storage_holder; @@ -413,6 +449,9 @@ class small_vector : public small_vector_base static std::size_t internal_capacity() { return (sizeof(small_vector) - storage_test::s_start)/sizeof(T); } + #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + + public: small_vector() : base_type(initial_capacity_t(), internal_capacity()) {} @@ -455,6 +494,7 @@ class small_vector : public small_vector_base void swap(small_vector &other) { return this->base_type::swap(other); } + #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: void move_construct_impl(small_vector &x, const allocator_type &a) { @@ -467,6 +507,7 @@ class small_vector : public small_vector_base ); } } + #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED }; }}