Boost logo

Boost :

Subject: Re: [boost] Assign V2 - first impression
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2011-06-24 16:33:19


er wrote:
>> Now if you want to repeat the operation of inserting the element f(
>> x ), I'm not sure how you do that with Range, but with V2, after
>> learning the syntax, it's relatively straightforward:
>>
>> ( put_front<1>( cont ) % ( _data = f ) % ( _repeat = n ) )( 1, 10,
>> 100, 1000 );
>>
>
> This was suggested, which is probably the best:
>
> push_front<1>( cont , _data = f, _repeat = n )( 1, 10, 100, 1000 );
>
> More generally,
>
> // Fixed arity:
> push_front<I>( cont , options... )( a1,...,aI,...,z1,...,zI );
>
> // Variadic
> push_front( cont , options... )( args1 )...( argsn );
>
> where in each case (fixed and variadic), options... modify the
> semantics
> of the subsequent calls to operator().

Can we change the name of _data to something like _filter? Also, I don't like the pre and post _ names in the interface. If you want to use a convention related to pre and post _ in the implementation details that's fine, but I don't think it is appropriate in the interface. If you use boost.parameter I think you would get a post _ charater, I believe, so having both pre and post _ for different reasons seems confusing.

Also, it would be nice to have iterator pair and range be acceptable alternatives to the fixed arity and variadic options shown above. I realize that would require some SFINAE, but I think being able to consistently initialize containers and then mix the forms would be a big plus.

char* cstr[] = "Hello world!";
std::vector<char> chrs;
push_back( chrs , filter = to_upper )( cstr, cstr+5 )( '\0' );

chrs contains a null terminated string "HELLO".

There is then a whole area of treating std::string like a container by specializing some of your library interfaces that would really be handy.

Regards,
Luke


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