Boost logo

Boost :

Subject: Re: [boost] [TypeErasure] Forward constructors and binded types
From: Fabio Fracassi (f.fracassi_at_[hidden])
Date: 2012-07-18 16:32:09


On 7/18/12 5:44 PM, Steven Watanabe wrote:
> On 07/18/2012 06:57 AM, Larry Evans wrote:
>> On 07/18/12 01:29, Vicente J. Botet Escriba wrote:
>>> Hi,,
>>>
>>> In the example from the doc
>>
>> http://steven_watanabe.users.sourceforge.net/type_erasure/libs/type_erasure/doc/html/boost_typeerasure/multi.html
>>
>>>
>>> typedef mpl::vector<
>>> copy_constructible<_a>,
>>> copy_constructible<_b>,
>>> copy_constructible<_c>,
>>> constructible<_a(const _b&, const _c&)>
>>> > construct;
>>>
>>> std::vector<double> vec;
>>> int i = 10;
>>> double d = 2.5;
>>> tuple<construct, _a&, _b, _c> t(vec, i, d);
>>> any<construct, _a> v(get<1>(t), get<2>(t));
>>>
>>> I don't see which type is constructed and stored in v and how this type
>>> is given. That is I don't see how _a is binded. Could you help me?
>>>
>>
>> I'd guess that a std::vector<double>&, more specifically the
>> vec is stored as the _a& in the tuple<construct, _&a, _b, _c>.
>> Hmm... Now I'm not sure anymore. Maybe it's a new std::vector<double>
>> that's stored and the std::vector<double> CTOR args are
>> 10 and double. IOW the equivalent of:
>>
>> std::vector<double> v_a(10,2.5)
>>
>> is stored in v?
>>
>
> Yes.
>
>> Could the documentation on this be clarified a bit?
>>
>
> What needs to be clarified? This is the
> only reasonable behavior:

Just spelling out some thoughts I had while reading the docu:

Even though, it would help to have this information in the docu. The way
it is written now feels a bit like playing Jeopardy, you present
solutions and the reader tries to figure out the problem.

additionally I do not quite gasp on what I could use this feature for.
the above is much more complex as using
any<...> v = std::vector<double>(10, 2.5);
what am I buying with it?

And couldn't another syntax like
any<...> v(binding_of(vec), (int)10, (double)2.5);
be made to work, and be much more comfortable?

regards

Fabio


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