Boost logo

Boost :

Subject: Re: [boost] Assign V2 - first impression
From: er (er.ci.2020_at_[hidden])
Date: 2011-06-24 13:30:37


On 6/24/11 9:08 AM, Stewart, Robert wrote:
> er wrote:
>>
>>> I am sure that it is a powerful library, but I really have no
>>> idea at all what is going on. I can't even parse the first
>>> line as valid C++ in any way. You need better examples, and
>>> also is that really the best way you could find to express
>>> repeating?
>>
>> If I try to imagine what the interface would look like after
>> taking into account some of the suggestions that were made, this
>> sentence:
>>
>> "Create data elements by mapping 1, 10, 100, 1000 by function
>> f, and insert each result in cont by invoking modifier
>> push_front."
>
> If I interpret that correctly, it would be clearer as:
>
> "Create elements in cont, using push_front(), by calling f() 1, 10, 100, and 1000 times."
>

Apologies, I misread this. It should be :

Map 1, 10, 100, and 1000 by function f,
which yields f( 1 ), f( 10 ), f( 100 ), f( 1000 )
and insert each, n times, using push_front, in cont.

T x;

x = f( 1 );
for(int i = 0; i < n; i++){
     cont.push_front( x );
}

x = f( 10 );
for(int i = 0; i < n; i++){
     cont.push_front( x );
}

etc.

The meaning of what is said next, I think, is not altered.

>> translates to
>>
>> (
>> push_front<1>( cont ) % ( _data = f ) % ( _repeat = n )
>> )( 1, 10, 100, 1000 );
>
> Why the leading underscores on "_data" and "_repeat?"
>
>> Questions :
>> - is it more readable, now?
>> - What if each example was preceded by its English equivalent.
>
> Preceding each by a clear English equivalent is necessary.
>
> Could that code be spelled like the following instead?
>
> push_front<1>(cont).from(f).repeated(1, 10, 100, 1000);
>
> That is, instead of operator overloading, member functions would make things clearer and more succinct. Is there more to the operator overloading than I know making the member function approach too restrictive? What happens to your operator overloading approach when a using directive is not in force? Does "_data" become "boost::assign::_data," for example?
>
> _____
> Rob Stewart robert.stewart_at_[hidden]
> Software Engineer using std::disclaimer;
> Dev Tools& Components
> Susquehanna International Group, LLP http://www.sig.com
>
>
>
>
> IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of vi
> ruses.
> _______________________________________________
> Unsubscribe& other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk