From: Eric Friedman (ebf_at_[hidden])
Date: 2003-08-29 22:58:05
I've recently added reference support to variant. For instance, the
following is now supported:
int i = 3;
boost::variant<int&, double&> var(i);
i = 2;
BOOST_CHECK( boost::get<int>(var) == 2 );
However, such support required the addition of an additional variant
template <typename T> variant( T& );
which subsequently determines whether to treat the passed reference as a
reference-qua-reference or rather as a reference to some object.
Unfortunately, the addition of this constructor seems to have broken variant
under Metrowerks in some situations. So far, I have discovered that embedded
variants cause a problem when implicit conversions to these embedded
variants occur. If the preceding description is unclear, the attached file
demonstrates the problem in code.
The attached code compiles and runs successfully on MSVC 6.5, MSVC 7.1, gcc
3.2, and Borland 5.5.1, but I cannot get it to compile under CodeWarrior
8.3. The compiler complains about "ambiguous access to overloaded function."
My first instinct is to disable reference support for CodeWarrior (as
#defining BOOST_VARIANT_NO_REFERENCE_SUPPORT does solve the problem), but
CodeWarrior is generally a quite conformant compiler. I therefore hope
someone might find a workaround.
Of course, I will gladly assist (in explaining variant's internals, etc.)
anyone who steps up to the challenge.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk