1///////////////////////////////////////////////////////////////////////////////
2// Copyright 2021 John Maddock.
3// Copyright Christopher Kormanyos 2021. 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
8#ifndef BOOST_MP_DETAIL_STATIC_ARRAY_HPP
9#define BOOST_MP_DETAIL_STATIC_ARRAY_HPP
10
11#include <array>
12#include <cstddef>
13#include <cstdint>
14#include <initializer_list>
15
16namespace boost { namespace multiprecision { namespace backends { namespace detail {
17template <class ValueType, const std::uint32_t ElemNumber>
18struct static_array : public std::array<ValueType, std::size_t(ElemNumber)>
19{
20private:
21 using base_class_type = std::array<ValueType, std::size_t(ElemNumber)>;
22
23public:
24 static_array() noexcept
25 {
26 base_class_type::fill(typename base_class_type::value_type(0u));
27 }
28
29 static_array(std::initializer_list<std::uint32_t> lst) noexcept
30 {
31 std::copy(lst.begin(),
32 lst.begin() + (std::min)(a: std::size_t(lst.size()), b: std::size_t(ElemNumber)),
33 base_class_type::begin());
34
35 std::fill(base_class_type::begin() + (std::min)(a: std::size_t(lst.size()), b: std::size_t(ElemNumber)),
36 base_class_type::end(),
37 typename base_class_type::value_type(0u));
38 }
39};
40}}}} // namespace boost::multiprecision::backends::detail
41
42#endif // BOOST_MP_DETAIL_STATIC_ARRAY_HPP
43

source code of boost/libs/multiprecision/include/boost/multiprecision/detail/static_array.hpp