Boost logo

Boost Users :

From: tomasz2k_at_[hidden]
Date: 2007-08-29 09:49:34


Hello group

I'm using boost::format heavily to format my output for user. I've run into a problem that I cannot resolve for now. I use this format:

    int i = 4;
    cout << format ("(%|1$+2|)") % i; // -> (+4)
    i = -4;
    cout << format ("(%|1$+2|)") % i; // -> (-4)

That's fine and expected. But my question for the one below:

    int i = 0;
    cout << format ("(%|1$+2|)") % i; // -> ( 0)
                                      // -> ( ) how?

How to avoid printing 0? I want formatter to print values in plus or in minus only. When there's value 0 - display only spaces to width. My problem is that I cannot create wrapper over that integer, I must feed formatter with int for various reasons.

Does anyone know how to achive this? Maybe I override some parts of library or parsing method? Maybe some of you added your own formatts to formatter and want to share?

Any hint or example would be valuable. Thanks in advance,
Tomasz Kalkosiñski


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net