DUNE-FEM (unstable)

tuples.hh
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>
8#include <dune/fem/io/streams/streams.hh>
9
10
11namespace 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
Stream & operator>>(Stream &stream, std::tuple< Ts... > &t)
Read a std::tuple.
Definition: streamoperators.hh:43
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:256
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)