deal.II version GIT relicensing-6809-ge913b9bb34 2026-09-25 17:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
conditional_ostream.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2004 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_conditional_ostream_h
14#define dealii_conditional_ostream_h
15
16#include <deal.II/base/config.h>
17
18#include <ostream>
19
21
22
78{
79public:
85 explicit ConditionalOStream(std::ostream &stream, const bool active = true);
86
92 void
93 set_condition(const bool active);
94
98 bool
99 is_active() const;
100
104 std::ostream &
105 get_stream() const;
106
112 template <typename T>
113 const ConditionalOStream &
114 operator<<(const T &t) const;
115
125 const ConditionalOStream &
126 operator<<(std::ostream &(*p)(std::ostream &)) const;
127
128private:
132 std::ostream &output_stream;
133
138};
139
140
141// --------------------------- inline and template functions -----------
142
143template <class T>
144inline const ConditionalOStream &
145ConditionalOStream::operator<<(const T &t) const
146{
147 if (active_flag == true)
148 output_stream << t;
149
150 return *this;
151}
152
153
154inline const ConditionalOStream &
155ConditionalOStream::operator<<(std::ostream &(*p)(std::ostream &)) const
156{
157 if (active_flag == true)
158 output_stream << p;
159
160 return *this;
161}
162
163
164inline std::ostream &
166{
167 return output_stream;
168}
169
170
172
173#endif
std::ostream & get_stream() const
void set_condition(const bool active)
std::ostream & output_stream
const ConditionalOStream & operator<<(const T &t) const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39