File indexing completed on 2026-07-10 07:48:43
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <ios>
0012 #include <ostream>
0013
0014 namespace Acts::detail {
0015
0016
0017
0018
0019
0020
0021 class OstreamStateGuard {
0022 public:
0023 explicit OstreamStateGuard(std::ostream& stream)
0024 : m_stream(&stream),
0025 m_flags(stream.flags()),
0026 m_precision(stream.precision()),
0027 m_width(stream.width()),
0028 m_fill(stream.fill()) {}
0029
0030 ~OstreamStateGuard() noexcept {
0031 m_stream->flags(m_flags);
0032 m_stream->precision(m_precision);
0033 m_stream->width(m_width);
0034 m_stream->fill(m_fill);
0035 }
0036
0037 OstreamStateGuard(const OstreamStateGuard&) = delete;
0038 OstreamStateGuard& operator=(const OstreamStateGuard&) = delete;
0039 OstreamStateGuard(OstreamStateGuard&&) = delete;
0040 OstreamStateGuard& operator=(OstreamStateGuard&&) = delete;
0041
0042 private:
0043 std::ostream* m_stream{};
0044 std::ios_base::fmtflags m_flags{};
0045 std::streamsize m_precision{};
0046 std::streamsize m_width{};
0047 char m_fill{};
0048 };
0049
0050 }