Dune Core Modules (2.10.0)

filledarray.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5
6#ifndef DUNE_COMMON_FILLED_ARRAY_HH
7#define DUNE_COMMON_FILLED_ARRAY_HH
8
13#include <array>
14#include <cstddef>
15#include <utility>
16
17#include <dune/common/indices.hh>
18
19namespace Dune
20{
27
32 template<std::size_t n, class T>
33 constexpr std::array<T, n> filledArray(const T& t)
34 {
35 return unpackIntegerSequence([&](auto... i) {
36 return std::array<T, n>{((void)(i),t)...};
37 }, std::make_index_sequence<n>{});
38 }
39
42} // end namespace Dune
43
44#endif // DUNE_COMMON_FILLED_ARRAY_HH
constexpr std::array< T, n > filledArray(const T &t)
Return an array filled with the provided value.
Definition: filledarray.hh:33
decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, i... > sequence)
Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
Definition: indices.hh:124
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)