|
Boost : |
Subject: Re: [boost] [spirit] Support for one-pass iterators?
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2009-10-19 12:02:01
Andrey Semashev wrote:
> If you read carefully the post I gave link to, the answer should be
> clear. The library docs suggest the usage pattern that is invalid with
> the current state of code. It is possible to make user's code compatible
> with the library implementation (by using base-from-member idiom), but
> (a) this requirement is not documented and (b) this complicates the
> code. Point (b) is especially significant for me as I'm considering to
> upgrade from Spirit 1.8 to 2.
Why don't you simply believe Hartmut when he tells you that everything is fine?
OK, the dangerous looking code is as follows:
grammar(
start_type const& start
, std::string const& name_ = "unnamed-grammar")
=> : proto::extends<terminal, base_type>(terminal::make(
start.alias()))
, name_(name_)
{}
I completely agree that the constructor of start has not yet been called, because grammar is the base class of your object. However, the memory for start is already there, and the "this" pointer of start already has the "correct" value. Now, all "start.alias()" does is to return a wrapped reference to "*this" of the start object. Are you sure that this doesn't work?
Regards,
Thomas
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk