Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:19

0001 ///////////////////////////////////////////////////////////////////////////////
0002 //  Copyright 2012 John Maddock.
0003 //  Copyright Christopher Kormanyos 2013. Distributed under the Boost
0004 //  Software License, Version 1.0. (See accompanying file
0005 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 
0008 #ifndef BOOST_MP_DETAIL_DYNAMIC_ARRAY_HPP
0009 #define BOOST_MP_DETAIL_DYNAMIC_ARRAY_HPP
0010 
0011 #include <algorithm>
0012 #include <cstddef>
0013 #include <cstdint>
0014 #include <vector>
0015 
0016 #include <boost/multiprecision/detail/rebind.hpp>
0017 
0018 namespace boost { namespace multiprecision { namespace backends { namespace detail {
0019 template <class ValueType, const std::uint32_t ElemNumber, class my_allocator>
0020 struct dynamic_array : public std::vector<ValueType, typename rebind<ValueType, my_allocator>::type>
0021 {
0022 private:
0023    using base_class_type = std::vector<ValueType, typename rebind<ValueType, my_allocator>::type>;
0024 
0025 public:
0026    dynamic_array()
0027       : base_class_type(static_cast<typename base_class_type::size_type>(ElemNumber),
0028                         static_cast<typename base_class_type::value_type>(0u)) { }
0029 
0030    dynamic_array(std::initializer_list<std::uint32_t> lst)
0031       : base_class_type(static_cast<typename base_class_type::size_type>(ElemNumber),
0032                         static_cast<typename base_class_type::value_type>(0u))
0033    {
0034       std::copy(lst.begin(),
0035                 lst.begin() + (std::min)(std::size_t(lst.size()), std::size_t(ElemNumber)),
0036                 data());
0037    }
0038 
0039          typename base_class_type::value_type* data()       { return &(*(this->begin())); }
0040    const typename base_class_type::value_type* data() const { return &(*(this->begin())); }
0041 };
0042 }}}} // namespace boost::multiprecision::backends::detail
0043 
0044 #endif // BOOST_MP_DETAIL_DYNAMIC_ARRAY_HPP