Boost C++ Libraries: Ticket #8554: make_variant_over requires Extensible Sequence https://svn.boost.org/trac10/ticket/8554 <p> Variant tries to perform operations not supported by a Forward Sequence on the sequence provided to make_variant_over. </p> <p> Conversely the type of variant&lt;T&gt;::types appears to be an Extensible Sequence which means: </p> <p> Can fix by amending docs to specify that sequences used must be Extensible Sequences (needs both changes as motivation for composing via joint_view was to avoid applying operations requiring Extensible Sequence to variant&lt;T&gt;::types) </p> <p> or </p> <p> Can fix by composing an Extensible Sequence in make_variant_over - something like: </p> <p> typedef boost::mpl::vector&lt;&gt; empty; typedef boost::mpl::insert_range&lt;empty, boost::mpl::end&lt;empty&gt;::type, Sequence&gt;::type <a class="missing wiki">ExtensibleSequence</a>; </p> <p> The following example shows the issue </p> <p> #include &lt;string&gt; #include &lt;boost/variant.hpp&gt; #include &lt;boost/mpl/joint_view.hpp&gt; #include &lt;boost/mpl/insert_range.hpp&gt; </p> <p> typedef boost::variant&lt;int&gt; v1; typedef boost::variant&lt;std::string&gt; v2; <em>typedef boost::make_variant_over&lt;boost::mpl::joint_view&lt;v1::types, v2::types&gt;::type&gt;::type v3; </em> FAILS - requires Extensible Sequence <em>typedef boost::variant&lt;int, std::string&gt; v3; </em> OK (obviously) <em>typedef boost::make_variant_over&lt;boost::mpl::insert_range&lt;v1::types, boost::mpl::end&lt;v1::types&gt;::type, v2::types::type&gt;::type&gt;::type v3; </em> OK (so types is probably an Extensible Sequence as insert_range works on it...) </p> <p> int main(int argc, char *argv[]) { </p> <blockquote> <p> v1 a = 1; v2 b = "2"; v3 c = a; return boost::get&lt;int&gt;(c); </p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8554 Trac 1.4.3 Darryl Green <darryl.green@…> Wed, 08 May 2013 01:19:48 GMT <link>https://svn.boost.org/trac10/ticket/8554#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8554#comment:1</guid> <description> <p> Sorry about formatting - try this.... </p> <div class="wiki-code"><div class="code"><pre><span class="c1">// possible &quot;fix&quot; to apply in make_variant_over</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">mpl</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;&gt;</span> <span class="n">empty</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">mpl</span><span class="o">::</span><span class="n">insert_range</span><span class="o">&lt;</span><span class="n">empty</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">mpl</span><span class="o">::</span><span class="n">end</span><span class="o">&lt;</span><span class="n">empty</span><span class="o">&gt;::</span><span class="n">type</span><span class="p">,</span> <span class="n">Sequence</span><span class="o">&gt;::</span><span class="n">type</span> <span class="n">ExtensibleSequence</span><span class="p">;</span> <span class="c1">// example</span> <span class="cp">#include</span> <span class="cpf">&lt;string&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/variant.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/mpl/joint_view.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/mpl/insert_range.hpp&gt;</span><span class="cp"></span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">variant</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">v1</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">variant</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&gt;</span> <span class="n">v2</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">make_variant_over</span><span class="o">&lt;</span><span class="n">boost</span><span class="o">::</span><span class="n">mpl</span><span class="o">::</span><span class="n">joint_view</span><span class="o">&lt;</span><span class="n">v1</span><span class="o">::</span><span class="n">types</span><span class="p">,</span> <span class="n">v2</span><span class="o">::</span><span class="n">types</span><span class="o">&gt;::</span><span class="n">type</span><span class="o">&gt;::</span><span class="n">type</span> <span class="n">v3</span><span class="p">;</span> <span class="c1">// FAILS - requires Extensible Sequence</span> <span class="c1">//typedef boost::variant&lt;int, std::string&gt; v3; // OK (obviously)</span> <span class="c1">//typedef boost::make_variant_over&lt;boost::mpl::insert_range&lt;v1::types, //boost::mpl::end&lt;v1::types&gt;::type, v2::types::type&gt;::type&gt;::type v3; // OK (so types is probably an Extensible Sequence as insert_range works on it...)</span> <span class="kt">int</span> <span class="nf">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="n">v1</span> <span class="n">a</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">v2</span> <span class="n">b</span> <span class="o">=</span> <span class="s">&quot;2&quot;</span><span class="p">;</span> <span class="n">v3</span> <span class="n">c</span> <span class="o">=</span> <span class="n">a</span><span class="p">;</span> <span class="k">return</span> <span class="n">boost</span><span class="o">::</span><span class="n">get</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span><span class="p">(</span><span class="n">c</span><span class="p">);</span> <span class="p">}</span> </pre></div></div> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 23 Jul 2017 19:33:25 GMT</pubDate> <title>owner, status, milestone changed https://svn.boost.org/trac10/ticket/8554#comment:2 https://svn.boost.org/trac10/ticket/8554#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">ebf</span> to <span class="trac-author">Antony Polukhin</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.65.0</span> </li> </ul> Ticket Antony Polukhin Sun, 23 Jul 2017 19:37:53 GMT <link>https://svn.boost.org/trac10/ticket/8554#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8554#comment:3</guid> <description> <p> Fixed by Mikhail Maximov in <a class="ext-link" href="https://github.com/boostorg/variant/pull/35"><span class="icon">​</span>PR35</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Tue, 26 Sep 2017 18:07:07 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8554#comment:4 https://svn.boost.org/trac10/ticket/8554#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket