Boost C++ Libraries: Ticket #5455: std::vector<byte_> not assignable to std::vector<unsigned char> https://svn.boost.org/trac10/ticket/5455 <p> Using a rule that is like this: </p> <p> rule = (*qi::byte_) [at_c&lt;0&gt;(_val) = _1]; </p> <p> where _val is a fusion-adapted struct that has a member (std::vector&lt;uint8_t&gt;, data). </p> <p> I get an error that there is no viable overload of operator= for: </p> <blockquote> <p> BOOST_BINARY_RESULT_OF(x = y, result_of_assign) </p> </blockquote> <p> where x = std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt; and y = std::vector&lt;boost::integer::endian&lt;2, unsigned char, 8, 0&gt;, std::allocator&lt;boost::integer::endian&lt;2, unsigned char, 8, 0&gt; &gt; &gt; </p> <p> appears to occur in this instantiation: </p> <p> boost::phoenix::result_of_assign&lt;std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt; &amp;, std::vector&lt;boost::integer::endian&lt;2, unsigned char, 8, 0&gt;, std::allocator&lt;boost::integer::endian&lt;2, unsigned char, 8, 0&gt; &gt; &gt; &amp;&gt; </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5455 Trac 1.4.3 Joel de Guzman Mon, 11 Apr 2011 23:15:42 GMT <link>https://svn.boost.org/trac10/ticket/5455#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5455#comment:1</guid> <description> <p> Why is this a bug? Please provide a minimal cpp file I can try. Also see Spirit support: <a class="ext-link" href="http://boost-spirit.com/home/feedback-and-support/"><span class="icon">​</span>http://boost-spirit.com/home/feedback-and-support/</a> </p> </description> <category>Ticket</category> </item> <item> <author>jaredgrubb@…</author> <pubDate>Tue, 12 Apr 2011 05:33:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5455#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5455#comment:2</guid> <description> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/fusion/container/vector.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/fusion/adapted/struct/define_struct.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/spirit/include/phoenix.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/spirit/include/qi.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;vector&gt;</span><span class="cp"></span> <span class="n">BOOST_FUSION_DEFINE_STRUCT</span><span class="p">(</span> <span class="p">(),</span> <span class="n">Vector</span><span class="p">,</span> <span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">unsigned</span> <span class="kt">char</span><span class="o">&gt;</span><span class="p">,</span> <span class="n">v</span><span class="p">))</span> <span class="n">BOOST_FUSION_DEFINE_STRUCT</span><span class="p">(</span> <span class="p">(),</span> <span class="n">Byte</span><span class="p">,</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">char</span><span class="p">,</span> <span class="n">b</span><span class="p">))</span> <span class="kt">int</span> <span class="n">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">argv</span><span class="p">[])</span> <span class="p">{</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">spirit</span><span class="o">::</span><span class="n">qi</span><span class="p">;</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">phoenix</span><span class="p">;</span> <span class="cm">/* r1 compiles fine: byte_ assigns to unsigned char */</span> <span class="n">rule</span><span class="o">&lt;</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*</span><span class="p">,</span> <span class="n">Byte</span><span class="p">()</span><span class="o">&gt;</span> <span class="n">r1</span><span class="p">;</span> <span class="n">r1</span> <span class="o">=</span> <span class="n">byte_</span> <span class="p">[</span><span class="n">at_c</span><span class="o">&lt;</span><span class="mi">0</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_val</span><span class="p">)</span><span class="o">=</span><span class="n">_1</span><span class="p">];</span> <span class="cm">/* r2 does not compile: vector&lt;byte_&gt; does not assign to vector&lt;unsigned char&gt; */</span> <span class="n">rule</span><span class="o">&lt;</span><span class="kt">char</span> <span class="k">const</span> <span class="o">*</span><span class="p">,</span> <span class="n">Vector</span><span class="p">()</span><span class="o">&gt;</span> <span class="n">r2</span><span class="p">;</span> <span class="n">r2</span> <span class="o">=</span> <span class="p">(</span><span class="o">*</span><span class="n">byte_</span><span class="p">)</span> <span class="p">[</span><span class="n">at_c</span><span class="o">&lt;</span><span class="mi">0</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_val</span><span class="p">)</span><span class="o">=</span><span class="n">_1</span><span class="p">];</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Tue, 12 Apr 2011 06:03:26 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/5455#comment:3 https://svn.boost.org/trac10/ticket/5455#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Joel de Guzman</span> to <span class="trac-author">Hartmut Kaiser</span> </li> </ul> <p> Doesn't look like a bug to me. It's the same as trying to assign a vector&lt;boost::integer::endian&lt;2, unsigned char, 8, 0&gt; &gt; from a vector&lt;unsigned char&gt;. </p> <p> I'll forward to Hartmut Kaiser anyway. He's the author of the binary parsers. </p> Ticket Hartmut Kaiser Tue, 12 Apr 2011 12:10:17 GMT <link>https://svn.boost.org/trac10/ticket/5455#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5455#comment:4</guid> <description> <p> Joel is right, it just can't work the way you set it up. And there is no way for Spirit to figure out how to convert the two vectors. But why do you need to use semantic actions? If you were relying on Spirit's attribute propagation it would be possible to make it work: </p> <pre class="wiki">r2 = (*byte_) &gt;&gt; eps; </pre><p> compiles just fine and does what you expect. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Hartmut Kaiser</dc:creator> <pubDate>Tue, 12 Apr 2011 12:10:39 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5455#comment:5 https://svn.boost.org/trac10/ticket/5455#comment:5 <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">wontfix</span> </li> </ul> Ticket jaredgrubb@… Wed, 13 Apr 2011 02:31:47 GMT <link>https://svn.boost.org/trac10/ticket/5455#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5455#comment:6</guid> <description> <p> It just seems odd that all these work: </p> <pre class="wiki"> U = T U %= T std::vector&lt;U&gt; %= (*T) at_c&lt;n&gt;(U) = T </pre><blockquote> <p> but this fails: </p> </blockquote> <pre class="wiki"> at_c&lt;n&gt;(std::vector&lt;U&gt;) = std::vector&lt;T&gt; </pre><p> I was able to work around the issue by using phx::assign, but it just seems inconsistent, especially since there doesnt appear to be any useful way to combine at_c with a vector of byte_'s (std::vector&lt;boost::integer::endian&lt;2, unsigned char, 8, 0&gt; just doesnt seem to be the right way to do it, and it looks like that should be convertible to std::vector&lt;unsigned char&gt;). But, if it's "wontfix", I'll let it go. Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Thu, 14 Apr 2011 03:14:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5455#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5455#comment:7</guid> <description> <p> That std::vector&lt;U&gt; cannot be assigned to std::vector&lt;T&gt; is not the problem of Spirit but is the problem of the C++ standard library -which is beyond the scope of what we can do. I suggest what Hartmut mentioned: use attribute propagation. There, we have more control of what we can do for ease of use. </p> </description> <category>Ticket</category> </item> </channel> </rss>