I've suddenly found a solution like this: 
*((qi::char_ - 'p') >> qi::omit[*qi::lit('p')])

But nevertheless it is interesting for me why my first attempt was wrong
and how should I understand its behavior.

Thanks.

On 24 November 2010 13:06, Paul Graphov <graphov@gmail.com> wrote:
Hello Boost Users, 

I'm now building configuration file parser with Boost.Spirit.
I have a little trouble understanding how this parser builds attribute:

It was supposed to parse strings throwing 'p' letter away.

*((qi::char_ - 'p') | qi::lit('p'))

attribute of qi::lit is Unused.
attribute of (qi::char_ - 'p') is char.

so attribute of ((qi::char_ - 'p') | qi::lit('p')) should be optional<char> that 
is uninitialized optional value when matched against character 'p'

After applying Kleene star it should became vector<optional<char> >.
It seems to be compatible with string (at least it compiles). But 'p' letters
are not thrown away.

The full example is here: http://pastebin.com/tCMw22Zy

The output of that example is:
Full parsing
Result: "abcpppdef"

Is it possible to make such a parser without using semantic actions
like [bind(&string::append, res, _1)] or something like that, which seem
to be less elegant solution.

Thanks!