• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
14 //Make sure assertions are active
15 #ifdef NDEBUG
16 #undef NDEBUG
17 #endif
18 #include <cassert>
19 
main()20 int main ()
21 {
22    using namespace boost::container;
23 
24    //This option specifies the desired alignment for value_type
25    typedef static_vector_options< inplace_alignment<16u> >::type alignment_16_option_t;
26 
27    //Check 16 byte alignment option
28    static_vector<int, 10, alignment_16_option_t > sv;
29    assert(((std::size_t)sv.data() % 16u) == 0);
30 
31    //This static_vector won't throw on overflow, for maximum performance
32    typedef static_vector_options< throw_on_overflow<false> >::type no_throw_options_t;
33 
34    //Create static_vector with no throw on overflow
35    static_vector<int, 10, no_throw_options_t > sv2;
36 
37    return 0;
38 }
39 //]
40