Back to home page

EIC code displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 //  Copyright 2021 John Maddock.
0003 //  Copyright Christopher Kormanyos 2021. 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_STATIC_ARRAY_HPP
0009 #define BOOST_MP_DETAIL_STATIC_ARRAY_HPP
0010 
0011 #include <array>
0012 #include <cstddef>
0013 #include <cstdint>
0014 #include <initializer_list>
0015 
0016 namespace boost { namespace multiprecision { namespace backends { namespace detail {
0017 template <class ValueType, const std::uint32_t ElemNumber>
0018 struct static_array : public std::array<ValueType, std::size_t(ElemNumber)>
0019 {
0020 private:
0021    using base_class_type = std::array<ValueType, std::size_t(ElemNumber)>;
0022 
0023 public:
0024    static_array() noexcept
0025    {
0026       base_class_type::fill(typename base_class_type::value_type(0u));
0027    }
0028 
0029    static_array(std::initializer_list<std::uint32_t> lst) noexcept
0030    {
0031       std::copy(lst.begin(),
0032                 lst.begin() + (std::min)(std::size_t(lst.size()), std::size_t(ElemNumber)),
0033                 base_class_type::begin());
0034 
0035       std::fill(base_class_type::begin() + (std::min)(std::size_t(lst.size()), std::size_t(ElemNumber)),
0036                 base_class_type::end(),
0037                 typename base_class_type::value_type(0u));
0038    }
0039 };
0040 }}}} // namespace boost::multiprecision::backends::detail
0041 
0042 #endif // BOOST_MP_DETAIL_STATIC_ARRAY_HPP