On (16 Mar 97) Jean-Pol Landrain wrote to Jerry Coffin...
[ wanting to write a manipulator with two parameters ]
JL> With BC++.
JL> I remember wich macro I have to use for a manipulator with one
JL> parameter, but I can't remember how to do with two parameters.
Just FWIW, recent versions of BC++ use templates instead of macros.
However, since you say you're using macros, I'll do a macro based one.
The general idea is to create a class that holds both (or all three, or
whatever) of the arguments, so you can pass them as a single parameter
to the manipulator proper. You then create a front-end function that
takes the correct number of parameters, and creates an object out of
them, and passes that along to the real manipulator:
For demo purposes, I'll do a manipulator to print a specified number of
lines filled to a specifed width with a specified character:
#include
class line_filler {
char ch;
int width;
int lines;
public:
line_filler(char ch_ = 0, int width_ = 0, int lines_ = 0) :
ch(ch_), width(width_), lines(lines_) {}
static ostream &do_fill(ostream &stream, line_filler param) {
for ( int i=0;i * Origin: Point Pointedly Pointless (1:128/166.5)
|