
On Sun, Aug 23, 2009 at 5:48 PM, Shaolin
Ok, so how do I print the results ?
2009/8/23 Steven Watanabe
AMDG
Shaolin wrote:
I have constructed some code but am getting some errors. I am trying to use a vector to hold several values but everytime I execute it I get a page worth of errors. Code below:
po::options_description desc("Available Options"); desc.add_options() ("file", po::value< vector<string> >(), "specify files to search") ;
po::variables_map vm; po::store(po::parse_command_line(ac, av, desc), vm); po::notify(vm);
if (vm.count("file")) { cout << "Files selected: " << vm["file"].as< vector<string> >() << "\n"; } else { cout << "No Files selected.\n"; }
The error is being caused by the following line:
cout << "Files selected: " << vm["file"].as< vector<string> >() << "\n";
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