(1)
对一组普通的内部类型实现下面的Bound_form。
struct Bound_form { const Form& f; double vl; Bound_form(const Form& ff, double v) : f(ff), val(v) { } }; Bound_form Form::operator(){double d} const{ return Bound_form(*this,d); } ostream& operator<<(ostream& os, const Bound_form& bf) { ostringstream s; s.precision(bf.f.prc); s.setf(bf.f.fmt,ios_base::floatfield); s << bf.val; return os << s.str(); }(2)
重新实现(1)中的Bound_form,使得一个输出操作决不会溢出其width()。应该使程序员能保证当输出超出了有关的精度描述时绝不会默不作声地截断。