dune-common  2.5.1
streamoperators.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_STREAMOPERATORS_HH
5 #define DUNE_STREAMOPERATORS_HH
6 
11 #include <array>
12 #include <tuple>
13 
16 
17 namespace Dune
18 {
24  template<typename Stream, typename... Ts>
26  inline Stream& operator<<(Stream& stream, const std::tuple<Ts...>& t)
27  {
28  stream<<"[";
29  if(sizeof...(Ts)>0)
30  {
31  Hybrid::forEach(Std::make_index_sequence<sizeof...(Ts)-1>{},
32  [&](auto i){stream<<std::get<i>(t)<<",";});
33  stream<<std::get<sizeof...(Ts)-1>(t);
34  }
35  stream<<"]";
36  return stream;
37  }
38 
40  template<typename Stream, typename... Ts>
41  inline Stream& operator>>(Stream& stream, std::tuple<Ts...>& t)
42  {
43  Hybrid::forEach(Std::make_index_sequence<sizeof...(Ts)>{},
44  [&](auto i){stream>>std::get<i>(t);});
45  return stream;
46  }
47 
49  template<typename Stream, typename T, std::size_t N>
50  inline Stream& operator<<(Stream& stream, const std::array<T,N>& a)
51  {
52  stream<<"[";
53  if(N>0)
54  {
55  for(std::size_t i=0; i<N-1; ++i)
56  stream<<a[i]<<",";
57  stream<<a[N-1];
58  }
59  stream<<"]";
60  return stream;
61  }
62 
65 } // end namespace Dune
66 
67 #endif
Reference get(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key)
Definition: propertymap.hh:82
Dune namespace.
Definition: alignment.hh:10
Stream & operator>>(Stream &stream, std::tuple< Ts... > &t)
Read a std::tuple.
Definition: streamoperators.hh:41
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition: bigunsignedint.hh:265
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:314