Ticket #3032: boost-01.patch
File boost-01.patch, 9.1 KB (added by , 13 years ago) |
---|
-
boost/circular_buffer/base.hpp
a b 1006 1006 \par Complexity 1007 1007 Constant. 1008 1008 */ 1009 explicit circular_buffer(capacity_type capacity, const allocator_type& alloc = allocator_type())1009 explicit circular_buffer(capacity_type in_capacity, const allocator_type& alloc = allocator_type()) 1010 1010 : m_size(0), m_alloc(alloc) { 1011 initialize_buffer( capacity);1011 initialize_buffer(in_capacity); 1012 1012 m_first = m_last = m_buff; 1013 1013 } 1014 1014 … … 1046 1046 \par Complexity 1047 1047 Linear (in the <code>n</code>). 1048 1048 */ 1049 circular_buffer(capacity_type capacity, size_type n, param_value_type item,1049 circular_buffer(capacity_type in_capacity, size_type n, param_value_type item, 1050 1050 const allocator_type& alloc = allocator_type()) 1051 1051 : m_size(n), m_alloc(alloc) { 1052 BOOST_CB_ASSERT( capacity >= size()); // check for capacity lower than size1053 initialize_buffer( capacity, item);1052 BOOST_CB_ASSERT(in_capacity >= size()); // check for capacity lower than size 1053 initialize_buffer(in_capacity, item); 1054 1054 m_first = m_buff; 1055 m_last = capacity == n ? m_buff : m_buff + n;1055 m_last = in_capacity == n ? m_buff : m_buff + n; 1056 1056 } 1057 1057 1058 1058 //! The copy constructor. … … 1145 1145 <a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>). 1146 1146 */ 1147 1147 template <class InputIterator> 1148 circular_buffer(capacity_type capacity, InputIterator first, InputIterator last,1148 circular_buffer(capacity_type in_capacity, InputIterator first, InputIterator last, 1149 1149 const allocator_type& alloc = allocator_type()) 1150 1150 : m_alloc(alloc) { 1151 initialize( capacity, first, last, is_integral<InputIterator>());1151 initialize(in_capacity, first, last, is_integral<InputIterator>()); 1152 1152 } 1153 1153 1154 1154 #endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) … … 1260 1260 assign(size_type, const_reference)\endlink</code>, <code>assign(InputIterator, InputIterator)</code>, 1261 1261 <code>assign(capacity_type, InputIterator, InputIterator)</code> 1262 1262 */ 1263 void assign(capacity_type capacity, size_type n, param_value_type item) {1264 BOOST_CB_ASSERT( capacity >= n); // check for new capacity lower than n1265 assign_n( capacity, n, cb_details::assign_n<param_value_type, allocator_type>(n, item, m_alloc));1263 void assign(capacity_type in_capacity, size_type n, param_value_type item) { 1264 BOOST_CB_ASSERT(in_capacity >= n); // check for new capacity lower than n 1265 assign_n(in_capacity, n, cb_details::assign_n<param_value_type, allocator_type>(n, item, m_alloc)); 1266 1266 } 1267 1267 1268 1268 //! Assign a copy of the range into the <code>circular_buffer</code>. … … 1333 1333 <code>assign(InputIterator, InputIterator)</code> 1334 1334 */ 1335 1335 template <class InputIterator> 1336 void assign(capacity_type capacity, InputIterator first, InputIterator last) {1337 assign( capacity, first, last, is_integral<InputIterator>());1336 void assign(capacity_type in_capacity, InputIterator first, InputIterator last) { 1337 assign(in_capacity, first, last, is_integral<InputIterator>()); 1338 1338 } 1339 1339 1340 1340 //! Swap the contents of two <code>circular_buffer</code>s. … … 2079 2079 } 2080 2080 2081 2081 //! Initialize the internal buffer. 2082 void initialize_buffer(capacity_type capacity) {2083 m_buff = allocate( capacity);2084 m_end = m_buff + capacity;2082 void initialize_buffer(capacity_type in_capacity) { 2083 m_buff = allocate(in_capacity); 2084 m_end = m_buff + in_capacity; 2085 2085 } 2086 2086 2087 2087 //! Initialize the internal buffer. 2088 void initialize_buffer(capacity_type capacity, param_value_type item) {2089 initialize_buffer( capacity);2088 void initialize_buffer(capacity_type in_capacity, param_value_type item) { 2089 initialize_buffer(in_capacity); 2090 2090 BOOST_TRY { 2091 2091 cb_details::uninitialized_fill_n_with_alloc(m_buff, size(), item, m_alloc); 2092 2092 } BOOST_CATCH(...) { … … 2135 2135 2136 2136 //! Specialized initialize method. 2137 2137 template <class IntegralType> 2138 void initialize(capacity_type capacity, IntegralType n, IntegralType item, const true_type&) {2139 BOOST_CB_ASSERT( capacity >= static_cast<size_type>(n)); // check for capacity lower than n2138 void initialize(capacity_type in_capacity, IntegralType n, IntegralType item, const true_type&) { 2139 BOOST_CB_ASSERT(in_capacity >= static_cast<size_type>(n)); // check for capacity lower than n 2140 2140 m_size = static_cast<size_type>(n); 2141 initialize_buffer( capacity, item);2141 initialize_buffer(in_capacity, item); 2142 2142 m_first = m_buff; 2143 m_last = capacity == size() ? m_buff : m_buff + size();2143 m_last = in_capacity == size() ? m_buff : m_buff + size(); 2144 2144 } 2145 2145 2146 2146 //! Specialized initialize method. 2147 2147 template <class Iterator> 2148 void initialize(capacity_type capacity, Iterator first, Iterator last, const false_type&) {2148 void initialize(capacity_type in_capacity, Iterator first, Iterator last, const false_type&) { 2149 2149 BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type 2150 2150 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581)) 2151 initialize( capacity, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());2151 initialize(in_capacity, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type()); 2152 2152 #else 2153 initialize( capacity, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());2153 initialize(in_capacity, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type()); 2154 2154 #endif 2155 2155 } 2156 2156 2157 2157 //! Specialized initialize method. 2158 2158 template <class InputIterator> 2159 void initialize(capacity_type capacity,2159 void initialize(capacity_type in_capacity, 2160 2160 InputIterator first, 2161 2161 InputIterator last, 2162 2162 const std::input_iterator_tag&) { 2163 initialize_buffer( capacity);2163 initialize_buffer(in_capacity); 2164 2164 m_first = m_last = m_buff; 2165 2165 m_size = 0; 2166 if ( capacity == 0)2166 if (in_capacity == 0) 2167 2167 return; 2168 2168 while (first != last && !full()) { 2169 2169 m_alloc.construct(m_last, *first++); … … 2179 2179 2180 2180 //! Specialized initialize method. 2181 2181 template <class ForwardIterator> 2182 void initialize(capacity_type capacity,2182 void initialize(capacity_type in_capacity, 2183 2183 ForwardIterator first, 2184 2184 ForwardIterator last, 2185 2185 const std::forward_iterator_tag&) { 2186 2186 BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range 2187 initialize( capacity, first, last, std::distance(first, last));2187 initialize(in_capacity, first, last, std::distance(first, last)); 2188 2188 } 2189 2189 2190 2190 //! Initialize the circular buffer. 2191 2191 template <class ForwardIterator> 2192 void initialize(capacity_type capacity,2192 void initialize(capacity_type in_capacity, 2193 2193 ForwardIterator first, 2194 2194 ForwardIterator last, 2195 2195 size_type distance) { 2196 initialize_buffer( capacity);2196 initialize_buffer(in_capacity); 2197 2197 m_first = m_buff; 2198 if (distance > capacity) {2199 std::advance(first, distance - capacity);2200 m_size = capacity;2198 if (distance > in_capacity) { 2199 std::advance(first, distance - in_capacity); 2200 m_size = in_capacity; 2201 2201 } else { 2202 2202 m_size = distance; 2203 2203 } 2204 2204 BOOST_TRY { 2205 2205 m_last = cb_details::uninitialized_copy_with_alloc(first, last, m_buff, m_alloc); 2206 2206 } BOOST_CATCH(...) { 2207 deallocate(m_buff, capacity);2207 deallocate(m_buff, in_capacity); 2208 2208 BOOST_RETHROW 2209 2209 } 2210 2210 BOOST_CATCH_END -
boost/circular_buffer/details.hpp
a b 146 146 public: 147 147 148 148 //! Constructor. 149 capacity_control(Size capacity, Sizemin_capacity = 0)150 : m_capacity( capacity), m_min_capacity(min_capacity) {151 BOOST_CB_ASSERT( capacity >=min_capacity); // check for capacity lower than min_capacity149 capacity_control(Size in_capacity, Size in_min_capacity = 0) 150 : m_capacity(in_capacity), m_min_capacity(in_min_capacity) { 151 BOOST_CB_ASSERT(in_capacity >= in_min_capacity); // check for capacity lower than min_capacity 152 152 } 153 153 154 154 // Default copy constructor. -
boost/circular_buffer/space_optimized.hpp
a b 1229 1229 } 1230 1230 1231 1231 //! Ensure the reserve for possible growth up. 1232 size_type ensure_reserve(size_type new_capacity, size_type size) const {1233 if ( size + new_capacity / 5 >= new_capacity)1232 size_type ensure_reserve(size_type new_capacity, size_type in_size) const { 1233 if (in_size + new_capacity / 5 >= new_capacity) 1234 1234 new_capacity *= 2; // ensure at least 20% reserve 1235 1235 if (new_capacity > m_capacity_ctrl) 1236 1236 return m_capacity_ctrl;