dReal4
precision_guard.h
1 #pragma once
2 
3 #include <iostream>
4 #include <limits>
5 
6 namespace dreal {
7 
8 /// Sets the decimal precision to be used to format floating-point
9 /// values on output operations. Restores the old precision when this guard is
10 /// destroyed.
11 class PrecisionGuard final {
12  public:
13  explicit PrecisionGuard(
14  std::ostream* os_,
15  std::streamsize precision = std::numeric_limits<double>::max_digits10);
16 
17  ~PrecisionGuard();
18 
19  PrecisionGuard(const PrecisionGuard&) = delete;
20  void operator=(const PrecisionGuard&) = delete;
21  PrecisionGuard(PrecisionGuard&&) = delete;
22  void operator=(PrecisionGuard&&) = delete;
23 
24  private:
25  std::ostream* os_{nullptr};
26  std::streamsize old_precision_;
27 };
28 } // namespace dreal
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9
Sets the decimal precision to be used to format floating-point values on output operations.
Definition: precision_guard.h:11