Boost logo

Boost Users :

Subject: Re: [Boost-users] [proto] baby steps learning with proto, proxy object
From: Alfredo Correa (alfredo.correa_at_[hidden])
Date: 2010-10-08 15:45:01


On Fri, Oct 8, 2010 at 12:31 PM, Eric Niebler <eric_at_[hidden]> wrote:
>
> On 10/7/2010 2:52 PM, alfC wrote:
> <snip>
>> So I guess we can create a proxy of the expression h[x] , "subindex of
>> historgram with double". The proxy can be used with the syntax to call
>> either accumulate or increment depending on the application of += or +
>> + to the proxy.
>>
>> The naive implementation is this:
>> class histogram{
>>       ...
>>       private:
>>       struct proxy_histogram_subscript{
>>               histogram& self;
>>               double const& x;
>>               proxy_histogram_subscript(histogram& self, double const& x) :
>> self(self), x(x){}
>>               proxy_histogram_subscript const& operator++()
>> const{self.increment(x); return *this;}
>>               bool operator++(int) const{return self.increment(x);}
>>               bool operator+=(double const& weight) const{return
>> self.accumulate(x, weight);}
>>       };
>>       public:
>>       proxy_histogram_subscript operator[](double const& x){
>>               return proxy_histogram_subscript(*this, x);
>>       }
>> };
>>
>> which allows the desired syntax. The question is, can Boost.Proto do
>> better?
> <snip>
>
> Not really, I don't think. What you have is short, simple, and
> efficient. I wouldn't mess with it further.
>

Thank you, I was just checking whether it worth using proto for such a
minimicrolanguage.
At least for learning, but it seems not. Thank you for saving me a headache.

Alfredo

> --
> Eric Niebler
> BoostPro Computing
> http://www.boostpro.com
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> --
> Sie haben diese Nachricht erhalten, da Sie der Google Groups-Gruppe Boost Users beigetreten sind.
> Wenn Sie Nachrichten in dieser Gruppe posten möchten, senden Sie eine E-Mail an boostusers_at_googlegroups.com.
> Wenn Sie aus dieser Gruppe austreten möchten, senden Sie eine E-Mail an boostusers+unsubscribe_at_googlegroups.com.
> Besuchen Sie die Gruppe unter http://groups.google.com/group/boostusers?hl=de, um weitere Optionen zu erhalten.
>
>


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