Subject: Re: [proto] Hold terminals by "smart" reference
From: Eric Niebler (eric_at_[hidden])
Date: 2012-06-02 20:59:20
On 6/2/2012 2:33 PM, Mathias Gaunard wrote:
> There are some terminals that, due to life-time issues, I cannot hold by
> reference. I don't want, however, to hold them by value.
> What I'm currently doing is that I'm holding a shared_ptr by value. For
> all practical purposes, however, I'd prefer if the expression behaved as
> a terminal of a reference, i.e. it would be nice if
> boost::proto::value(xpr) could directly return a T& and not a
> shared_ptr<T> const&.
There is no way to hook proto::value to return anything but what is
stored in the terminal. It's a very dumb, low-level function. You could
easily define your own value function that does something smarter, tho.
> Currently I need to treat terminals of shared_ptr specially, but ideally
> I'd like to have a way to extend terminal value capture with custom
> holding strategies.
> Any way to do this?
Value *capture* is another story. You can hook a domain's as_child as
described in the docs here: <http://bit.ly/L9Numg>
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Proto list run by eric at boostpro.com