Boost logo

Boost :

Subject: Re: [boost] [iterator] Using zip_iterator with std::pair
From: Claas H. Köhler (claas.koehler_at_[hidden])
Date: 2012-10-16 13:06:42


On 16/10/12 14:27, Jeffrey Lee Hellrung, Jr. wrote:
> On Tue, Oct 16, 2012 at 4:21 AM, "Claas H. Köhler" <claas.koehler_at_[hidden]>wrote:
>
>>
>>
>> On 16/10/12 12:01, Giovanni Piero Deretta wrote:
>>> On Tue, Oct 16, 2012 at 9:06 AM, "Claas H. Köhler" <claas.koehler_at_[hidden]>
>> wrote:
>>>> Hi!
>>>>
>>>> I would like to use the boost::zip_iterator with std::pair.
>> Unfortunately this does not work out of
>>>> the box, but there exists a namespace
>> boost::detail::tuple_impl_specific, which apparently needs to
>>>> be specialised for each tuple type.
>>
>
> Hmmm...I guess it makes sense you might have to specialize something if
> zip_iterator doesn't specifically know about your desired tuple type.
>
>
>>>> I managed to re-implement tuple_meta_transform and
>> tuple_meta_accumulate for std::tuple, which seems
>>>> to be straightforward. However, there are functions of the form
>>>>
>>>> template<typename Tuple, typename Fun>
>>>> complex_result_type tuple_transform(const Tuple&, Fun)
>>>>
>>>> which have to be overloaded as well, if I am not mistaken. However,
>> overloading this with something like
>>>> template<typename... Args, typename Fun>
>>>> complex_result_type tuple_transform(const std::tuple<Args...>&, Fun)
>>>>
>>>> is probably not going to work, since this would be a partial template
>> specialisation of a function.
>>>
>>> That's an overload actually and should work fine. Did you try it?
>>>
>>> HTH,
>>
>> Thanks for the hint. I have to admit I did not try it yet. I have just
>> created a similar simple test
>> case, which indeed compiles/works fine. Shame on me for not trying it out.
>> For me this was always a
>> classical example of template function specialisation. I guess I should
>> take a look at template
>> basics again :-)
>>
>> Sorry for that and thanks for the quick response.
>>
>
> I'm glad you got it working, but ideally, I think, zip_iterator should work
> out of the box for std::pair and std::tuple. Could I trouble you to provide
> patches based on what you needed to get this to work?
>
> - Jeff

Unfortunately things are not working yet. As far as I can judge, the problem is that some of the
functions are called from within the zip_iterator.hpp header file, which is before I can actually
define the overloaded functions. As a result the overloaded functions are not called.

Should I get this working, however, I am glad to share the wisdom.

Regards
Claas


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