Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I make a recursive boost::variant which works with gcc 4.6?
    text
    copied!<p>I am decoding bencode, and have some code which works well with gcc 4.4. But having recently upgraded to gcc 4.6 this code no longer builds:</p> <pre><code>#ifndef BENCODE_VALUETYPES_H #define BENCODE_VALUETYPES_H #include &lt;boost/variant.hpp&gt; #include &lt;string&gt; #include &lt;vector&gt; #include &lt;map&gt; namespace bencode { typedef boost::make_recursive_variant&lt; int, std::string, std::vector&lt;boost::recursive_variant_&gt;, std::map&lt;std::string, boost::recursive_variant_&gt; &gt;::type Value; typedef std::map&lt;std::string, Value&gt; ValueDictionary; typedef std::vector&lt;Value&gt; ValueVector; }; #endif </code></pre> <p>g++ gives this error message:</p> <pre><code>/usr/include/c++/4.6/bits/stl_pair.h: In instantiation of 'std::pair&lt;const std::basic_string&lt;char&gt;, boost::recursive_variant_&gt;': Decoder.cpp:97:39: instantiated from here /usr/include/c++/4.6/bits/stl_pair.h:93:11: error: 'std::pair&lt;_T1, _T2&gt;::second' has incomplete type /usr/include/boost/variant/variant_fwd.hpp:232:12: error: forward declaration of 'struct boost::recursive_variant_' </code></pre> <p>The <a href="http://www.boost.org/doc/libs/1_48_0/doc/html/variant/tutorial.html#variant.tutorial.recursive" rel="nofollow">documentation</a> for the latest boost version (1.48 at the moment) states that "due to standard conformance issues in several compilers, make_recursive_variant is not universally supported", and that you should use the recursive_wrapper instead. But I am having problem making the change: does anyone know what this should look like using the wrapper?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload