doc_custom_static_vector.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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_static_vector
  11. #include <boost/container/static_vector.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 alignment for value_type
  22. typedef static_vector_options< inplace_alignment<16u> >::type alignment_16_option_t;
  23. //Check 16 byte alignment option
  24. static_vector<int, 10, alignment_16_option_t > sv;
  25. assert(((std::size_t)sv.data() % 16u) == 0);
  26. //This static_vector won't throw on overflow, for maximum performance
  27. typedef static_vector_options< throw_on_overflow<false> >::type no_throw_options_t;
  28. //Create static_vector with no throw on overflow
  29. static_vector<int, 10, no_throw_options_t > sv2;
  30. return 0;
  31. }
  32. //]