File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,29 @@ int main ()
2020{
2121 using namespace boost ::container;
2222
23+ // This option specifies that a deque that will use "unsigned char" as
24+ // the type to store capacity or size internally.
25+ typedef deque_options< stored_size<unsigned char > >::type size_option_t ;
26+
27+ // Size-optimized deque is smaller than the default one.
28+ typedef deque<int , new_allocator<int >, size_option_t > size_optimized_deque_t ;
29+ assert (( sizeof (size_optimized_deque_t ) < sizeof (deque<int >) ));
30+
31+ // Requesting capacity for more elements than representable by "unsigned char"
32+ // is an error in the size optimized deque.
33+ bool exception_thrown = false ;
34+ /* <-*/
35+ #ifndef BOOST_NO_EXCEPTIONS
36+ BOOST_CONTAINER_TRY{ size_optimized_deque_t v (256 ); } BOOST_CONTAINER_CATCH (...){ exception_thrown = true ; } BOOST_CONTAINER_CATCH_END
37+ #else
38+ exception_thrown = true ;
39+ #endif // BOOST_NO_EXCEPTIONS
40+ /* ->*/
41+ // =try { size_optimized_deque_t v(256); }
42+ // =catch(...){ exception_thrown = true; }
43+
44+ assert (exception_thrown == true );
45+
2346 // This option specifies the desired block size for deque
2447 typedef deque_options< block_size<128u > >::type block_128_option_t ;
2548
You can’t perform that action at this time.
0 commit comments