Arcane  v4.1.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ScopedStreamModifier.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ScopedStreamModifier.h (C) 2000-2026 */
9/* */
10/* Save/Restore std::stream flags. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_ALINA_SCOPEDSTREAMMODIFIER_H
13#define ARCCORE_ALINA_SCOPEDSTREAMMODIFIER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16/*
17 * This file is based on the work on AMGCL library (version march 2026)
18 * which can be found at https://github.com/ddemidov/amgcl.
19 *
20 * Copyright (c) 2012-2022 Denis Demidov <dennis.demidov@gmail.com>
21 * SPDX-License-Identifier: MIT
22 */
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26#include <ios>
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane::Alina
32{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
39class ScopedStreamModifier
40{
41 public:
42
43 ScopedStreamModifier(std::ios_base& s)
44 : s(s)
45 , f(s.flags())
46 , p(s.precision())
47 {}
48 ~ScopedStreamModifier()
49 {
50 s.flags(f);
51 s.precision(p);
52 }
53
54 private:
55
56 std::ios_base& s;
57 std::ios_base::fmtflags f;
58 std::streamsize p;
59};
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64} // namespace Arcane::Alina
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69#endif