Re: problems with binary variant visitors in 1.31

Never mind. Sorry I didn't notice 'const' in data(). Everything is pefect now. Eugene --- "E. Gladyshev" <egladysh@yahoo.com> wrote:
Great job with the 1.31 release!
Just wondering if anybody else observerved this kind of problems before. When compiling the code below with MSVC 7.1, I am getting this error: test.cpp(123) : error C2039: 'set' : is not a member of 'my_type::test1'. GCC 3.2.3 gives a compilation error as well.
template< typename T > struct binary_variant_visitor : public ::boost::static_visitor<> { T& obj_;
binary_variant_visitor( T& obj ) : obj_(obj) {}
template< typename VT1, typename VT2 > void operator()( VT1& v1, VT2& v2 ) { obj_.visit( v1, v2 ); } };
struct my_type { struct test1 { test1(); ~test1(); }; struct test2 { ~test2(); template< typename T > void set( T& ); };
typedef ::boost::variant<test1,test2> var;
var d_;
template< typename U > void visit( test1& t, U& u ) //test1 doesn't have set() { }
template< typename T, typename U > void visit( T& t, U& u ) { t.set(u); }
const var& data() const { return d_; } };
main() { my_type t1, t2;
binary_variant_visitor<my_type> v(t1); ::boost::apply_visitor(v, t1.data(), t2.data() ); }
If I change the last line to ::boost::apply_visitor(v, t1.d_, t2.d_ );
it works fine on both compilers. I guess it has something to do with how apply_visitor derives the parameter types.
Eugene
__________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html
__________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html
participants (1)
-
E. Gladyshev