From d2bd31e4d09f167fc0cabf187e1da7a6563b9fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 20 Sep 2014 17:28:41 +0200 Subject: [PATCH] Add new documentation macros and tested in vector. --- doc/Jamfile.v2 | 6 ++- include/boost/container/detail/workaround.hpp | 5 ++ include/boost/container/vector.hpp | 54 ++++++++++--------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index f185ef8..4118511 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -37,7 +37,11 @@ doxygen autodoc \"BOOST_COPY_ASSIGN_REF(T)=const T &\" \\ \"BOOST_FWD_REF(a)=a &&\" \\ \"BOOST_INTRUSIVE_OPTION_CONSTANT(OPTION_NAME, TYPE, VALUE, CONSTANT_NAME) = template struct OPTION_NAME{};\" \\ - \"BOOST_INTRUSIVE_OPTION_TYPE(OPTION_NAME, TYPE, TYPEDEF_EXPR, TYPEDEF_NAME) = template struct OPTION_NAME{};\" " + \"BOOST_INTRUSIVE_OPTION_TYPE(OPTION_NAME, TYPE, TYPEDEF_EXPR, TYPEDEF_NAME) = template struct OPTION_NAME{};\" + \"BOOST_CONTAINER_DOC1ST(T1, T2)=T1\" \\ + \"BOOST_CONTAINER_DOCIGN(T) \"\\ + \"BOOST_CONTAINER_DOCONLY(T) T\"\\ + " "boost.doxygen.reftitle=Boost.Container Header Reference" ; diff --git a/include/boost/container/detail/workaround.hpp b/include/boost/container/detail/workaround.hpp index c290861..bee4c1a 100644 --- a/include/boost/container/detail/workaround.hpp +++ b/include/boost/container/detail/workaround.hpp @@ -58,6 +58,11 @@ #define BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL #endif +#define BOOST_CONTAINER_DOC1ST(TYPE1, TYPE2) TYPE2 +#define BOOST_CONTAINER_I , +#define BOOST_CONTAINER_DOCIGN(T) T +#define BOOST_CONTAINER_DOCONLY(T) + #include #endif //#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index ffca47c..d35b08e 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -294,6 +294,9 @@ struct vector_alloc_holder { if(initial_size){ m_start = this->allocation_command(allocate_new, initial_size, initial_size, m_capacity, m_start).first; + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_alloc; + #endif } } @@ -307,6 +310,9 @@ struct vector_alloc_holder if(initial_size){ m_start = this->allocation_command (allocate_new, initial_size, initial_size, m_capacity, m_start).first; + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_alloc; + #endif } } @@ -325,6 +331,9 @@ struct vector_alloc_holder if(cap){ m_start = this->allocation_command (allocate_new, cap, cap, m_capacity, m_start).first; + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_alloc; + #endif } } @@ -529,11 +538,7 @@ struct vector_alloc_holder > -#else -template -#endif +template ) > class vector { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -567,7 +572,7 @@ class vector typedef typename ::boost::container::allocator_traits::difference_type difference_type; typedef Allocator allocator_type; typedef Allocator stored_allocator_type; - #if defined BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + #if defined BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER typedef BOOST_CONTAINER_IMPDEF(pointer) iterator; typedef BOOST_CONTAINER_IMPDEF(const_pointer) const_iterator; #else @@ -909,14 +914,11 @@ class vector //! Complexity: Linear to n. template void assign(InIt first, InIt last - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value && + BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I typename container_detail::enable_if_c + < !container_detail::is_convertible::value && ( container_detail::is_input_iterator::value || - container_detail::is_same::value ) - >::type * = 0 - #endif - ) + container_detail::is_same::value ) + >::type * = 0) ) { //Overwrite all elements we can from [first, last) iterator cur = this->begin(); @@ -957,13 +959,11 @@ class vector //! Complexity: Linear to n. template void assign(FwdIt first, FwdIt last - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value && + BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I typename container_detail::enable_if_c + < !container_detail::is_convertible::value && ( !container_detail::is_input_iterator::value && - !container_detail::is_same::value ) - >::type * = 0 - #endif + !container_detail::is_same::value ) + >::type * = 0) ) { //For Fwd iterators the standard only requires EmplaceConstructible and assignable from *first @@ -973,8 +973,11 @@ class vector if(input_sz > old_capacity){ //If input range is too big, we need to reallocate size_type real_cap = 0; std::pair ret = - this->m_holder.allocation_command(allocate_new, input_sz, input_sz, real_cap, this->m_holder.start()); + this->m_holder.allocation_command(allocate_new|expand_fwd, input_sz, input_sz, real_cap, this->m_holder.start()); if(!ret.second){ //New allocation, just emplace new values + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_alloc; + #endif pointer const old_p = this->m_holder.start(); if(old_p){ this->priv_destroy_all(); @@ -987,6 +990,9 @@ class vector return; } else{ + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_expand_fwd; + #endif //Forward expansion, use assignment + back deletion/construction that comes later } } @@ -1519,12 +1525,10 @@ class vector //! Complexity: Linear to std::distance [first, last). template iterator insert(const_iterator pos, InIt first, InIt last - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value + BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I typename container_detail::enable_if_c + < !container_detail::is_convertible::value && container_detail::is_input_iterator::value - >::type * = 0 - #endif + >::type * = 0) ) { const size_type n_pos = pos - this->cbegin();