indentlog: refactor: move stream-inserters to print/ subdir
This commit is contained in:
parent
5c60277610
commit
efe207a4de
19 changed files with 9 additions and 9 deletions
|
|
@ -1,45 +0,0 @@
|
|||
/* @file fixed.hpp */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace xo {
|
||||
/* use:
|
||||
* ostream os = ...;
|
||||
*
|
||||
* os << fixed(3.1415926, 3)
|
||||
*
|
||||
* writes
|
||||
* 3.142
|
||||
*
|
||||
* on os, restoring stream's formatting+precision state
|
||||
*/
|
||||
class fixed {
|
||||
public:
|
||||
fixed(double x, uint16_t prec) : x_{x}, prec_{prec} {}
|
||||
|
||||
/* print this value */
|
||||
double x_;
|
||||
/* precision */
|
||||
uint16_t prec_ = 0;
|
||||
}; /*fixed*/
|
||||
|
||||
inline std::ostream &
|
||||
operator<<(std::ostream & s, fixed const & fx)
|
||||
{
|
||||
std::ios::fmtflags orig_flags = s.flags();
|
||||
std::streamsize orig_p = s.precision();
|
||||
|
||||
s.flags(std::ios::fixed);
|
||||
s.precision(fx.prec_);
|
||||
s << fx.x_;
|
||||
|
||||
s.flags(orig_flags);
|
||||
s.precision(orig_p);
|
||||
|
||||
return s;
|
||||
} /*operator<<*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end fixed.hpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue