Dune Core Modules (2.8.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
4#ifndef DUNE_COMMON_FILLED_ARRAY_HH
5#define DUNE_COMMON_FILLED_ARRAY_HH
6
11#include <array>
12#include <cstddef>
13
14namespace Dune
15{
22
30 template<std::size_t n, class T>
31 constexpr std::array<T, n> filledArray(const T& t)
32 {
33 std::array<T, n> arr{};
34 // this is constexpr in c++17, `arr.fill(t)` is not
35 for(auto &el : arr)
36 el = t;
37 return arr;
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:31
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)