DUNE-ACFEM (unstable)

ostream.hh
1#ifndef __DUNE_ACFEM_COMMON_OSTREAM_HH__
2#define __DUNE_ACFEM_COMMON_OSTREAM_HH__
3
4#if HAVE_CONFIG_H
5# include <config.h>
6#endif
7
8#include <limits>
9#include <iostream>
10#include <iomanip>
11#include <bitset>
12#include <utility>
13#include <dune/common/hybridutilities.hh>
14#include <dune/common/streamoperators.hh> // << for tuples etc.
15
16#include "types.hh"
17#include "tostring.hh"
18#include "typestring.hh"
19#include "../mpl/mpl.hh"
20#include "findbit.hh"
21#include "fractionconstant.hh"
22
23namespace Dune {
24
25 namespace ACFem {
26
31 template<class T, std::size_t Size = std::numeric_limits<T>::digits>
32 auto makeBitset(const T& t, const IndexConstant<Size>& = IndexConstant<Size>{})
33 {
34 return std::bitset<Size>(t);
35 }
36
38 template<class T>
39 std::ostream& operator<<(std::ostream& out, TypeString<T>&& t)
40 {
41 return out << t.name(true);
42 }
43
53 template<class T>
54 void prettyPrint(T&& arg, std::ostream& out = std::cout, const bool newLine = true)
55 {
56 out << typeString(arg);
57 if (newLine) {
58 out << std::endl;
59 }
60 }
61
62 // provided in dune/common/streamoperators.hh
63 /* *Output operator for tuple-like objects. Should probably support
64 * everthing which is accepted by std::get.
65 *
66 * @param[in,out] out stream to print to.
67 *
68 * @param[in] tuple Tuple-like object.
69 */
70 template<class T, std::enable_if_t<(IsTupleLike<T>::value
71 && !IsTuple<T>::value // dune-common
72 && !IsArray<T>::value // dune-common
73 ), int> = 0>
74 std::ostream& operator<<(std::ostream& out, const T& t)
75 {
76 out << (IsArray<T>::value ? "[" : "(");
77 forLoop<size<T>()>([&] (auto i) {
78 using I = decltype(i);
79 out << std::get<I::value>(t);
80 if (I::value < size<T>()-1) {
81 out << ", ";
82 }
83 });
84 out << (IsArray<T>::value ? "]" : ")");
85 return out;
86 }
87
89 template<class Int, Int I0, Int... I>
90 std::ostream& operator<<(std::ostream& out, Sequence<Int, I0, I...>)
91 {
92 return ((out << "<" << I0) << ... << ("," + toString(I))) << ">";
93 }
94
95 template<class Int>
96 std::ostream& operator<<(std::ostream& out, Sequence<Int>)
97 {
98 return out << "<>";
99 }
100
102 template<bool I0, bool... I>
103 std::ostream& operator<<(std::ostream& out, BoolSequence<I0, I...>)
104 {
105 return ((out << (I0 ? "true" : "false")) << ... << (I ? " true" : " false"));
106 }
107
108 static inline std::ostream& operator<<(std::ostream& out, BoolSequence<>)
109 {
110 return out;
111 }
112
113 using Dune::operator<<;
114 using Dune::ACFem::operator<<;
115
117
118 } // ACFem::
119
120} // Dune::
121
122#endif // __DUNE_ACFEM_COMMON_OSTREAM_HH__
A class constructing the name of another type.
Definition: typestring.hh:67
void prettyPrint(T &&arg, std::ostream &out=std::cout, const bool newLine=true)
Print something which shows the type that was passed to the function.
Definition: ostream.hh:54
std::ostream & operator<<(std::ostream &out, TypeString< T > &&t)
Output operator for TypePrint tag-structure.
Definition: ostream.hh:39
auto typeString(T &&t, bool stripNameSpaces=true)
Generator for TypeString.
Definition: typestring.hh:144
std::integer_sequence< T, V... > Sequence
Sequence of any type of integer values.
Definition: types.hh:56
Sequence< bool, Decisions... > BoolSequence
Sequence of boolean values.
Definition: types.hh:60
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Jun 19, 23:17, 2026)