mirror of
https://github.com/boostorg/container.git
synced 2026-02-23 03:32:14 +00:00
Use "get_segment_size/bytes" in deque and its example.
This commit is contained in:
@@ -48,28 +48,43 @@ int main ()
|
||||
assert(exception_thrown == true);
|
||||
|
||||
//--------------------------------------------
|
||||
// 'block_size' option
|
||||
// 'block_size/segment_size' option
|
||||
//--------------------------------------------
|
||||
|
||||
//This option specifies the desired block size for deque
|
||||
typedef deque_options< block_size<128u> >::type block_128_option_t;
|
||||
|
||||
//This deque will allocate blocks of 128 elements
|
||||
//segment_size is an alias for block_size (an alias for block_size)
|
||||
typedef deque_options< segment_size<128u> >::type segment_128_option_t;
|
||||
|
||||
//This deque will allocate blocks of 128 elements
|
||||
typedef deque<int, void, block_128_option_t > block_128_deque_t;
|
||||
assert(block_128_deque_t::get_block_size() == 128u);
|
||||
|
||||
//This deque will allocate segments of 128 elements (an alias for block_size)
|
||||
typedef deque<int, void, segment_128_option_t > segment_128_deque_t;
|
||||
assert(segment_128_deque_t::get_block_size() == 128u);
|
||||
|
||||
//--------------------------------------------
|
||||
// 'block_bytes' option
|
||||
// 'block_bytes/segment_bytes' option
|
||||
//--------------------------------------------
|
||||
|
||||
//This option specifies the maximum block size for deque
|
||||
//in bytes
|
||||
typedef deque_options< block_bytes<1024u> >::type block_1024_bytes_option_t;
|
||||
|
||||
//This option specifies the maximum segment size for deque
|
||||
//in bytes (an alias for block_bytes)
|
||||
typedef deque_options< segment_bytes<1024u> >::type segment_1024_bytes_option_t;
|
||||
|
||||
//This deque will allocate blocks of 1024 bytes
|
||||
typedef deque<int, void, block_1024_bytes_option_t > block_1024_bytes_deque_t;
|
||||
assert(block_1024_bytes_deque_t::get_block_size() == 1024u/sizeof(int));
|
||||
|
||||
//This deque will allocate blocks of 1024 bytes (an alias for block_bytes)
|
||||
typedef deque<int, void, segment_1024_bytes_option_t > segment_1024_bytes_deque_t;
|
||||
assert(segment_1024_bytes_deque_t::get_block_size() == 1024u/sizeof(int));
|
||||
|
||||
return 0;
|
||||
}
|
||||
//]
|
||||
|
||||
@@ -80,6 +80,7 @@ class deque : public deque_impl<T, Allocator, false, Options>
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
using base_type::get_block_size;
|
||||
using base_type::get_segment_size;
|
||||
using base_type::is_reservable;
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
@@ -322,6 +323,23 @@ class deque : public deque_impl<T, Allocator, false, Options>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! <b>Effects</b>: Returns the number of continguous elements per segment/block.
|
||||
//! Same as get_block_size().
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant.
|
||||
static size_type get_segment_size() BOOST_NOEXCEPT_OR_NOTHROW;
|
||||
|
||||
//! <b>Effects</b>: Returns the number of continguous elements per segment/block.
|
||||
//! Same as get_segment_size().
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant.
|
||||
static size_type get_block_size() BOOST_NOEXCEPT_OR_NOTHROW;
|
||||
|
||||
//! <b>Effects</b>: Assigns the n copies of val to *this.
|
||||
//!
|
||||
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
|
||||
|
||||
Reference in New Issue
Block a user