For POD and even std::string boost variant works for me, but when I try my user type A, it fails for this code:
#include "stdafx.h"
#include <boost/variant/variant.hpp>
#include <boost/variant/get.hpp>
struct A
{
char ch;
};
int main()
{
boost::variant< int, A > n, a;
n = 33;
a = 'a';
try
{
int nn = boost::get< int >( n ); // ok
auto aa = boost::get< A >( a ); // throws bad_get
}
catch( boost::bad_get& )
{
bool okay = false;
}
return 0;
}
Why is that?