Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] .at<N>() template member in containers?
From: Alfredo Correa (correaa_at_[hidden])
Date: 2010-10-06 15:58:45


On Wed, Oct 6, 2010 at 12:09 PM, michi7x7 <mailing-lists_at_[hidden]> wrote:

> Hi
>
>> Besides possible redundancy, why is that the fusion containers, for
>> example fusion::vector, doesn't have a template member function to
>> extract elements?
>>
> what do you mean? .at<>() is a template member function.
> at_c<N>() is from Boost.Spirit and uses .at<>() internally (i guess).
>

it doesn't seem so:

    vector<double, double, double> bfv;
    clog << bfv.at<0>() << endl; //ERROR
 error: ‘struct boost::fusion::vector<double, double, double,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_>’ has no member named ‘at’

> Wouldn't it be more consistent with std::vector v, v[2] or v.at(2);
>>
> That's not possible, because the return-type has to be known during
> compile-time. You can't do this with "normal" arguments.
>

presicely, I am asking for .at<N>() (I just noticed that boost::tuples have
.get<N>() member)

Thanks for the answer,
Alfredo



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