dynamic_array.hpp 1.2 KB

123456789101112131415161718192021222324252627
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright 2012 John Maddock.
  3. // Copyright Christopher Kormanyos 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. #ifndef BOOST_MP_DETAIL_DYNAMIC_ARRAY_HPP
  8. #define BOOST_MP_DETAIL_DYNAMIC_ARRAY_HPP
  9. #include <vector>
  10. #include <boost/multiprecision/detail/rebind.hpp>
  11. namespace boost { namespace multiprecision { namespace backends { namespace detail {
  12. template <class value_type, const std::uint32_t elem_number, class my_allocator>
  13. struct dynamic_array : public std::vector<value_type, typename rebind<value_type, my_allocator>::type>
  14. {
  15. dynamic_array() : std::vector<value_type, typename rebind<value_type, my_allocator>::type>(static_cast<typename std::vector<value_type, typename rebind<value_type, my_allocator>::type>::size_type>(elem_number), static_cast<value_type>(0))
  16. {
  17. }
  18. value_type* data() { return &(*(this->begin())); }
  19. const value_type* data() const { return &(*(this->begin())); }
  20. };
  21. }}}} // namespace boost::multiprecision::backends::detail
  22. #endif // BOOST_MP_DETAIL_DYNAMIC_ARRAY_HPP