dune-fem  2.8-git
tuples.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_IO_STREAMS_TUPLES_HH
2 #define DUNE_FEM_IO_STREAMS_TUPLES_HH
3 
4 #include <tuple>
5 #include <utility>
6 
7 #include <dune/common/hybridutilities.hh>
9 
10 
11 namespace Dune
12 {
13 
14  namespace Fem
15  {
16 
17  // External forward declarations
18  // -----------------------------
19 
20  template <class StreamTraits>
21  class OutStreamInterface;
22  template <class StreamTraits>
23  class InStreamInterface;
24 
25 
26 
27  // std::tuple to InStream
28  // ----------------------
29 
30  template< class StreamTraits >
31  inline InStreamInterface< StreamTraits > &
32  operator>> ( InStreamInterface< StreamTraits > &in, std::tuple<> &tuple )
33  {
34  return in;
35  }
36 
37  template< class StreamTraits, class... Args >
38  inline InStreamInterface< StreamTraits > &
39  operator>> ( InStreamInterface< StreamTraits > &in, std::tuple< Args... > &tuple )
40  {
41 
42  Hybrid::forEach ( std::make_index_sequence< sizeof...( Args ) >{}, [ & ]( auto i ){ in >> std::get< i >( tuple ); } );
43  return in;
44  }
45 
46 
47 
48  // std::tuple to OutStream
49  // -----------------------
50 
51  template< class StreamTraits >
52  inline OutStreamInterface< StreamTraits > &
53  operator<< ( OutStreamInterface< StreamTraits > &out, const std::tuple<> &tuple )
54  {
55  return out;
56  }
57 
58  template< class StreamTraits, class... Args >
59  inline OutStreamInterface< StreamTraits > &
60  operator<< ( OutStreamInterface< StreamTraits > &out, const std::tuple< Args... > &tuple )
61  {
62  Hybrid::forEach ( std::make_index_sequence< sizeof...( Args ) >{}, [ & ]( auto i ){ out << std::get< i >( tuple ); } );
63  return out;
64  }
65 
66  } // namespace Fem
67 
68 } // namespace Dune
69 
70 #endif // #ifndef DUNE_FEM_IO_STREAMS_TUPLES_HH
Definition: bindguard.hh:11
OutStreamInterface< StreamTraits > & operator<<(OutStreamInterface< StreamTraits > &out, const DiscreteFunctionInterface< Impl > &df)
write a discrete function into an output stream
Definition: discretefunction_inline.hh:397
InStreamInterface< StreamTraits > & operator>>(InStreamInterface< StreamTraits > &in, DiscreteFunctionInterface< Impl > &df)
read a discrete function from an input stream
Definition: discretefunction_inline.hh:417
static void forEach(IndexRange< T, sz > range, F &&f)
Definition: hybrid.hh:129
abstract interface for an input stream
Definition: streams.hh:179