Boost C++ Libraries: Ticket #12680: Inheriting constructors from Boost.Variant should be possible https://svn.boost.org/trac10/ticket/12680 <p> Suppose users want a strong typedef for their sumtypes. Instead of creating a weak type alias for a boost::variant the user should be able to inherit from the variant inheriting its constructors, too. </p> <pre class="wiki">using TreeBase = boost::variant&lt;Leaf, boost::recursive_wrapper&lt;Node&gt;&gt;; struct Tree : TreeBase { using TreeBase::TreeBase; // ... }; </pre><p> Here is the full small self-contained example </p> <p> <a class="ext-link" href="https://gist.github.com/daniel-j-h/12c8b7f1c59b5a76c7e75dab38eb06fe#file-crash-cc"><span class="icon">​</span>https://gist.github.com/daniel-j-h/12c8b7f1c59b5a76c7e75dab38eb06fe#file-crash-cc</a> </p> <p> GCC crashing on this is ticketed upstream </p> <p> <a class="ext-link" href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78767"><span class="icon">​</span>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78767</a> </p> <p> Creating a new type for this use-case provides the user with type safety and should be the recommended way of using variant in any non-trivial code. Unfortunately, inheriting from Boost.Variant is not possible at the moment. The code example above does not compile. </p> <p> In the Boost IRC channel Agustín Bergé told me this might be related to inheriting constructors with default arguments and that there are quirks related to SFINAE before C++17. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12680 Trac 1.4.3 djh Mon, 12 Dec 2016 10:15:20 GMT attachment set https://svn.boost.org/trac10/ticket/12680 https://svn.boost.org/trac10/ticket/12680 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">crash.cc</span> </li> </ul> Ticket Antony Polukhin Fri, 20 Jan 2017 19:13:06 GMT owner, status, milestone changed https://svn.boost.org/trac10/ticket/12680#comment:1 https://svn.boost.org/trac10/ticket/12680#comment:1 <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.64.0</span> </li> </ul> <p> Fixed by Mikhail Maximov in <a class="ext-link" href="https://github.com/boostorg/variant/commit/217ee7f9ff769a1495e33f63d090ce70d54385a6"><span class="icon">​</span>217ee7f9</a>. Fix will be marged to master, as soon as all the tests will cycle. </p> Ticket Antony Polukhin Sat, 22 Apr 2017 06:01:43 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12680#comment:2 https://svn.boost.org/trac10/ticket/12680#comment:2 <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