Boost logo

Boost Users :

Subject: Re: [Boost-users] commandline args
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-08-24 02:17:11


On Sun, Aug 23, 2009 at 11:58 PM, Diederick C.
Niehorster<dcnieho_at_[hidden]> wrote:
> Yup, now it works.
>
> For reference, I got rid of the duplicated bk::eol also by using the
> folloing code:
>
> bk::generate(ostream_iterator<char>(cout),
>        "Command line options not recognized:\n" <<
>        ("  \"" << ba::string << '"' << bk::eol) % "",
>        vsTest);
>
> Not putting an empty char array after the modulus operator would be
> invalid C++ and is thus required.

Why not just use what I posted? There-for you will not have a
trailing eol, if you want a trailing eol then you should just loop it,
not list it, do this:
bk::generate(ostream_iterator<char>(cout),
       "Command line options not recognized:\n" <<
       +(" \"" << ba::string << '"' << bk::eol),
       vsTest);

The + in front of that loop section means 1 or more, you can also use
* for zero or more, but since you should be testing you array size
before you call this anyway, you know you have at least one, you can
also not do an array size test outside of it and do it inside the
parsing function but there is not much point here it is so simple. :)


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