I definitely had success. First, I used the following code:
#include <boost/xpressive/xpressive.hpp> #include <iostream> using namespace std; using namespace boost::xpressive; //A simple regex test int main() { std::string hello( "hello world!" ); sregex rex = sregex::compile( "(\\w+) (\\w+)!" ); smatch what; if( regex_match( hello, what, rex ) ) { std::cout << what[0] << '\n'; // whole match std::cout << what[1] << '\n'; // first capture std::cout << what[2] << '\n'; // second capture } return 0; }
It was just a hello world from Boost Xpressive (see link below). Firstly, I compiled with the -H option in gcc. He showed a huge list of titles that he used. Then I looked at the flag compilation that my IDE (code :: blocks) created and saw something like this:
g++ -Wall -fexceptions -g -c main.cpp -o obj/Debug/main.o
So, I wrote a command to compile the Xpressive.hpp file with the same flags:
sudo g++ -Wall -fexceptions -g /usr/local/include/boost/xpressive/xpressive.hpp
I compiled the source code with -H and got this output:
g ++ -Wall -fexceptions -H -g -c main.cpp -o obj / Debug / main.o
! /usr/local/include/boost/xpressive/xpressive.hpp.gch
main.cpp
. /usr/include/c++/4.4/iostream
.. /usr/include/c++/4.4/x86_64-linux-gnu/bits/c++config.h
.. /usr/include/c++/4.4/ostream
.. /usr/include/c++/4.4/istream
main.cpp
The! means that the compiler was able to use a precompiled header. X means that he could not use it. Using the appropriate compiler flags is crucial. I took off -H and did some speed tests. The precompiled header had an improvement from 14 seconds to 11 seconds. Not bad, but not very.
Note: here is an example link: http://www.boost.org/doc/libs/1_43_0/doc/html/xpressive/user_s_guide.html#boost_xpressive.user_s_guide.examples I couldn’t get it to work in the message.
BTW: I am using the following g ++
g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
User1 May 29 '10 at 2:59 p.m. 2010-05-29 14:59
source share