Boost logo

Boost Users :

From: Olaf Peter (ope-devel_at_[hidden])
Date: 2008-04-01 01:10:05


Hi,

the following code did not work as expected:

--8<---
#include <iostream>
#include <sstream>
#include <boost/format.hpp>
#include <boost/xpressive/xpressive.hpp>

using namespace boost::xpressive;

int main()
{
     std::string input(
         "the answer is\r42"
         );

     const std::string f( "[Input]\n%1%\n|\n" );
     std::ostringstream oss;

#if 0
     oss << boost::format( f )
         % input
         ;
#else
     oss << input;
#endif

     sregex re = as_xpr("\r");
     std::string format("\n");

     std::ostream_iterator< char > out_iter( std::cout );
     regex_replace( out_iter, oss.str().begin(), oss.str().end(), re,
format );
}

--->8---

The first version displays nothings, the second adds garbage around the
text and prints the input string twice. Does exist some limitations or
did I ignore some basics?

Thanks,
Olaf


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