AMDG On 09/06/2012 12:29 AM, Markus Lenger wrote:
Hi!
I face a problem using Boost.Variant 1.48 under Windows with Cygwin and g++ (GCC) 4.5.3. The following code crashes due to infinite recursion in the constructor of a_t:
#include
#include <iostream> struct a_t { boost::variant< boost::recursive_wrapper
,int > child; }; int main() { a_t a; std::cout << "OK" << std::endl; return 0; }
If I change the type of "child" to "boost::variant< int, boost::recursive_wrapper
>" (I just swapped the template parameters) the program prints "OK". Any ideas?
A default constructed variant contains a default constructed instance of the first variant type. Swapping the template parameters causes it to hold an int instead of recursively constructing an a_t. In Christ, Steven Watanabe