Boost logo

Boost Users :

From: aitors2002 (aitors2002_at_[hidden])
Date: 2003-04-02 11:17:38


Hello, the next program doesn't work. It should print all the lines except the ones starting with '#'.
It does work in perl :
$ perl -ne 'print unless /^\s*\#/' a.cc

why ?

Thank you
                              aitor

-------------------
// a.cc
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<boost/regex.hpp>

int main() {

  using namespace std;

  ifstream f("a.cc");
  string l;
  vector<string> v;
  static const boost::regex r("^\\s*\\#", boost::regbase::escape_in_lists |
                                                            boost::regbase::perl);

  while(f) {
    getline(f,l,'\n');
    if (boost::regex_match(l,r)) continue;
    v.push_back(l);
  }
  for(vector<string>::const_iterator it = v.begin();
      it != v.end(); ++it)
    cout << *it << endl;
}


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