/* A non-copyable vector which first allocates from the stack, before falling back on usual std::allocator behavior. */ // Copyright Frank Mori Hess 2008. // Distributed under the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/signals2 for library home page. #ifndef BOOST_SIGNALS2_STACK_VECTOR_HPP #define BOOST_SIGNALS2_STACK_VECTOR_HPP #include #include #include namespace boost { namespace signals2 { namespace detail { template class stack_vector: public std::vector >, public boost::noncopyable { typedef std::vector > base_vector_type; public: static const std::size_t num_stack_elements = NumStackElements; stack_vector(): base_vector_type(stack_allocator(&_storage)) { base_vector_type::reserve(num_stack_elements); } private: stack_storage _storage; }; template const std::size_t stack_vector::num_stack_elements; } // namespace detail } // namespace signals2 } // namespace boost #endif // BOOST_SIGNALS2_STACK_VECTOR_HPP