dune-common
2.7.0
dune
common
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
14
namespace
Dune
15
{
21
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
Dune::filledArray
constexpr std::array< T, n > filledArray(const T &t)
Return an array filled with the provided value.
Definition:
filledarray.hh:31
Dune
Dune namespace.
Definition:
alignedallocator.hh:13
Generated by
1.8.17