Boost C++ Libraries: Ticket #10133: boost 1.55 breaks fusion map arrays https://svn.boost.org/trac10/ticket/10133 <p> The attached code compiles and runs on 1.53 with the attached output. It fails to build on 1.55 with the attached error. (gcc 4.8.2) </p> <p> build with: </p> <p> g++ fusion_map.cpp -o fusion_map -std=c++11 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10133 Trac 1.4.3 anonymous Wed, 18 Jun 2014 17:33:55 GMT attachment set https://svn.boost.org/trac10/ticket/10133 https://svn.boost.org/trac10/ticket/10133 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">fusion_map.cpp</span> </li> </ul> Ticket anonymous Wed, 18 Jun 2014 17:34:08 GMT attachment set https://svn.boost.org/trac10/ticket/10133 https://svn.boost.org/trac10/ticket/10133 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">fusion_map_1.53</span> </li> </ul> Ticket anonymous Wed, 18 Jun 2014 17:34:37 GMT attachment set https://svn.boost.org/trac10/ticket/10133 https://svn.boost.org/trac10/ticket/10133 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">fusion_map.error.1.55</span> </li> </ul> Ticket anonymous Sat, 05 Jul 2014 15:58:49 GMT <link>https://svn.boost.org/trac10/ticket/10133#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10133#comment:1</guid> <description> <p> After a discussion on the mailing list, it was determined that my use of for_each is not correct. The library should not have stepped through each item of an array in a fusion map but rather send the whole array as a type to the function called on each value. It appears that this has been fixed in 1.55. </p> <p> I had a discussion on the mailing list with Agustin quoted below: </p> <blockquote class="citation"> <p> 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. </p> </blockquote> <p> I missed the part where <code>for_each</code> 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. -- </p> <p> This suggests that in reality what I was doing before was actually the bug, and that 1.55 has the correct behavior. </p> <p> One issue that we did find, however, is that fusion maps with std::array&lt;T&gt; types cannot have static initializers with 1.55. </p> <p> For example, </p> <blockquote> <p> typedef boost::fusion::map&lt;boost::fusion::pair&lt;struct blah, short&gt;, </p> <blockquote> <p> boost::fusion::pair&lt;struct bleh, int&gt;, boost::fusion::pair&lt;struct foo, std::array&lt;int, 2&gt;&gt;, boost::fusion::pair&lt;struct bloog, std::string&gt; &gt; test_t; </p> </blockquote> </blockquote> <p> </p> <blockquote> <p> test_t test{1,2, {{3,4}}, "test"}; </p> </blockquote> <p> This compiles with 1.53 but not 1.55. The {{3, 4}} is the issue. </p> <p> Also interestingly enough, I have to put braces around "test" with 1.53 but not 1.55. </p> </description> <category>Ticket</category> </item> <item> <author>Kohei Takahashi <flast@…></author> <pubDate>Sat, 21 Feb 2015 14:35:49 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10133#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10133#comment:2</guid> <description> <p> I believe that it is not a fusion's bug. </p> <p> The constructor of <code>map</code> will take their arguments by Universal References, like <code>template &lt;class... T&gt; map(T &amp;&amp;...)</code>, to accept any types and any value categories, i.e. perfect forwarding. However, compiler cannot deduce the argument type from brace-enclosed initializer, see below. </p> <p> n3337 14.8.2.1 [temp.deduct.call] p.1 sais: </p> <blockquote> <p> If removing references and cv-qualifiers from P gives std::initializer_list&lt;P 0 &gt; for some P 0 and the argument is an initializer list (8.5.4), then deduction is performed instead for each element of the initializer list, taking P 0 as a function template parameter type and the initializer element as its argument. Otherwise, an initializer list argument causes the parameter to be considered a non-deduced context (14.8.2.5). </p> </blockquote> <p> and 14.8.2.5 [temp.deduct.type] p.4 sais: </p> <blockquote> <p> If a template parameter is used only in non-deduced contexts and is not explicitly specified, template argument deduction fails. </p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>Kohei Takahashi</dc:creator> <pubDate>Fri, 06 Jul 2018 03:47:28 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/10133#comment:3 https://svn.boost.org/trac10/ticket/10133#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.68.0</span> </li> </ul> <p> The problem, <em>function returns array</em> will be resolved in next release, by <a class="ext-link" href="https://github.com/boostorg/fusion/pull/177"><span class="icon">​</span>https://github.com/boostorg/fusion/pull/177</a> . And another issue, brace initializer is now handled by <a class="ext-link" href="https://github.com/boostorg/fusion/issues/165"><span class="icon">​</span>https://github.com/boostorg/fusion/issues/165</a> . </p> <p> So I close this ticket with <em>resolved</em>. </p> Ticket