Use "get_segment_size/bytes" in deque and its example.

This commit is contained in:
Ion Gaztañaga
2026-02-04 00:26:25 +01:00
parent ea94858c0a
commit bfb2563355
2 changed files with 36 additions and 3 deletions

View File

@@ -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;
}
//]