![](http://static.javashuo.com/static/loading.gif)
#include <iostream>
![](http://static.javashuo.com/static/loading.gif)
#include <
string>
using
namespace std;
template<typename T, typename C>
class ManipInfra
![](http://static.javashuo.com/static/loading.gif)
{
private:
![](http://static.javashuo.com/static/loading.gif)
T val_;
![](http://static.javashuo.com/static/loading.gif)
basic_ostream<C>& (*manipFun_)(basic_ostream<C>&, T );
public:
![](http://static.javashuo.com/static/loading.gif)
ManipInfra(basic_ostream<C>& (*pFun)(basic_ostream<C>&, T), T val)
![](http://static.javashuo.com/static/loading.gif)
: manipFun_ (pFun), val_(val){
![](http://static.javashuo.com/static/loading.gif)
}
void
operator()(basic_ostream<C>& os)
const {
![](http://static.javashuo.com/static/loading.gif)
manipFun_(os, val_);
![](http://static.javashuo.com/static/loading.gif)
}
![](http://static.javashuo.com/static/loading.gif)
};
template<typename T, typename C>
![](http://static.javashuo.com/static/loading.gif)
basic_ostream<C>&
operator<<(basic_ostream<C>& os,
const ManipInfra<T, C>& manip) {
![](http://static.javashuo.com/static/loading.gif)
manip(os);
return os;
![](http://static.javashuo.com/static/loading.gif)
}
ostream& setTheWidth(ostream& os,
int n) {
![](http://static.javashuo.com/static/loading.gif)
os.width(n);
return os;
![](http://static.javashuo.com/static/loading.gif)
}
ostream& setTheFill(ostream& os,
char c) {
![](http://static.javashuo.com/static/loading.gif)
os.fill(c);
return os;
![](http://static.javashuo.com/static/loading.gif)
}
ManipInfra<
int,
char> setWidth(
int n) {
return ManipInfra<
int,
char>(setTheWidth, n);
![](http://static.javashuo.com/static/loading.gif)
}
ManipInfra<
char,
char> setFill(
char c) {
return ManipInfra<
char,
char>(setTheFill, c);
![](http://static.javashuo.com/static/loading.gif)
}
int main()
![](http://static.javashuo.com/static/loading.gif)
{
![](http://static.javashuo.com/static/loading.gif)
cout << setFill('*') << setWidth(19) << right <<
"djf\n";
return 0;
![](http://static.javashuo.com/static/loading.gif)
}