doc_custom_deque.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2013-2013. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //[doc_custom_deque
  11. #include <boost/container/deque.hpp>
  12. #include <boost/static_assert.hpp>
  13. //Make sure assertions are active
  14. #ifdef NDEBUG
  15. #undef NDEBUG
  16. #endif
  17. #include <cassert>
  18. int main ()
  19. {
  20. using namespace boost::container;
  21. //This option specifies the desired block size for deque
  22. typedef deque_options< block_size<128u> >::type block_128_option_t;
  23. //This deque will allocate blocks of 128 elements
  24. typedef deque<int, void, block_128_option_t > block_128_deque_t;
  25. assert(block_128_deque_t::get_block_size() == 128u);
  26. //This option specifies the maximum block size for deque
  27. //in bytes
  28. typedef deque_options< block_bytes<1024u> >::type block_1024_bytes_option_t;
  29. //This deque will allocate blocks of 1024 bytes
  30. typedef deque<int, void, block_1024_bytes_option_t > block_1024_bytes_deque_t;
  31. assert(block_1024_bytes_deque_t::get_block_size() == 1024u/sizeof(int));
  32. return 0;
  33. }
  34. //]