CppADCodeGen 2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
Loading...
Searching...
No Matches
ostream_config_restore.hpp
1#ifndef CPPAD_CG_OSTREAM_CONFIG_RESTORE_INCLUDED
2#define CPPAD_CG_OSTREAM_CONFIG_RESTORE_INCLUDED
3/* --------------------------------------------------------------------------
4 * CppADCodeGen: C++ Algorithmic Differentiation with Source Code Generation:
5 * Copyright (C) 2015 Ciengis
6 *
7 * CppADCodeGen is distributed under multiple licenses:
8 *
9 * - Eclipse Public License Version 1.0 (EPL1), and
10 * - GNU General Public License Version 3 (GPL3).
11 *
12 * EPL1 terms and conditions can be found in the file "epl-v10.txt", while
13 * terms and conditions for the GPL3 can be found in the file "gpl3.txt".
14 * ----------------------------------------------------------------------------
15 * Author: Joao Leal
16 */
17
18#include <iostream>
19
20namespace CppAD {
21namespace cg {
22
24private:
25 std::ostream& os;
26 std::ios::fmtflags f;
27 std::streamsize nf;
28 std::streamsize nw;
29public:
30
31 inline explicit OStreamConfigRestore(std::ostream& os) :
32 os(os),
33 f(os.flags()),
34 nf(os.precision()),
35 nw(os.width()) {
36 }
37
38 OStreamConfigRestore(const OStreamConfigRestore &rhs) = delete;
39 OStreamConfigRestore& operator=(const OStreamConfigRestore& rhs) = delete;
40
41 inline ~OStreamConfigRestore() {
42 os.flags(f);
43 os.precision(nf);
44 os.width(nw);
45 }
46};
47
48} // END cg namespace
49} // END CppAD namespace
50
51#endif