|
Boost : |
From: Brian McNamara (lorgon_at_[hidden])
Date: 2004-02-06 05:50:43
I haven't tried any of this code, but I just happened to notice this
while glancing...
On Fri, Feb 06, 2004 at 02:29:53AM -0800, E. Gladyshev wrote:
...
> struct my_type
> {
...
> 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.
data() returns a "const &", whereas I think .d_ will be non-const.
Offhand I am kinda surprised that any of the visit() methods (which all
want non-const) end up matching, but I have not studied the code very
deeply.
In any case, maybe adding a
> var& data() { return d_; }
in addition to
> const var& data() const { return d_; }
will help.
-- -Brian McNamara (lorgon_at_[hidden])
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk