Boost logo

Boost Users :

Subject: Re: [Boost-users] commandline args
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2009-08-23 21:53:42


> >> The standard library doesn't provide output operators
> >> for containers.
>
> The same way that you would stream any normal vector:
> vector<string> &files = vm["file"].as< vector<string> >();
> vector<string>::const_iterator iter = files.begin();
> cout << "Files selected: ";
> for(;iter!=files.end();++iter)
> {
> cout << *iter << ";";
> }
> cout << "\n";
>
> If you do not know how to do that then you may want to read up on some
> C++ tutorials first before you start delving into something as big as
> LLVM.
>
>
> Consequently, if you have Boost trunk installed, then you could do
> this as well since it does support streaming vectors:
> #include <boost/spirit/include/karma.hpp>
> using namespace boost::spirit::karma;
> using namespace boost::spirit::ascii;
>
> generate(cout, "Files selected: " << (*char_)%';' << eol,
> vm["file"].as< vector<string> >());

Somewhat unrelated but FWIW: this can be simplified further:

generate(sink,
    "Files selected: " << string % ';' << eol,
    vm["file"].as< vector<string> >());

Regards Hartmut


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