dune-common 3.0-git
array.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_ARRAY_HH
5#define DUNE_ARRAY_HH
6
11#include <array>
12#include <ostream>
13
14#include "std/make_array.hh"
15
16namespace Dune
17{
23 // pull in default implementation
24 using std::array;
25
27 template < class T, size_t N >
28 inline std::ostream& operator<< (std::ostream& s, const std::array<T,N>& e)
29 {
30 if (N == 0)
31 {
32 s << "[]";
33 return s;
34 }
35
36 s << "[";
37 for (size_t i=0; i<N-1; i++) s << e[i] << ",";
38 s << e[N-1] << "]";
39 return s;
40 }
41
43
45
48 template<typename T, std::size_t n>
49 std::array<T,n> fill_array(const T& t)
50 {
51 std::array<T,n> r;
52 r.fill(t);
53 return r;
54 }
55
58} // end namespace Dune
59
60#endif
std::ostream & operator<<(std::ostream &s, const std::array< T, N > &e)
Output operator for array.
Definition array.hh:28
std::array< T, n > fill_array(const T &t)
Create an array and fill it with copies of the provided value.
Definition array.hh:49
Dune namespace.
Definition alignment.hh:11
std::array< typename std::common_type< Args... >::type, sizeof...(Args)> make_array(const Args &... args)
Create and initialize an array.
Definition make_array.hh:23