Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] maps and arrays
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2014-06-29 12:21:21


On 29/06/2014 10:52 a.m., Seeger, Steven D. (GSFC-444.0)[Embedded Flight
Systems, Inc] wrote:
> From: Agust?n K-ballo Berg?
> Subject: Re: [Boost-users] [fusion] maps and arrays
>
>> Not an official answer in any way, but considering it's not explicitly
>> documented as supported and your test case also fails when replacing
>> `fusion::map` with `std::tuple` I would consider it just a fluke in the
>> past. On the other hand, the following code compiles correctly (albeit
>> with possibly a warning):
>
> Hi Agustin thanks for your reply. You are correct that what I'm doing is not documented. In fact, it doesn't really make sense now that I look at it. The for_each should be called on each type. If the type is an array it doesn't make sense for a for_each to break down the array. That said, there should be some way to specialize operator() in the functor passed to it in order to correctly handle array types.

I missed the part where `for_each` was invoking the callable on each
element of the array, that is not how it is supposed to be. You are
right that making a recursive callable is the correct way to obtain that
behavior.

> You know one other weird thing, is that with boost 1.53 I could initialize this with std::array<int, 2> as:
>
> test_1 test{1,2, {{3,4}}, {"hello"}};
>
> Now with 1.55 it's only working with:
>
> test_1 test{1,2,std::int<array, 2>{3, 4}, "hello"}; //missing braces on string correct

Without any other information on the error you get, I'm betting that
this is due to adding support for C++11 (not-so) perfect forwarding:

     void foo(std::array<int, 2> const&){}

     template <typename T>
     void bar(T&& v){ foo(std::forward<T>(v)); }

     foo({3,4}); // ok
     bar({3,4}); // error: {3,4} has no type

Regards,

-- 
Agustín K-ballo Bergé.-
http://talesofcpp.fusionfenix.com

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