Re: [Boost-users] [fusion] maps and arrays
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.
typedef std::tuple
, // note std::array std::string > test_t;
You inspired me with your use of std::array to try it out in my example. I changed "print_me" to use t.second instead of just t (which is correct) and then made a template function to support std::array with std::cout. That did the trick. Of course, the real goal here would be to handle it on the for_each side not the cout side, as outputting the types is not always the goal.
test_t test{1, 2, {}, {"hello"}};
You know one other weird thing, is that with boost 1.53 I could initialize this with std::array
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
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
{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
participants (2)
-
Agustín K-ballo Bergé
-
Seeger, Steven D. (GSFC-444.0)[Embedded Flight Systems, Inc]