Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-06-23 09:11:46


At 08:53 AM 6/23/2001, Kostya Altukhov wrote:

>Beman Dawes wrote:
>
>> >bind(f, _1, _2);
>> >one-based indexing is much more intuitive.
>>
>>My memory of past discussions in the C++ committee was a strong
preference
>
>>for consistent 0 based indexing even in the cases where it is less
>>intuitive.
>>
>Why than std::pair has 'first' and 'second' instead of 'nullth' and
'first'
>(and why tuple of two variables should use different scheme than
>std::pair)?
>
>Why do we have std::bind1st and std::bind2nd instead of std::bind0th
>and std::bind1st (and I think when we use tuples for binding,
>the scheme should be consistent with standard binders)?

Very good point!

So the rule actually seems something like:

    For by-value indexes such as selecting an element in a container, use 0
as the base. Examples: std::vector or std::string.

    For by-name ordinals such as naming operands, arguments, or structure
members, use 1 as the base. Examples: std::pair.first, std::bind1st.

On that basis, bind( f, _1, _2 ) seems the correct choice. It might be
worth mentioning the above rules in the rationale.

--Beman


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