|
Boost Users : |
Subject: Re: [Boost-users] Proto: extending the example mixed.cpp
From: Eric Niebler (eric_at_[hidden])
Date: 2008-12-11 16:47:23
Kim Kuen Tang wrote:
> Hi all,
>
> i wnat to extend the example in the file mixed.cpp with an operator[]:
>
> double operator []( std::ptrdiff_t i ) const
> {
> DereferenceCtx const deref = {};
> AdvanceCtx adctx(i); //just shift the iterator with std::advance
> typename boost::result_of<Begin(Expr const &)>::type expr2 =
> Begin()(*this);
> proto::eval(expr2,adctx);
> return proto::eval(expr2, deref);
> }
> This works well.
>
> However is it possible to let proto figure out what the result_type of
> this function is?
>
> I've tried to program in this way.
>
> typedef typename boost::result_of<Begin(Expr const &)>::type Expr2;
> typedef typename proto::result_of::eval<Expr,DereferenceCtx>::type
<snip>
You probably need something like this:
typedef
typename boost::remove_reference<
typename boost::result_of<Begin(Expr const &)>::type
>::type
Expr2;
typedef
typename proto::result_of::eval<Expr2, DereferenceCtx>::type
result_type;
HTH,
-- Eric Niebler BoostPro Computing http://www.boostpro.com
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